conn_pool

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2019 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidConfig  = errors.New("invalid pool config")
	ErrPoolClosed     = errors.New("pool closed")
	ErrGetConnTimeout = errors.New("get conn timeout")
	ErrConnFactory    = errors.New("ConnFactory error")
)

Functions

This section is empty.

Types

type ConnFactory

type ConnFactory func() (io.Closer, error)

type ErrorHandler

type ErrorHandler func(err error)

type Option

type Option interface {
	// contains filtered or unexported methods
}

type OptionConnMaxAliveTime

type OptionConnMaxAliveTime time.Duration

连接最大存活时间

type OptionGetConnWaitDeadline

type OptionGetConnWaitDeadline time.Duration

获取连接最大等待时间

type OptionMaxOpen

type OptionMaxOpen int

池中最大资源数

type OptionMinOpen

type OptionMinOpen int

池中最少资源数

type Pool

type Pool struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewPool

func NewPool(factory ConnFactory, errorHandler ErrorHandler, options ...Option) (*Pool, error)

func (*Pool) Acquire

func (p *Pool) Acquire() (io.Closer, error)

func (*Pool) Close

func (p *Pool) Close(closer io.Closer)

func (*Pool) Release

func (p *Pool) Release(closer io.Closer, err error)

释放单个资源到连接池

func (*Pool) Shutdown

func (p *Pool) Shutdown() error

关闭连接池,释放所有资源

Jump to

Keyboard shortcuts

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