grpcpool: Index | Files

package grpcpool

import ""


Package Files

client.go pool.go queue.go


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 Uses

type ClientConn struct {
    // contains filtered or unexported fields

ClientConn is the basic unit in the pool

func (*ClientConn) Put Uses

func (client *ClientConn) Put()

Put return the ClientConn when client call finish

type Factory Uses

type Factory func() (*grpc.ClientConn, error)

Factory function type to create a new gRPC client

type Options Uses

type Options struct {
    Factory         Factory
    PoolSize        int
    MinIdleConns    int
    UsedPreConn     int
    MaxConnLifeTime time.Duration
    IdleTimeout     time.Duration

Options Pool Options defined

type Pool Uses

type Pool struct {
    // contains filtered or unexported fields

Pool struct defined

func New Uses

func New(factory Factory, minIdleConns, poolSize, usedPreConn int, idleTimeout, maxLifetime time.Duration) (*Pool, error)

New create and init a new gRPC pool

func (*Pool) Close Uses

func (p *Pool) Close()

Close the pool and release resources

func (*Pool) CloseClient Uses

func (p *Pool) CloseClient(client *ClientConn) error

CloseClient will remove the client And close it

func (*Pool) Get Uses

func (p *Pool) Get(ctx context.Context) (*ClientConn, error)

Get an Available client to use

func (*Pool) Print Uses

func (p *Pool) Print() []byte

Print the pool to monitor Usage

Package grpcpool imports 8 packages (graph). Updated 2019-08-14. Refresh now. Tools for package owners.