worker

package
v0.0.0-...-d62e3dc Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAlreadyStarted = errors.New("already started")
	ErrNoOnWorking    = errors.New("no onWorking")
)

Functions

This section is empty.

Types

type OptionFunc

type OptionFunc func(w *Worker)

func WithContext

func WithContext(ctx context.Context, cancelFunc context.CancelFunc) OptionFunc

func WithOnError

func WithOnError(onError func(p any) (err error)) OptionFunc

func WithOnStarted

func WithOnStarted(onStarted func()) OptionFunc

func WithOnStop

func WithOnStop(onStopping func()) OptionFunc

func WithOnWorking

func WithOnWorking(onWorking func(ctx context.Context) bool) OptionFunc

func WithStartWaiter

func WithStartWaiter(startWaiter *sync.WaitGroup) OptionFunc

func WithStopWaiter

func WithStopWaiter(stopWaiter *sync.WaitGroup) OptionFunc

type Worker

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

func Create

func Create(startFunc func() error, wait bool, optionFuncs ...OptionFunc) (*Worker, error)

func (*Worker) Stop

func (w *Worker) Stop(stopFunc func(), wait bool)

func (*Worker) Working

func (w *Worker) Working() bool

Jump to

Keyboard shortcuts

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