jitter

package
v1.6.30 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 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 DurationGenerator

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

DurationGenerator generates time.Durations with variance called "jitter". Successive calls to Generate() return new randomized durations.

The zero-value returns 0 for every duration.

func NewDurationGenerator

func NewDurationGenerator(base time.Duration, jitterPercent float64) DurationGenerator

NewDurationGenerator returns a new DurationGenerator with a base time duration and a percentage of jitter

func (DurationGenerator) Generate

func (g DurationGenerator) Generate() time.Duration

Generate returns a new, randomized duration from the interval base±jitterPercent

func (*DurationGenerator) MarshalLogObject added in v1.6.6

func (g *DurationGenerator) MarshalLogObject(enc zapcore.ObjectEncoder) error

MarshalLogObject allow zap logging

Jump to

Keyboard shortcuts

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