executor

package
v0.0.1-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2022 License: Apache-2.0 Imports: 8 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            int
	Workers              int
	MaxJobRetries        int
	BaseRetryDelay       time.Duration
	RetryJobAfterFailure bool
	PerWorkerQPS         int
	Timeout              time.Duration
}

type Executor

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

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

func New

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

New creates a new Executor with a queue size, number of workers, and a job-running or shutdown timeout.

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.

func (*Executor) Shutdown

func (e *Executor) Shutdown() bool

Shutdown stops workers.

type Job

type Job interface {
	Type() 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