pool

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: MIT Imports: 6 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DefaultPoolSize   = 8  // DefaultPoolSize is the default size of the pool.
	DefaultBufferSize = 64 // DefaultBufferSize is the default size of the work channel buffer.
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

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

Pool is a congigurable collection of Probes that run functions on available goroutines.

func NewPool

func NewPool(cfg *PoolConfig) *Pool

NewPool initializes and returns a new Pool.

func (*Pool) Idle

func (p *Pool) Idle() int

Idle returns the number of idle Probes in the Pool.

func (*Pool) Run

func (p *Pool) Run(r probe.Runner)

Run executes a probe.Runner on a Probe in the Pool.

func (*Pool) Running

func (p *Pool) Running() int

Running returns the number of running Probes in the Pool.

func (*Pool) Start

func (p *Pool) Start()

Start starts the Pool.

func (*Pool) Stop

func (p *Pool) Stop(wait bool)

Stop stops the Pool.

type PoolConfig

type PoolConfig struct {
	LogHandler slog.Handler    // Handler to use for pool logging. If empty, probe.NoopHandler will be used.
	Ctx        context.Context // Context to use for the pool. If empty, context.Background will be used.
	Size       int             // Size of the pool. Default pool size is 8.
	BufferSize int             // Size of the work channel buffer. Default buffer size is 64.
}

PoolConfig is a struct for passing configuration data to a new Pool.

Jump to

Keyboard shortcuts

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