repeater

package
v1.1.49 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2024 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Options)

type Options

type Options struct {
	// Enabled controls if the side effect should ever be run. If false,
	// Repeater.Start and Repeater.Stop will do nothing.
	Enabled bool
	// Interval controls how often the side effect should be run.
	Interval time.Duration
	// StartRun controls if the side effect should be run immediately when
	// Repeater.Start is called.
	StartRun bool
	// StopRun controls if the side effect should be run immediately when
	// Repeater.Stop is called.
	StopRun bool
}

type Repeater

type Repeater interface {
	// Start begins running the side effect on the configured interval.
	Start()
	// Stop ceases running the side effect.
	Stop()
}

Repeater runs an arbitrary side effect at a regular interval.

func New

func New(run func(), options ...Option) Repeater

New creates a new Repeater for the given side effect. The interval can be configured with the other options; it defaults to 30 seconds.

Jump to

Keyboard shortcuts

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