periodic

package
v0.4.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Runner

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

Runner runs a task periodically.

func Start

func Start(task Task, period, timeout time.Duration) *Runner

Start creates and starts a new Runner to run the given task peridiocally. The timeout is used for the context timeout of the task. The timeout can be larger than the periodicity of the task. That means if a tasks takes a long time it will be immediately retriggered.

func (*Runner) Kill

func (r *Runner) Kill()

Kill is like stop but it also cancels the context of the current running method.

func (*Runner) Stop

func (r *Runner) Stop()

Stop stops the periodic execution of the Runner. If the task is currently running this method will block until it is done.

func (*Runner) TriggerRun

func (r *Runner) TriggerRun()

TriggerRun triggers the periodic task to run now. This does not impact the normal periodicity of this task. That means if the periodicity is 5m and you call TriggerNow() after 2 minutes, the next execution will be in 3 minutes.

The method blocks until either the triggered run was started or the runner was stopped, in which case the triggered run will not be executed.

type Task

type Task interface {
	// Run executes the task once, it should return within the context's timeout.
	Run(context.Context)
	// Name returns the tasks name, each successive call should return the same
	// value as the first call.
	Name() string
}

A Task that has to be periodically executed.

Directories

Path Synopsis
internal
metrics/mock_metrics
Package mock_metrics is a generated GoMock package.
Package mock_metrics is a generated GoMock package.

Jump to

Keyboard shortcuts

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