Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LimitedConnPool ¶
type LimitedConnPool struct {
// contains filtered or unexported fields
}
A LimitedConnPool is a connection pool, with the property that the total number of live connections is limited to the size parameter passed to NewLimited. In order to make this guarantee, we assume that all new connections are introduced by calls to the Get method, and returned to the pool by calls to Close().
func NewLimited ¶
func NewLimited(size int, dial func() (io.WriteCloser, error)) (*LimitedConnPool, error)
NewLimited returns a new LimitedConnPool with the given size limit and dial function.
func (*LimitedConnPool) Close ¶
func (p *LimitedConnPool) Close()
func (*LimitedConnPool) Errors ¶
func (p *LimitedConnPool) Errors() <-chan error
Errors returns a channel of errors encountered when dialing new connections. Errors will be dropped if this channel is not consumed.
func (*LimitedConnPool) Get ¶
func (p *LimitedConnPool) Get() io.WriteCloser
Get retrieves a connection from the pool, if available. A new connection will only be dialed if the total number of live connections is below the configured size limit. Closing the returned io.WriteCloser automatically returns the connection to the pool.