pool: github.com/silenceper/pool Index | Files | Directories

package pool

import "github.com/silenceper/pool"

Index

Package Files

channel.go pool.go

Variables

❖
var (
    //ErrClosed 连接池已经关闭Error
    ErrClosed = errors.New("pool is closed")
)
❖
var (
    //ErrMaxActiveConnReached 连接池超限
    ErrMaxActiveConnReached = errors.New("MaxActiveConnReached")
)

type Config Uses

❖
type Config struct {
    //连接池中拥有的最小连接数
    InitialCap int
    //最大并发存活连接数
    MaxCap int
    //最大空闲连接
    MaxIdle int
    //生成连接的方法
    Factory func() (interface{}, error)
    //关闭连接的方法
    Close func(interface{}) error
    //检查连接是否有效的方法
    Ping func(interface{}) error
    //连接最大空闲时间,超过该事件则将失效
    IdleTimeout time.Duration
}

Config 连接池相关配置

type Pool Uses

❖
type Pool interface {
    Get() (interface{}, error)

    Put(interface{}) error

    Close(interface{}) error

    Release()

    Len() int
}

Pool 基本方法

func NewChannelPool Uses

❖
func NewChannelPool(poolConfig *Config) (Pool, error)

NewChannelPool 初始化连接

Directories

PathSynopsis
example

Package pool imports 5 packages (graph) and is imported by 4 packages. Updated 2020-10-15. Refresh now. Tools for package owners.