blob: bc1f99ac80306a0d46031223cfaf809ea0144821 [file] [log] [blame]
Scott Bakereee8dd82019-09-24 12:52:34 -07001/*
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.
21package internal
22
23import (
24 "context"
25 "time"
Scott Baker611f6bd2019-10-18 13:45:19 -070026
27 "google.golang.org/grpc/connectivity"
Scott Bakereee8dd82019-09-24 12:52:34 -070028)
29
30var (
31 // WithResolverBuilder is exported by dialoptions.go
32 WithResolverBuilder interface{} // func (resolver.Builder) grpc.DialOption
33 // WithHealthCheckFunc is not exported by dialoptions.go
34 WithHealthCheckFunc interface{} // func (HealthChecker) DialOption
35 // HealthCheckFunc is used to provide client-side LB channel health checking
36 HealthCheckFunc HealthChecker
37 // BalancerUnregister is exported by package balancer to unregister a balancer.
38 BalancerUnregister func(name string)
39 // KeepaliveMinPingTime is the minimum ping interval. This must be 10s by
40 // default, but tests may wish to set it lower for convenience.
41 KeepaliveMinPingTime = 10 * time.Second
Scott Baker611f6bd2019-10-18 13:45:19 -070042 // ParseServiceConfig is a function to parse JSON service configs into
43 // opaque data structures.
44 ParseServiceConfig func(sc string) (interface{}, error)
45 // StatusRawProto is exported by status/status.go. This func returns a
46 // pointer to the wrapped Status proto for a given status.Status without a
47 // call to proto.Clone(). The returned Status proto should not be mutated by
48 // the caller.
49 StatusRawProto interface{} // func (*status.Status) *spb.Status
Scott Bakereee8dd82019-09-24 12:52:34 -070050)
51
52// HealthChecker defines the signature of the client-side LB channel health checking function.
Scott Baker611f6bd2019-10-18 13:45:19 -070053//
54// The implementation is expected to create a health checking RPC stream by
55// calling newStream(), watch for the health status of serviceName, and report
56// it's health back by calling setConnectivityState().
57//
58// The health checking protocol is defined at:
59// https://github.com/grpc/grpc/blob/master/doc/health-checking.md
60type HealthChecker func(ctx context.Context, newStream func(string) (interface{}, error), setConnectivityState func(connectivity.State), serviceName string) error
Scott Bakereee8dd82019-09-24 12:52:34 -070061
62const (
63 // CredsBundleModeFallback switches GoogleDefaultCreds to fallback mode.
64 CredsBundleModeFallback = "fallback"
65 // CredsBundleModeBalancer switches GoogleDefaultCreds to grpclb balancer
66 // mode.
67 CredsBundleModeBalancer = "balancer"
68 // CredsBundleModeBackendFromBalancer switches GoogleDefaultCreds to mode
69 // that supports backend returned by grpclb balancer.
70 CredsBundleModeBackendFromBalancer = "backend-from-balancer"
71)