task

package
v0.4.33 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 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 BackgroundTaskManager

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

BackgroundTaskManager is used for registering tasks (functions) to be run periodically. Prometehus log names for each task are prepended with metricsPrefix. BackgroundTaskManager is not threadsafe; it should only be accessed from a single thread.

func NewBackgroundTaskManager

func NewBackgroundTaskManager(metricsPrefix string) *BackgroundTaskManager

NewBackgroundTaskManager returns a new BackgroundTaskManager with no registered tasks. Call Register to add and start tasks.

func (*BackgroundTaskManager) Register

func (m *BackgroundTaskManager) Register(function func(), interval time.Duration, metricName string)

Register the function f to be run periodically. Interval is the time between function returns and the next time it is called, i.e., the time between calls to function is interval + the runtime of the function.

func (*BackgroundTaskManager) StopAll

func (m *BackgroundTaskManager) StopAll(timeout time.Duration) bool

StopAll stops all tasks. Returns after all currently running tasks have finished or timeout has elapsed, whichever occurs first. Returns true if there are tasks still running when this function returns and false otherwise.

Jump to

Keyboard shortcuts

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