pool

package
v2.10.1+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 18, 2019 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

Global pool with connections

View Source
var RootCAs *x509.CertPool

RootCAs to use in API connections

Functions

func KeepAliveDialer

func KeepAliveDialer(addr string, timeout time.Duration) (net.Conn, error)

KeepAliveDialer is a dialer that adds a 10 second TCP KeepAlive

func TLSConfig

func TLSConfig(serverName string) *tls.Config

TLSConfig that will be used when dialing securely without supplying TransportCredentials

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) Close

func (p *Pool) Close(target ...string)

Close connections. If no target names supplied, just closes all.

func (*Pool) CloseConn

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

func (p *Pool) SetContext(ctx context.Context)

SetContext sets a new background context for the pool. Only new connections will use this new context

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL