worker

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

type Builder interface {
	WithOptions(options *Options) Builder
	WithStop(func() error) Builder
	Build() Worker
}

func NewWorkerBuilder

func NewWorkerBuilder(name string, workerFn func(context.Context) error) Builder

type Options

type Options struct {
	Interval        time.Duration
	RunImmediately  bool
	RunConsequently bool
}

func DefaultOptions

func DefaultOptions(interval time.Duration) *Options

type Worker

type Worker interface {
	Name() string
	Start(ctx context.Context, wg *sync.WaitGroup)
}

Worker interface can be constructed using worker.NewBuilder("worker_name", workerFn).Build() or allows custom implementation (e.g. one-off jobs)

Jump to

Keyboard shortcuts

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