raterun

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2024 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 RunFunction

type RunFunction func(frequency time.Duration)

RunFunction is a function type that represents the function to be executed by the Runner.

It will be called with the frequency at which the function is executed.

type Runner

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

func New

func New(fn RunFunction, schedules []Schedule) (*Runner, error)

New creates a new runner that will execute fn as defined by the provided schedules

Each Schedule in schedules defines how often fn should be executed at any given point in time.

func (*Runner) Restart added in v2.1.0

func (r *Runner) Restart()

Restart will stop the current schedule and start from the first one defined.

func (*Runner) Start added in v2.1.0

func (r *Runner) Start(ctx context.Context)

Start starts the execution of the runner.

Start is non-blockig and runs in a go routine. The provided context can be used to manage the lifecycle. Stop() will also terminate the runner.

func (*Runner) Stop added in v2.1.0

func (r *Runner) Stop()

Stop stopps the runner and will block until the runner is stopped

type Schedule added in v2.1.0

type Schedule struct {
	// StartDelay is when the function will start executing at a certain frequency
	StartDelay time.Duration
	// Frequency configures how often the function will be executed during this Schedule
	Frequency time.Duration
}

Schedule configures when and how frequent the Runner will execute the function

Jump to

Keyboard shortcuts

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