timeutil

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2024 License: MIT Imports: 2 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JitterPct

type JitterPct float64

JitterPct is a percent by which to scale a duration up or down. For example, 0.1 will result in +/- 10%.

func (JitterPct) Apply

func (p JitterPct) Apply(d time.Duration) time.Duration

type Ticker

type Ticker struct {
	C <-chan time.Time
	// contains filtered or unexported fields
}

Ticker is like time.Ticker, but with a variable period.

func NewTicker

func NewTicker(nextDur func() time.Duration) *Ticker

NewTicker returns a started Ticker which calls nextDur for each period. Ticker.Stop should be called to prevent goroutine leaks.

func (*Ticker) Reset

func (t *Ticker) Reset()

Reset starts a new period.

func (*Ticker) Stop

func (t *Ticker) Stop()

Stop permanently stops the Ticker. It cannot be Reset.

Jump to

Keyboard shortcuts

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