jitter

package
v5.0.0-rc8 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2021 License: MIT Imports: 3 Imported by: 1

Documentation

Overview

Package jitter provides methods of transforming durations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Transformation

type Transformation = func(duration time.Duration) time.Duration

Transformation defines a function that calculates a time.Duration based on the given duration.

func Deviation

func Deviation(generator *rand.Rand, factor float64) Transformation

Deviation creates a Transformation that transforms a duration into a result duration that deviates from the input randomly by a given factor.

The given generator is what is used to determine the random transformation.

Inspired by https://developers.google.com/api-client-library/java/google-http-java-client/backoff

func Equal

func Equal(generator *rand.Rand) Transformation

Equal creates a Transformation that transforms a duration into a result duration in [n/2, n) randomly, where n is the given duration.

The given generator is what is used to determine the random transformation.

Inspired by https://www.awsarchitectureblog.com/2015/03/backoff.html

func Full

func Full(generator *rand.Rand) Transformation

Full creates a Transformation that transforms a duration into a result duration in [0, n) randomly, where n is the given duration.

The given generator is what is used to determine the random transformation.

Inspired by https://www.awsarchitectureblog.com/2015/03/backoff.html

func NormalDistribution

func NormalDistribution(generator *rand.Rand, standardDeviation float64) Transformation

NormalDistribution creates a Transformation that transforms a duration into a result duration based on a normal distribution of the input and the given standard deviation.

The given generator is what is used to determine the random transformation.

Jump to

Keyboard shortcuts

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