genpool

package
v0.0.0-...-2ec961a Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidConfig = errors.New("invalid pool config")
	ErrPoolClosed    = errors.New("pool closed")
)

Functions

This section is empty.

Types

type GenericPool

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

func NewGenericPool

func NewGenericPool(minOpen, maxOpen int, maxLifetime time.Duration, factory factory) (*GenericPool, error)

func (*GenericPool) Acquire

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

func (*GenericPool) Close

func (p *GenericPool) Close(closer io.Closer) error

关闭单个资源

func (*GenericPool) Release

func (p *GenericPool) Release(closer io.Closer) error

释放单个资源到连接池

func (*GenericPool) Shutdown

func (p *GenericPool) Shutdown() error

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

type Pool

type Pool interface {
	Acquire() (io.Closer, error) // 获取资源
	Release(io.Closer) error     // 释放资源
	Close(io.Closer) error       // 关闭资源
	Shutdown() error             // 关闭池
}

Jump to

Keyboard shortcuts

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