periodic

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 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 Doer

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

Doer limits an action to be executed at most once within a specified period. It is intended for managing events that occur frequently, but instead of an action being taken for every event, the action should be executed at most once within a given period of time.

Doer takes a function to execute, doFn, which is called every time the specified period has elapsed with the number of events and the period.

func NewDoer

func NewDoer(period time.Duration, doFn func(count uint64, d time.Duration)) *Doer

NewDoer returns a new Doer. It takes a doFn, which is called with the current count of events and the period.

func (*Doer) Add

func (r *Doer) Add()

func (*Doer) AddN

func (r *Doer) AddN(n uint64)

func (*Doer) Start

func (r *Doer) Start()

func (*Doer) Stop

func (r *Doer) Stop()

Jump to

Keyboard shortcuts

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