worker

package
v0.0.0-...-ae3587a Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2020 License: LGPL-3.0 Imports: 6 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 struct {
	// contains filtered or unexported fields
}

Builder is for configuring a worker

func (Builder) AddShutdownHook

func (b Builder) AddShutdownHook(hookName string, hook func() error) Builder

AddShutdownHook registers the hook to be called on shutdown of the worker

func (Builder) Build

func (b Builder) Build() (*Worker, error)

Build a Worker with the given configuration

func (Builder) MustBuild

func (b Builder) MustBuild() *Worker

MustBuild a Worker with the given configuration. Panics if not all required config is given

func (Builder) WithName

func (b Builder) WithName(n string) Builder

WithName sets the worker name (required)

func (Builder) WithStopTimeout

func (b Builder) WithStopTimeout(t time.Duration) Builder

WithStopTimeout changes the timeout used when stopping the worker loop. If not set, uses defaultStopTimeout

func (Builder) WithWorkStep

func (b Builder) WithWorkStep(s func() error) Builder

WithWorkStep sets the step func a worker should repeatedly call (required)

type Worker

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

Worker abstracts away all the executor lifecycle hooks, exposing a much more high level api

func (*Worker) Close

func (w *Worker) Close()

Close Worker work

func (*Worker) Start

func (w *Worker) Start() (wait func())

Start tells the worker to go and do work in another goroutine. Returns a wait func that blocks until the worker is closed or encountered an error it can't handle

Jump to

Keyboard shortcuts

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