executor

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// QueueSize is the maximum number of jobs in the executor queue.
	QueueSize int
	// Workers is the number of workers that are concurrently executing jobs.
	Workers int
	// MaxJobRetries is the maximum number of retries if a job fails. This should
	// not be zero. If you want to disable retries, just disable RetryJobAfterFailure.
	MaxJobRetries int
	// BaseRetryDelay defines how long after a job fails before it is re-queued.
	BaseRetryDelay time.Duration
	// RetryJobAfterFailure allows the job to be re-queued if it fails.
	RetryJobAfterFailure bool
	// PerWorkerQPS is the max QPS of a worker before it is rate-limited. With Workers,
	// Workers*PerWorkerQPS is the overall QPS limit of the entire executor.
	PerWorkerQPS int
	// Timeout defines how long a single job is allowed to run and how long the
	// entire executor should wait for all the jobs to stop when shutting down.
	Timeout time.Duration
}

Config is the config for the Executor.

type Executor

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

Executor is a rate-limited job queue with concurrent workers.

func New

func New(c Config) (*Executor, error)

New creates a new Executor with user-provided Config.

func (*Executor) AddJob

func (e *Executor) AddJob(j Job) error

AddJob adds a job to the queue.

func (*Executor) RunJobs

func (e *Executor) RunJobs(ctx context.Context)

RunJobs starts workers.

type Job

type Job interface {
	Type() string
	ID() string
	Run(ctx context.Context) error
	AllowConcurrency() bool
}

Job is an Action to be executed by the workers in the Executor.

Jump to

Keyboard shortcuts

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