pool

package
v0.0.0-...-e120ae1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2023 License: Apache-2.0 Imports: 18 Imported by: 13

Documentation

Overview

Package pool provides specific implementations of the amboy.Runner interface that serve as the worker pools for jobs in work queues.

Intentionally, most of the important logic about job execution and dispatching happens in the Queue implementation, and the Runner implementations are simplistic.

Rate Limiting Pools Amboy includes a rate limiting pool to control the flow of jobs processed by the queue. The averaged pool uses an exponential weighted moving average and a targeted number of jobs to complete over an interval to achieve a reasonable flow of jobs through the runner.

Local Workers Pool

The LocalWorkers is a simple worker pool implementation that spawns a collection of (n) workers and dispatches jobs to worker threads, that consume work items from the Queue's Next() method.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAbortablePool

func NewAbortablePool(size int, q amboy.Queue) amboy.AbortableRunner

NewAbortablePool produces a simple implementation of a worker pool that provides access to cancel running jobs. The cancellation functions work by creating context cancelation function and then canceling the contexts passed to the jobs specifically.

func NewLocalWorkers

func NewLocalWorkers(numWorkers int, q amboy.Queue) amboy.Runner

NewLocalWorkers is a constructor for pool of worker processes that execute jobs from a queue locally, and takes arguments for the number of worker processes and a amboy.Queue object.

func NewMovingAverageRateLimitedWorkers

func NewMovingAverageRateLimitedWorkers(size, targetNum int, period time.Duration, q amboy.Queue) (amboy.AbortableRunner, error)

NewMovingAverageRateLimitedWorkers returns a worker pool implementation that attempts to run a target number of jobs over a specified period to provide a more stable dispatching rate. It uses an exponentially weighted average of job time when determining the rate, which favors recent jobs over previous jobs.

Returns an error if the size or target numbers are less than one and if the period is less than a millisecond.

func NewNoop

func NewNoop() amboy.Runner

NewNoop creates a runner implementation that has no workers, but satisfies the workers and semantics of the Runner interface to support queues deployments that have insert only queues.

Types

This section is empty.

Jump to

Keyboard shortcuts

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