Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrClosed is the error when the client pool is closed ErrClosed = errors.New("client pool is closed") // ErrTimeout is the error when the client pool timed out ErrTimeout = errors.New("get client timed out") // ErrFullPool is the error when the pool is already full ErrFullPool = errors.New("can't create ClientConn into a full pool") )
Error defined
Functions ¶
This section is empty.
Types ¶
type ClientConn ¶
type ClientConn struct { *grpc.ClientConn // contains filtered or unexported fields }
ClientConn is the basic unit in the pool
func (*ClientConn) Put ¶
func (client *ClientConn) Put()
Put return the ClientConn when client call finish
type Factory ¶
type Factory func() (*grpc.ClientConn, error)
Factory function type to create a new gRPC client
type Options ¶
type Options struct { Factory Factory PoolSize int MinIdleConns int UsedPreConn int MaxConnLifeTime time.Duration IdleTimeout time.Duration }
Options Pool Options defined
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool struct defined
func New ¶
func New(factory Factory, minIdleConns, poolSize, usedPreConn int, idleTimeout, maxLifetime time.Duration) (*Pool, error)
New create and init a new gRPC pool
func (*Pool) CloseClient ¶
func (p *Pool) CloseClient(client *ClientConn) error
CloseClient will remove the client And close it
Click to show internal directories.
Click to hide internal directories.