import "github.com/AKA-bingo/grpcpool"
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
type ClientConn struct { *grpc.ClientConn // contains filtered or unexported fields }
ClientConn is the basic unit in the pool
func (client *ClientConn) Put()
Put return the ClientConn when client call finish
type Factory func() (*grpc.ClientConn, error)
Factory function type to create a new gRPC client
type Options struct { Factory Factory PoolSize int MinIdleConns int UsedPreConn int MaxConnLifeTime time.Duration IdleTimeout time.Duration }
Options Pool Options defined
type Pool struct {
// contains filtered or unexported fields
}
Pool struct defined
func New(factory Factory, minIdleConns, poolSize, usedPreConn int, idleTimeout, maxLifetime time.Duration) (*Pool, error)
New create and init a new gRPC pool
Close the pool and release resources
func (p *Pool) CloseClient(client *ClientConn) error
CloseClient will remove the client And close it
Get an Available client to use
Print the pool to monitor Usage
Package grpcpool imports 8 packages (graph). Updated 2019-08-14. Refresh now. Tools for package owners.