Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrCanNotGetItem return when get item failed ErrCanNotGetItem = errors.New("Unable GET Item") // ErrTypeConvert return when Convert item to require type ErrTypeConvert = errors.New("Class Cast Failed") // ErrItemInitialFailed return when Initial item failed ErrItemInitialFailed = errors.New("Iem Initial Failed") // ErrPoolExtendFailed return when Initial pool failed ErrPoolExtendFailed = errors.New("Pool Extend Failed") // ErrHasBeenShotdown return when do something after pool has been shutdown ErrHasBeenShotdown = errors.New("Pool has been shutdown") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
//InitialPoolSize initial pool size. Default: 5
InitialPoolSize int
//MinPoolSize min item in pool. Default: 2
MinPoolSize int
//MaxPoolSize max item in pool. Default: 15
MaxPoolSize int
//AcquireRetryAttempts retry times when get item Failed. Default: 5
AcquireRetryAttempts int
//AcquireIncrement create item count when pool is empty. Default: 5
AcquireIncrement int
//TestDuration interval time between check item avaiable.Unit:Millisecond Default: 1000
TestDuration int
//TestOnGetItem test avaiable when get item. Default: false
TestOnGetItem bool
//Params item initial params
Params map[string]string
}
Config pool config
type Item ¶
type Item interface {
Initial(map[string]string) error
Destory(map[string]string) error
Check(map[string]string) error
}
Item pool item
type Pool ¶
type Pool struct {
Config Config
// contains filtered or unexported fields
}
Pool pool class
func DefaultPool ¶
DefaultPool create a pool with default config
Click to show internal directories.
Click to hide internal directories.