Documentation ¶
Index ¶
Constants ¶
const (
DefaultClaimTimeout = 10 * time.Minute
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Size: while active, the pool will attempt to maintain at these many // connections. Size int // ClaimTimeout: connections will be removed from pool if unclaimed for // longer than ClaimTimeout. The default ClaimTimeout is 10 minutes. Once // connections have been removed from the Pool, they won't be replaced until // another connection is requested, at which point the pool will fill again. ClaimTimeout time.Duration // Dial: specifies the function used to create new connections Dial DialFunc }
Config contains configuration information for a Pool.
type Pool ¶
type Pool interface { // Get gets a connection from the pool, or dials a new one if none are // available. Get() (net.Conn, error) // Close stops the goroutines that are filling the pool, blocking until // they've all terminated. Close() }
Pool is a pool of connections, built from a Config using the New method. The purpose of connpool is to accelerate bursty clients, that is to say clients that tend to do a lot of dialing in rapid succeession. At steady state, the pool is usually empty, but once activity is detected it starts to fill itself up and keeps itself filled as long as activity continues.
Connections are pooled lazily up to Size and expire after ClaimTimeout. Lazily here means that the Pool won't start to fill until the first request for a connection. As long as the Pool is actively being used, it will attempt to always have Size number of connections ready to use.