gitee.com/ks-custle/core-gm@v0.0.0-20230922171213-b83bdd97b62c/grpc/internal/internal.go (about)

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