static_pool

package
v4.7.2 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 16 Imported by: 14

Documentation

Index

Constants

View Source
const (
	MB = 1024 * 1024

	// NsecInSec nanoseconds in second
	NsecInSec int64 = 1000000000
)
View Source
const (
	// StopRequest can be sent by worker to indicate that restart is required.
	StopRequest = `{"stop":true}`
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options func(p *Pool)

func WithLogger

func WithLogger(z *zap.Logger) Options

func WithQueueSize added in v4.6.0

func WithQueueSize(l uint64) Options

type PExec added in v4.4.0

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

func (*PExec) Body added in v4.4.0

func (p *PExec) Body() []byte

func (*PExec) Context added in v4.4.0

func (p *PExec) Context() []byte

func (*PExec) Error added in v4.4.0

func (p *PExec) Error() error

func (*PExec) Payload added in v4.4.0

func (p *PExec) Payload() *payload.Payload

type Pool

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

Pool controls worker creation, destruction and task routing. Pool uses fixed amount of stack.

func NewPool

func NewPool(ctx context.Context, cmd pool.Command, factory pool.Factory, cfg *pool.Config, log *zap.Logger, options ...Options) (*Pool, error)

NewPool creates a new worker pool and task multiplexer. Pool will initiate with one worker. If supervisor configuration is provided -> pool will be turned into a supervisedExec mode

func (*Pool) AddWorker added in v4.5.0

func (sp *Pool) AddWorker() error

func (*Pool) Destroy

func (sp *Pool) Destroy(ctx context.Context)

Destroy all underlying stack (but let them complete the task).

func (*Pool) Exec

func (sp *Pool) Exec(ctx context.Context, p *payload.Payload, stopCh chan struct{}) (chan *PExec, error)

Exec executes provided payload on the worker

func (*Pool) GetConfig

func (sp *Pool) GetConfig() *pool.Config

GetConfig returns associated pool configuration. Immutable.

func (*Pool) QueueSize

func (sp *Pool) QueueSize() uint64

func (*Pool) RemoveWorker

func (sp *Pool) RemoveWorker(ctx context.Context) error

func (*Pool) Reset

func (sp *Pool) Reset(ctx context.Context) error

func (*Pool) Start

func (sp *Pool) Start()

func (*Pool) Stop

func (sp *Pool) Stop()

func (*Pool) Workers

func (sp *Pool) Workers() (workers []*worker.Process)

Workers returns worker list associated with the pool.

Jump to

Keyboard shortcuts

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