pool

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChannelPool

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

ChannelPool store connection information

func NewPool

func NewPool(poolConfig *conf.PoolConfig, voiceFactory func() IComputation, logger logging.ILogger) (*ChannelPool, error)

NewPool new 1 pool

func (*ChannelPool) ApplyLen

func (c *ChannelPool) ApplyLen() int

ApplyLen The number of connection that can be applied for.

func (*ChannelPool) Close

func (c *ChannelPool) Close(conn IComputation) error

Close close single connection

func (*ChannelPool) Get

func (c *ChannelPool) Get() (IComputation, error)

Get get a connection from pool

func (*ChannelPool) GetConns

func (c *ChannelPool) GetConns() chan *IdleConn

GetConns get all connection

func (*ChannelPool) Len

func (c *ChannelPool) Len() int

Len existing connections in the connection pool

func (*ChannelPool) Put

func (c *ChannelPool) Put(conn IComputation) error

Put put the connection back into the pool

func (*ChannelPool) Release

func (c *ChannelPool) Release() error

Release releasef all connection in ther connection pool

type ComputationPool

type ComputationPool struct {
	ObjectPool *ChannelPool
	WorkerTask func(taskType, taskData string) (string, error)
	// contains filtered or unexported fields
}

ComputationPool define computation pool

func InitComputationPool

func InitComputationPool(poolConfig *conf.PoolConfig, computationFactory func() IComputation, initFunc func() error, logger logging.ILogger) (*ComputationPool, error)

InitComputationPool init computation pool

func (*ComputationPool) Destroy

func (p *ComputationPool) Destroy() error

Destroy -

func (*ComputationPool) Get

func (p *ComputationPool) Get() (IComputation, error)

Get -

func (*ComputationPool) Process

func (p *ComputationPool) Process(taskType, taskData string) (string, error)

Process -

func (*ComputationPool) Release

func (p *ComputationPool) Release(computation IComputation) error

Release -

type IComputation

type IComputation interface {
	InitWorker(id uint32) error
	GetID() uint32
	OnIdle()
	OnBusy()
	Release() error
}

IComputation computation interface

type IdleConn

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

IdleConn idle connection

Jump to

Keyboard shortcuts

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