Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrClosed is the error when the client pool is closed ErrClosed = errors.New("grpc pool: client pool is closed") // ErrTimeout is the error when the client pool timed out ErrTimeout = errors.New("grpc pool: client pool timed out") // ErrAlreadyClosed is the error when the client conn was already closed ErrAlreadyClosed = errors.New("grpc pool: the connection was already closed") // ErrFullPool is the error when the pool is already full ErrFullPool = errors.New("grpc pool: closing a ClientConn into a full pool") )
Functions ¶
This section is empty.
Types ¶
type ClientFactory ¶
type ClientFactory func() (*grpc.ClientConn, error)
ClientFactory is a function type creating a grpc client
type Option ¶
Option is used to configure a pool.
func WithIdleTimeout ¶
WithIdleTimeout configures the idle timeout for a gRPC connection.
func WithInitialCapacity ¶
WithInitialCapacity configures the initial capacity of the pool.
func WithMaxCapacity ¶
WithMaxCapacity configures the max capacity of the pool.
func WithMaxLifeDuration ¶
WithMaxLifeDuration configures the max life time of a gRPC connection.
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool is the grpc client pool
func New ¶
func New(factory ClientFactory, opts ...Option) (*Pool, error)
New creates a new client pool using the given options and returns an error if the initial clients could not be created.
func (*Pool) Close ¶
Close empties the pool calling Close on all its clients. You can call Close while there are outstanding clients. It waits for all clients to be returned (Close). The pool channel is then closed, and Get will not be allowed anymore
type PooledClientConn ¶
type PooledClientConn struct {
*grpc.ClientConn
// contains filtered or unexported fields
}
PooledClientConn is a wrapper for a grpc client conn
func (*PooledClientConn) Close ¶
func (pcc *PooledClientConn) Close() error
Close returns a ClientConn to the pool. It is safe to call multiple time, but will return an error after first time
func (*PooledClientConn) MarkUnhealthy ¶
func (pcc *PooledClientConn) MarkUnhealthy()
MarkUnhealthy marks the client conn as unhealthy, so that the connection gets reset when closed