pool

package
v1.8.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 21, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//ErrClosed 连接池已经关闭Error
	ErrClosed = errors.New("pool is closed")
)

Functions

This section is empty.

Types

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

type Pool

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

	Put(interface{}) error

	Close(interface{}) error

	CloseAll()

	Len() int
}

Pool 基本方法

func NewChannelPool

func NewChannelPool(poolConfig *PoolConfig) (Pool, error)

NewChannelPool 初始化连接

type PoolConfig

type PoolConfig struct {
	//是否初始化连接池
	// IsInit bool
	//最大链接数
	MaxOpenConns int
	//最大闲置链接
	MaxIdleConns int
	//生成连接的方法
	New func() (interface{}, error)
	//关闭连接的方法
	Close func(interface{}) error
	//检查连接是否有效的方法
	Ping func(interface{}) error
	//连接最大空闲时间,超过该事件则将失效
	ConnTimeout time.Duration
	//配置参数
	Config interface{}
}

PoolConfig 连接池相关配置

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL