Documentation
¶
Overview ¶
Package clientpool provides implementations of a generic client pool.
The channel implementation has roughly 300ns overhead on Get/Release pair calls:
$ go test -bench . -benchmem goos: darwin goarch: amd64 pkg: github.com/reddit/baseplate.go/clientpool BenchmarkPoolGetRelease/channel-8 3993308 278 ns/op 0 B/op 0 allocs/op PASS ok github.com/reddit/baseplate.go/clientpool 2.495s
This package is considered low level and should not be used directly in most cases. A thrift-specific wrapping is available in thriftbp package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrExhausted = exhaustedError{}
ErrExhausted is the error returned by Get when the pool is exhausted.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client is a minimal interface for a client needed by the pool.
TTransport interface in thrift satisfies Client interface, so embedding the TTransport used by the actual client is a common way to implement the ClientOpener for thrift Clients.
type ClientOpener ¶
ClientOpener defines a generator for clients.
type ConfigError ¶
ConfigError is the error type returned when trying to open a new client pool, but the configuration values passed in won't work.
func (*ConfigError) Error ¶
func (e *ConfigError) Error() string
type Pool ¶
type Pool interface {
io.Closer
Get() (Client, error)
Release(c Client) error
NumActiveClients() int32
NumAllocated() int32
IsExhausted() bool
}
Pool defines the client pool interface.
func NewChannelPool ¶
func NewChannelPool(ctx context.Context, requiredInitialClients, bestEffortInitialClients, maxClients int, opener ClientOpener) (_ Pool, err error)
NewChannelPool creates a new client pool implemented via channel.