gopool

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2019 License: MIT Imports: 5 Imported by: 0

README

gopool

go connection pool with channel

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrPoolClosed ...
	ErrPoolClosed = errors.New("pool closed")
)

Functions

This section is empty.

Types

type ChanPool

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

ChanPool ...

func NewChanPool

func NewChanPool(factory func(Pool) (Elem, error),
	maxActive, maxIdle int, heartTime, maxWait time.Duration) (cp *ChanPool)

NewChanPool ...

func (*ChanPool) Close

func (p *ChanPool) Close() error

Close ...

func (*ChanPool) Get

func (p *ChanPool) Get() (elem Elem, err error)

Get ...

func (*ChanPool) IsClosed

func (p *ChanPool) IsClosed() bool

IsClosed ...

func (*ChanPool) Len

func (p *ChanPool) Len() int

Len ...

func (*ChanPool) OutAllBefore

func (p *ChanPool) OutAllBefore(t time.Time)

OutAllBefore ...

func (*ChanPool) Put

func (p *ChanPool) Put(elem Elem) (err error)

Put ...

type Elem

type Elem interface {
	Out() error
	IsAlive() bool
	ElemBase
}

Elem ...

type ElemBase

type ElemBase interface {
	CreatedTime() time.Time
	SetInPool(bool)
	IsInPool() bool
}

ElemBase ...

func NewElemBase

func NewElemBase() ElemBase

NewElemBase ...

type Pool

type Pool interface {
	Get() (elem Elem, err error)
	Put(elem Elem) (err error)
	Len() int
	Close() error
	IsClosed() bool
	OutAllBefore(time.Time)
}

Pool ...

Jump to

Keyboard shortcuts

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