Versions in this module Expand all Collapse all v1 v1.0.10 Mar 20, 2019 Changes in this version + const CheckIdleInterval + const DefaultCapacity + const DefaultMaxIdle + var ErrContextDone = errors.New("context done") + var ErrInvalidArguments = errors.New("invalid arguments") + var ErrInvalidState = errors.New("invalid state") + var ErrNoAvailableResource = errors.New("no available resource") + var ErrNotFound = errors.New("not found") + type Initializer func(holder ResourceHolder) error + type ObjectFactory interface + Create func() (types.NetworkResource, error) + Dispose func(types.NetworkResource) error + type ObjectPool interface + Acquire func(ctx context.Context, resid string) (types.NetworkResource, error) + AcquireAny func(ctx context.Context) (types.NetworkResource, error) + Release func(resId string) error + ReleaseWithReverse func(resId string, reverse time.Duration) error + Stat func(resId string) error + func NewSimpleObjectPool(cfg PoolConfig) (ObjectPool, error) + type PoolConfig struct + Capacity int + Factory ObjectFactory + Initializer Initializer + MaxIdle int + MinIdle int + type PriorityQeueu struct + func NewPriorityQueue() *PriorityQeueu + func (q *PriorityQeueu) Find(id string) *poolItem + func (q *PriorityQeueu) Peek() *poolItem + func (q *PriorityQeueu) Pop() *poolItem + func (q *PriorityQeueu) Push(item *poolItem) + func (q *PriorityQeueu) Rob(id string) *poolItem + func (q *PriorityQeueu) Size() int + type ResourceHolder interface + AddIdle func(resource types.NetworkResource) + AddInuse func(resource types.NetworkResource) + type SimpleObjectPool struct + func (p *SimpleObjectPool) Acquire(ctx context.Context, resId string) (types.NetworkResource, error) + func (p *SimpleObjectPool) AcquireAny(ctx context.Context) (types.NetworkResource, error) + func (p *SimpleObjectPool) AddIdle(resource types.NetworkResource) + func (p *SimpleObjectPool) AddInuse(res types.NetworkResource) + func (p *SimpleObjectPool) Release(resId string) error + func (p *SimpleObjectPool) ReleaseWithReverse(resId string, reverse time.Duration) error + func (p *SimpleObjectPool) Stat(resId string) error