worker

package
v1.0.1050-8d28a3e Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrShouldBackoff = errors.New("should back off")

Functions

func Run

func Run(ctx context.Context, cfg Config)

Run a worker, which calls WorkFunc in a loop. Run exits when the context is cancelled.

Types

type Config

type Config struct {
	Name          string
	NoWorkBackOff backoff.BackOff
	MaxWorkTime   time.Duration
	// WorkFunc should return ErrShouldBackoff if it wants to back off, or set BackoffOnAllErrors
	WorkFunc func(ctx context.Context) error
	// If backoff is desired for any returned error
	BackoffOnAllErrors bool
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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