dubbo.apache.org/dubbo-go/v3@v3.1.1/xds/internal/internal.go (about) 1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 /* 19 * 20 * Copyright 2016 gRPC authors. 21 * 22 */ 23 24 // Package internal contains gRPC-internal code, to avoid polluting 25 // the godoc of the top-level grpc package. It must not import any grpc 26 // symbols to avoid circular dependencies. 27 package internal 28 29 import ( 30 "context" 31 "time" 32 ) 33 34 import ( 35 "google.golang.org/grpc/connectivity" 36 37 "google.golang.org/grpc/serviceconfig" 38 ) 39 40 var ( 41 // WithHealthCheckFunc is set by dialoptions.go 42 WithHealthCheckFunc interface{} // func (HealthChecker) DialOption 43 // HealthCheckFunc is used to provide client-side LB channel health checking 44 HealthCheckFunc HealthChecker 45 // BalancerUnregister is exported by package balancer to unregister a balancer. 46 BalancerUnregister func(name string) 47 // KeepaliveMinPingTime is the minimum ping interval. This must be 10s by 48 // default, but tests may wish to set it lower for convenience. 49 KeepaliveMinPingTime = 10 * time.Second 50 // ParseServiceConfigForTesting is for creating a fake 51 // ClientConn for resolver testing only 52 ParseServiceConfigForTesting interface{} // func(string) *serviceconfig.ParseResult 53 // EqualServiceConfigForTesting is for testing service config generation and 54 // parsing. Both a and b should be returned by ParseServiceConfigForTesting. 55 // This function compares the config without rawJSON stripped, in case the 56 // there's difference in white space. 57 EqualServiceConfigForTesting func(a, b serviceconfig.Config) bool 58 // GetCertificateProviderBuilder returns the registered builder for the 59 // given name. This is set by package certprovider for use from xDS 60 // bootstrap code while parsing certificate provider configs in the 61 // bootstrap file. 62 GetCertificateProviderBuilder interface{} // func(string) certprovider.Builder 63 // GetXDSHandshakeInfoForTesting returns a pointer to the xds.HandshakeInfo 64 // stored in the passed in attributes. This is set by 65 // credentials/xds/xds.go. 66 GetXDSHandshakeInfoForTesting interface{} // func (*attributes.Attributes) *xds.HandshakeInfo 67 // GetServerCredentials returns the transport credentials configured on a 68 // gRPC server. An xDS-enabled server needs to know what type of credentials 69 // is configured on the underlying gRPC server. This is set by server.go. 70 GetServerCredentials interface{} // func (*grpc.Server) credentials.TransportCredentials 71 // DrainServerTransports initiates a graceful close of existing connections 72 // on a gRPC server accepted on the provided listener address. An 73 // xDS-enabled server invokes this method on a grpc.Server when a particular 74 // listener moves to "not-serving" mode. 75 DrainServerTransports interface{} // func(*grpc.Server, string) 76 ) 77 78 // HealthChecker defines the signature of the client-side LB channel health checking function. 79 // 80 // The implementation is expected to create a health checking RPC stream by 81 // calling newStream(), watch for the health status of serviceName, and report 82 // it's health back by calling setConnectivityState(). 83 // 84 // The health checking protocol is defined at: 85 // https://github.com/grpc/grpc/blob/master/doc/health-checking.md 86 type HealthChecker func(ctx context.Context, newStream func(string) (interface{}, error), setConnectivityState func(connectivity.State, error), serviceName string) error 87 88 const ( 89 // CredsBundleModeFallback switches GoogleDefaultCreds to fallback mode. 90 CredsBundleModeFallback = "fallback" 91 // CredsBundleModeBalancer switches GoogleDefaultCreds to grpclb balancer 92 // mode. 93 CredsBundleModeBalancer = "balancer" 94 // CredsBundleModeBackendFromBalancer switches GoogleDefaultCreds to mode 95 // that supports backend returned by grpclb balancer. 96 CredsBundleModeBackendFromBalancer = "backend-from-balancer" 97 )