pool

package
v0.0.0-...-cda2eac Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: GPL-3.0 Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPoolClosed     = errcode.New("pool is closed")
	ErrNilFactory     = errcode.New("nil factory")
	ErrOpenedMaxConns = errcode.New("opened the maximum conns")
	ErrNilCloseFunc   = errcode.New("nil close function")
	ErrNilConnection  = errcode.New("nil connection")
	ErrGetConnTimeout = errcode.New("timeout to get connection")
)

Functions

This section is empty.

Types

type Executor

type Executor func(interface{}) error

type Factory

type Factory func() (interface{}, error)

type Option

type Option func(*Options)

func IdleTimeout

func IdleTimeout(idle time.Duration) Option

func InitialCap

func InitialCap(cap int) Option

func MaxCap

func MaxCap(cap int) Option

func MaxIdle

func MaxIdle(idle int) Option

func OptionClose

func OptionClose(f Executor) Option

func OptionFactory

func OptionFactory(f Factory) Option

func OptionPing

func OptionPing(f Executor) Option

type Options

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

type Pool

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

	Put(interface{}) error

	Close(interface{}) error

	Release()

	Len() int
}

Pool interface describes a pool implementation. A pool should have maximum capacity. An ideal pool is threadsafe and easy to use.

func NewPool

func NewPool(opts ...Option) (Pool, error)

Jump to

Keyboard shortcuts

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