Documentation ¶
Overview ¶
Package balancer is a forked version of https://github.com/GoogleCloudPlatform/grpc-gcp-go.
Index ¶
- Constants
- Variables
- func ParseAPIConfig(path string) (*pb.ApiConfig, error)
- type DialFunc
- type GCPInterceptor
- func (gcpInt *GCPInterceptor) GCPStreamClientInterceptor(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, ...) (grpc.ClientStream, error)
- func (gcpInt *GCPInterceptor) GCPUnaryClientInterceptor(ctx context.Context, method string, req interface{}, reply interface{}, ...) error
- type RRConnPool
- func (p *RRConnPool) Close() error
- func (p *RRConnPool) Conn() *grpc.ClientConn
- func (p *RRConnPool) Invoke(ctx context.Context, method string, args interface{}, reply interface{}, ...) error
- func (p *RRConnPool) NewStream(ctx context.Context, desc *grpc.StreamDesc, method string, ...) (grpc.ClientStream, error)
Constants ¶
const (
// Name is the name of grpc_gcp balancer.
Name = "grpc_gcp"
)
Variables ¶
var ( // DefaultMinConnections is the default number of gRPC sub-connections the // gRPC balancer should create during SDK initialization. DefaultMinConnections = 5 // MinConnections is the minimum number of gRPC sub-connections the gRPC balancer // should create during SDK initialization. // It is initialized in flags package. MinConnections = DefaultMinConnections )
Functions ¶
Types ¶
type DialFunc ¶
type DialFunc func(ctx context.Context) (*grpc.ClientConn, error)
DialFunc defines the dial function used in creating the pool.
type GCPInterceptor ¶
type GCPInterceptor struct {
// contains filtered or unexported fields
}
GCPInterceptor provides functions for intercepting client requests in order to support GCP specific features
func NewGCPInterceptor ¶
func NewGCPInterceptor(config *pb.ApiConfig) *GCPInterceptor
NewGCPInterceptor creates a new GCPInterceptor with a given ApiConfig
func (*GCPInterceptor) GCPStreamClientInterceptor ¶
func (gcpInt *GCPInterceptor) GCPStreamClientInterceptor( ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption, ) (grpc.ClientStream, error)
GCPStreamClientInterceptor intercepts the execution of a client streaming RPC and injects necessary information to be used by the picker.
func (*GCPInterceptor) GCPUnaryClientInterceptor ¶
func (gcpInt *GCPInterceptor) GCPUnaryClientInterceptor( ctx context.Context, method string, req interface{}, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption, ) error
GCPUnaryClientInterceptor intercepts the execution of a unary RPC and injects necessary information to be used by the picker.
type RRConnPool ¶
type RRConnPool struct { grpc.ClientConnInterface io.Closer // contains filtered or unexported fields }
RRConnPool is a pool of *grpc.ClientConn that are selected in a round-robin fashion.
func NewRRConnPool ¶
NewRRConnPool makes a new instance of the round-robin connection pool and dials as many as poolSize connections using the provided dialFn.
func (*RRConnPool) Close ¶
func (p *RRConnPool) Close() error
Close closes all connections in the bool.
func (*RRConnPool) Conn ¶
func (p *RRConnPool) Conn() *grpc.ClientConn
Conn picks the next connection from the pool in a round-robin fasion.
func (*RRConnPool) Invoke ¶
func (p *RRConnPool) Invoke(ctx context.Context, method string, args interface{}, reply interface{}, opts ...grpc.CallOption) error
Invoke picks up a connection from the pool and delegates the call to it.
func (*RRConnPool) NewStream ¶
func (p *RRConnPool) NewStream(ctx context.Context, desc *grpc.StreamDesc, method string, opts ...grpc.CallOption) (grpc.ClientStream, error)
NewStream picks up a connection from the pool and delegates the call to it.