Documentation ¶
Index ¶
- Variables
- type Conn
- func (c *Conn) Close() (err error)
- func (c *Conn) Invoke(ctx context.Context, rpc string, in drpc.Message, out drpc.Message) (err error)
- func (c *Conn) NewStream(ctx context.Context, rpc string) (_ drpc.Stream, err error)
- func (c *Conn) Put(conn *drpcconn.Conn) error
- func (c *Conn) Transport() drpc.Transport
- type Dialer
- type Options
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 ¶
New returns a new Conn that will keep cap connections open using the provided dialer when it needs new ones.
func (*Conn) Close ¶
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 ¶
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.
type Options ¶ added in v0.28.0
type Options struct { // Capacity is how many connections to keep open. Capacity int // IdleExpiration is how long a connection in the pool is allowed to be // kept idle. If zero, connections do not expire. IdleExpiration time.Duration }
Options controls the options for a connection pool.
Click to show internal directories.
Click to hide internal directories.