periodic

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2018 License: Apache-2.0 Imports: 3 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 StartPeriodicTask

func StartPeriodicTask(task Task, ticker *time.Ticker, timeout time.Duration) *Runner

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

func (*Runner) Stop

func (r *Runner) Stop()

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

type Task

type Task interface {
	// Run executes the task once, it should return within the context's timeout.
	Run(context.Context)
}

A Task that has to be periodically executed.

Jump to

Keyboard shortcuts

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