interval

package module
v0.37.1 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2021 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package interval is a work in progress. Later versions may support parallel execution.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Runnable

type Runnable interface {
	// called once at Start() time
	Setup() error
	// called on the interval defined by the
	// duration passed into NewRunner
	Run() error
}

Runnable must be implemented by types passed into the Runner constructor.

type Runner

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

Runner takes a list of `Runnable`s, calls Setup() on each of them and then calls Run() on each of them, using a Ticker, sequentially and within the same goroutine. Call Stop() to turn off the Ticker.

func NewRunner

func NewRunner(interval time.Duration, runnables ...Runnable) *Runner

NewRunner creates a new interval runner. Pass in a duration (time between calls) and one or more Runnables to be run on the defined interval.

func (*Runner) Start

func (r *Runner) Start() error

Start kicks off this Runner. Calls Setup() and Run() on the passed-in Runnables.

func (*Runner) Stop

func (r *Runner) Stop()

Stop turns off this Runner's ticker.

Jump to

Keyboard shortcuts

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