rpcpool

package
v0.27.1-rc-crdb Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2019 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Error = errs.Class("rpcpool")

Error is the class of errors returned by this package.

Functions

This section is empty.

Types

type Conn

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

Conn implements drpc.Conn but keeps a pool of connections open.

func New

func New(cap int, dial Dialer) *Conn

New returns a new Conn that will keep cap connections open using the provided dialer when it needs new ones.

func (*Conn) Close

func (c *Conn) Close() (err error)

Close closes all of the pool's connections and ensures no new ones will be made.

func (*Conn) Invoke

func (c *Conn) Invoke(ctx context.Context, rpc string, in drpc.Message, out drpc.Message) (err error)

Invoke implements drpc.Conn's Invoke method using a pooled connection.

func (*Conn) NewStream

func (c *Conn) NewStream(ctx context.Context, rpc string) (_ drpc.Stream, err error)

NewStream implements drpc.Conn's NewStream method using a pooled connection. It waits for the stream to be finished before replacing the connection into the pool.

func (*Conn) Put

func (c *Conn) Put(conn *drpcconn.Conn) error

Put places the connection back into the pool if there's room. It closes the connection if there is no room or the pool is closed. If the connection is closed, it does not attempt to place it into the pool.

func (*Conn) Transport

func (c *Conn) Transport() drpc.Transport

Transport returns nil because there is no well defined transport to use.

type Dialer

type Dialer = func(context.Context) (drpc.Transport, error)

Dialer is the type of function to create a new connection.

Jump to

Keyboard shortcuts

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