background

package
v0.0.0-...-a69e935 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2019 License: Apache-2.0 Imports: 5 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

type Manager interface {
	// Start starts all registered background works.
	Start()
	// Stop starts all registered background works.
	Stop()
	// RegisterWork registers a background work against the Manager
	RegisterWorks(works ...Work) error
}

Manager allows multiple background Works to be registered and started/stopped together.

func NewManager

func NewManager() Manager

NewManager creates a new instance of Manager with registered background works.

type Work

type Work struct {
	Name         string
	Func         func(*atomic.Bool)
	Period       time.Duration
	InitialDelay time.Duration
}

Work refers to a piece of background work which needs to happen periodically.

Jump to

Keyboard shortcuts

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