workqueue

package
v0.0.0-...-4d08361 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotStarted = errors.New("workqueue not started")

Functions

This section is empty.

Types

type Job

type Job func(context.Context) error

type JobOption

type JobOption func(*item)

func WithJobName

func WithJobName(name string) JobOption

WithJobName sets the name of the job.

type Option

type Option func(*WorkQueue)

func WithGracefulShutdown

func WithGracefulShutdown(gracePeriod time.Duration) Option

func WithInitialDelay

func WithInitialDelay(delay time.Duration) Option

WithInitialDelay sets the initial exponential backoff delay of the workqueue.

func WithName

func WithName(name string) Option

WithName sets the name of the workqueue.

type WorkQueue

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

func NewWorkQueue

func NewWorkQueue(opts ...Option) *WorkQueue

func (*WorkQueue) Add

func (w *WorkQueue) Add(job Job, opts ...JobOption) error

Add adds a job to the workqueue.

func (*WorkQueue) Run

func (w *WorkQueue) Run(ctx context.Context) error

Run starts the workqueue which processes jobs and retries them on failure with exponential backoff.

func (*WorkQueue) Shutdown

func (w *WorkQueue) Shutdown()

Shutdown stops the workqueue.

func (*WorkQueue) Started

func (w *WorkQueue) Started() bool

Started returns true if the workqueue is started.

Jump to

Keyboard shortcuts

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