Documentation ¶
Index ¶
- Variables
- func KeepAliveDialer(addr string, timeout time.Duration) (net.Conn, error)
- func TLSConfig(serverName string) *tls.Config
- type Pool
- func (p *Pool) AddDialOption(opts ...grpc.DialOption)
- func (p *Pool) Close(target ...string)
- func (p *Pool) CloseConn(conn *grpc.ClientConn)
- func (p *Pool) DialInsecure(target string) (*grpc.ClientConn, error)
- func (p *Pool) DialSecure(target string, creds credentials.TransportCredentials) (*grpc.ClientConn, error)
- func (p *Pool) SetContext(ctx context.Context)
Constants ¶
This section is empty.
Variables ¶
var DefaultDialOptions = []grpc.DialOption{ grpc.WithUnaryInterceptor(grpc_middleware.ChainUnaryClient( grpc_prometheus.UnaryClientInterceptor, rpcerror.UnaryClientInterceptor(errors.FromGRPCError), rpclog.UnaryClientInterceptor(nil), )), grpc.WithStreamInterceptor(grpc_middleware.ChainStreamClient( grpc_prometheus.StreamClientInterceptor, rpcerror.StreamClientInterceptor(errors.FromGRPCError), restartstream.Interceptor(restartstream.DefaultSettings), rpclog.StreamClientInterceptor(nil), )), grpc.WithDialer(KeepAliveDialer), grpc.WithBlock(), }
DefaultDialOptions for connecting with servers
var Global = NewPool(context.Background(), DefaultDialOptions...)
Global pool with connections
var RootCAs *x509.CertPool
RootCAs to use in API connections
Functions ¶
func KeepAliveDialer ¶
KeepAliveDialer is a dialer that adds a 10 second TCP KeepAlive
Types ¶
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool with connections
func NewPool ¶
func NewPool(ctx context.Context, dialOptions ...grpc.DialOption) *Pool
NewPool returns a new connection pool that uses the given DialOptions
func (*Pool) AddDialOption ¶
func (p *Pool) AddDialOption(opts ...grpc.DialOption)
AddDialOption adds DialOption for the pool. Only new connections will use these new DialOptions
func (*Pool) CloseConn ¶ added in v2.7.1
func (p *Pool) CloseConn(conn *grpc.ClientConn)
CloseConn closes a connection.
func (*Pool) DialInsecure ¶
func (p *Pool) DialInsecure(target string) (*grpc.ClientConn, error)
DialInsecure gets a connection from the pool or creates a new one This function is blocking if grpc.WithBlock() is used
func (*Pool) DialSecure ¶
func (p *Pool) DialSecure(target string, creds credentials.TransportCredentials) (*grpc.ClientConn, error)
DialSecure gets a connection from the pool or creates a new one This function is blocking if grpc.WithBlock() is used
func (*Pool) SetContext ¶
SetContext sets a new background context for the pool. Only new connections will use this new context