pool

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPoolIsFull   = errors.New("vex: pool is full")
	ErrPoolIsClosed = errors.New("vex: pool is closed")
)

Functions

This section is empty.

Types

type DialFunc

type DialFunc func() (vex.Client, error)

DialFunc is a function dials to somewhere and returns a client and error if failed.

func Dial

func Dial(address string, opts ...vex.Option) DialFunc

Dial returns a function which dials to address with opts. It's a convenient way used in creating a pool.

type Option

type Option func(conf *config)

func WithFastFailed added in v0.4.3

func WithFastFailed() Option

WithFastFailed sets fastFailed to config.

func WithLimit added in v0.4.3

func WithLimit(limit uint64) Option

WithLimit sets limit to config.

func (Option) ApplyTo

func (o Option) ApplyTo(conf *config)

type Pool

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

func New

func New(dial DialFunc, opts ...Option) *Pool

func (*Pool) Close

func (p *Pool) Close() error

Close closes pool and releases all resources.

func (*Pool) Get

func (p *Pool) Get(ctx context.Context) (vex.Client, error)

func (*Pool) Status

func (p *Pool) Status() Status

Status returns the status of the pool.

type Status

type Status struct {
	// Limit is the limit of connected clients.
	Limit uint64 `json:"limit"`

	// Connected is the count of connected clients.
	Connected uint64 `json:"connected"`

	// Idle is the count of idle clients.
	Idle uint64 `json:"idle"`

	// Waiting is the count of waiting for a client.
	Waiting uint64 `json:"waiting"`
}

Jump to

Keyboard shortcuts

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