Documentation ¶
Overview ¶
Package connpool provide short connection and long connection pool.
Index ¶
- func SetReporter(r Reporter)
- type ConnWithPkgSize
- type ConnectionPoolType
- type DummyPool
- type DummyReporter
- func (dcm *DummyReporter) ConnFailed(poolType ConnectionPoolType, serviceName string, addr net.Addr)
- func (dcm *DummyReporter) ConnSucceed(poolType ConnectionPoolType, serviceName string, addr net.Addr)
- func (dcm *DummyReporter) ReuseSucceed(poolType ConnectionPoolType, serviceName string, addr net.Addr)
- type LongPool
- func (lp *LongPool) Clean(network, address string)
- func (lp *LongPool) Close() error
- func (lp *LongPool) Discard(conn net.Conn) error
- func (lp *LongPool) Dump() interface{}
- func (lp *LongPool) EnableReporter()
- func (lp *LongPool) Evict()
- func (lp *LongPool) Get(ctx context.Context, network, address string, opt remote.ConnOption) (net.Conn, error)
- func (lp *LongPool) Put(conn net.Conn) error
- func (lp *LongPool) Tick()
- func (lp *LongPool) WarmUp(eh warmup.ErrorHandling, wuo *warmup.PoolOption, co remote.ConnOption) error
- type PoolDump
- type Reporter
- type ShortPool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetReporter ¶
func SetReporter(r Reporter)
SetReporter set the common reporter of connection pool, that can only be set once.
Types ¶
type ConnWithPkgSize ¶
ConnWithPkgSize wraps a connection and records the bytes read or written through it.
func (*ConnWithPkgSize) Close ¶
func (c *ConnWithPkgSize) Close() error
Close implements the net.Conn interface.
type ConnectionPoolType ¶
type ConnectionPoolType int8
ConnectionPoolType is the type of connection pool.
const ( Short ConnectionPoolType = iota Long )
Short and Long flags define which indicates type of connection pool..
type DummyPool ¶
type DummyPool struct{}
DummyPool is a dummy implementation of remote.ConnPool.
func (*DummyPool) Close ¶
Close is to release resource of ConnPool, it is executed when client is closed.
type DummyReporter ¶
type DummyReporter struct{}
DummyReporter is a dummy implementation of Reporter.
func (*DummyReporter) ConnFailed ¶
func (dcm *DummyReporter) ConnFailed(poolType ConnectionPoolType, serviceName string, addr net.Addr)
ConnFailed implements the Reporter interface.
func (*DummyReporter) ConnSucceed ¶
func (dcm *DummyReporter) ConnSucceed(poolType ConnectionPoolType, serviceName string, addr net.Addr)
ConnSucceed implements the Reporter interface.
func (*DummyReporter) ReuseSucceed ¶
func (dcm *DummyReporter) ReuseSucceed(poolType ConnectionPoolType, serviceName string, addr net.Addr)
ReuseSucceed implements the Reporter interface.
type LongPool ¶
type LongPool struct {
// contains filtered or unexported fields
}
LongPool manages a pool of long connections.
func NewLongPool ¶
func NewLongPool(serviceName string, idlConfig connpool.IdleConfig) *LongPool
NewLongPool creates a long pool using the given IdleConfig.
func (*LongPool) Close ¶
Close releases all peers in the pool, it is executed when client is closed.
func (*LongPool) Dump ¶
func (lp *LongPool) Dump() interface{}
Dump is used to dump current long pool info when needed, like debug query.
func (*LongPool) EnableReporter ¶
func (lp *LongPool) EnableReporter()
EnableReporter enable reporter for long connection pool.
func (*LongPool) Evict ¶ added in v0.4.3
func (lp *LongPool) Evict()
Evict cleanups the idle connections in peers.
func (*LongPool) Get ¶
func (lp *LongPool) Get(ctx context.Context, network, address string, opt remote.ConnOption) (net.Conn, error)
Get pick or generate a net.Conn and return The context is not used but leave it for now.
func (*LongPool) Tick ¶ added in v0.5.0
func (lp *LongPool) Tick()
Tick implements the interface utils.TickerTask.
func (*LongPool) WarmUp ¶ added in v0.3.0
func (lp *LongPool) WarmUp(eh warmup.ErrorHandling, wuo *warmup.PoolOption, co remote.ConnOption) error
WarmUp implements the warmup.Pool interface.
type Reporter ¶
type Reporter interface { ConnSucceed(poolType ConnectionPoolType, serviceName string, addr net.Addr) ConnFailed(poolType ConnectionPoolType, serviceName string, addr net.Addr) ReuseSucceed(poolType ConnectionPoolType, serviceName string, addr net.Addr) }
Reporter report status of connection pool.
func GetCommonReporter ¶ added in v0.3.0
func GetCommonReporter() Reporter
GetCommonReporter returns the current Reporter used by connection pools.
type ShortPool ¶
type ShortPool struct {
// contains filtered or unexported fields
}
ShortPool is the conn pool for short connections.
func NewShortPool ¶
NewShortPool timeout is connection timeout.
func (*ShortPool) Close ¶
Close is to release resource of ConnPool, it is executed when client is closed. ShortPool do nothing
func (*ShortPool) EnableReporter ¶
func (p *ShortPool) EnableReporter()
EnableReporter enable reporter for short connection pool.