util

package
v0.0.0-...-1a56975 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Worker

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

Worker is a utility to help manage the lifecycle of a worker thread.

func NewWorker

func NewWorker(name string, scope *log.Scope) *Worker

NewWorker creates a new worker with the given name and logging scope.

func (*Worker) Start

func (w *Worker) Start(setupFn func() error, runFn func(c context.Context)) error

Start the worker thread via the provided lambda. The runFn lambda is run in a go routine and is provided a context to trigger the exit of the function. If this Worker was already started, returns an error.

func (*Worker) Stop

func (w *Worker) Stop()

Stop the worker thread and waits for it to exit gracefully.

Jump to

Keyboard shortcuts

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