periodic

package
v1.20.1 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package periodic allow to execute a specified function periodically.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Periodic

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

Periodic instance.

func New

func New(interval time.Duration, jitter time.Duration, timeout time.Duration, task TaskFn) (*Periodic, error)

New creates a new Periodic instance. The jitter parameter is the maximum random Jitter time between each function call. This is useful to avoid the Thundering herd problem (https://en.wikipedia.org/wiki/Thundering_herd_problem).

func (*Periodic) Start

func (p *Periodic) Start()

Start the periodic execution.

func (*Periodic) Stop

func (p *Periodic) Stop()

Stop the periodic execution. It may block until the last running function returns.

type TaskFn

type TaskFn func(context.Context)

TaskFn is the type of function to be periodically executed.

Jump to

Keyboard shortcuts

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