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. Prometheus 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.