Documentation ¶
Index ¶
- Constants
- Variables
- type Initializer
- type ObjectFactory
- type ObjectPool
- type PoolConfig
- type PriorityQeueu
- type ResourceHolder
- type SimpleObjectPool
- 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
Constants ¶
View Source
const (
CheckIdleInterval = 2 * time.Minute
)
View Source
const DefaultCapacity = 50
View Source
const DefaultMaxIdle = 20
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Initializer ¶
type Initializer func(holder ResourceHolder) error
type ObjectFactory ¶
type ObjectFactory interface { Create() (types.NetworkResource, error) Dispose(types.NetworkResource) error }
type ObjectPool ¶
type ObjectPool interface { Acquire(ctx context.Context, resid string) (types.NetworkResource, error) ReleaseWithReverse(resId string, reverse time.Duration) error Release(resId string) error AcquireAny(ctx context.Context) (types.NetworkResource, error) Stat(resId string) error }
func NewSimpleObjectPool ¶
func NewSimpleObjectPool(cfg PoolConfig) (ObjectPool, error)
type PoolConfig ¶
type PoolConfig struct { Factory ObjectFactory Initializer Initializer MinIdle int MaxIdle int Capacity int }
type PriorityQeueu ¶
type PriorityQeueu struct {
// contains filtered or unexported fields
}
func NewPriorityQueue ¶
func NewPriorityQueue() *PriorityQeueu
func (*PriorityQeueu) Find ¶
func (q *PriorityQeueu) Find(id string) *poolItem
func (*PriorityQeueu) Peek ¶
func (q *PriorityQeueu) Peek() *poolItem
func (*PriorityQeueu) Pop ¶
func (q *PriorityQeueu) Pop() *poolItem
func (*PriorityQeueu) Push ¶
func (q *PriorityQeueu) Push(item *poolItem)
func (*PriorityQeueu) Rob ¶
func (q *PriorityQeueu) Rob(id string) *poolItem
func (*PriorityQeueu) Size ¶
func (q *PriorityQeueu) Size() int
type ResourceHolder ¶
type ResourceHolder interface { AddIdle(resource types.NetworkResource) AddInuse(resource types.NetworkResource) }
type SimpleObjectPool ¶
type SimpleObjectPool struct {
// contains filtered or unexported fields
}
func (*SimpleObjectPool) Acquire ¶
func (p *SimpleObjectPool) Acquire(ctx context.Context, resId string) (types.NetworkResource, error)
func (*SimpleObjectPool) AcquireAny ¶
func (p *SimpleObjectPool) AcquireAny(ctx context.Context) (types.NetworkResource, error)
func (*SimpleObjectPool) AddIdle ¶
func (p *SimpleObjectPool) AddIdle(resource types.NetworkResource)
func (*SimpleObjectPool) AddInuse ¶
func (p *SimpleObjectPool) AddInuse(res types.NetworkResource)
func (*SimpleObjectPool) Release ¶
func (p *SimpleObjectPool) Release(resId string) error
func (*SimpleObjectPool) ReleaseWithReverse ¶
func (p *SimpleObjectPool) ReleaseWithReverse(resId string, reverse time.Duration) error
func (*SimpleObjectPool) Stat ¶
func (p *SimpleObjectPool) Stat(resId string) error
Click to show internal directories.
Click to hide internal directories.