pool

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2017 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

type Pool struct {
	// contains filtered or unexported fields
}

Pool stores a pool of grpc connections to, it's useful in places where you would otherwise need to create several connections.

func NewPool

func NewPool(kubeClient *kube.Client, namespace string, serviceName string, numWorkers int, opts ...grpc.DialOption) (*Pool, error)

NewPool creates a new connection pool with connections to pods in the given service.

func (*Pool) Close

func (p *Pool) Close() error

Close closes all connections stored in the pool, it returns an error if any of the calls to Close error.

func (*Pool) Get

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

Get returns a new connection, unlike sync.Pool if it has a cached connection it will always return it. Otherwise it will create a new one. Get errors only when it needs to Dial a new connection and that process fails.

func (*Pool) Put

func (p *Pool) Put(conn *grpc.ClientConn) error

Put returns the connection to the pool. If there are more than `size` connections already cached in the pool the connection will be closed. Put errors only when it Closes a connection and that call errors.

Jump to

Keyboard shortcuts

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