jitter

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2016 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package jitter provides methods of transforming durations.

Copyright © 2016 Trevor N. Suarez (Rican7)

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. If a nil generator is passed, a default one will be provided.

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. If a nil generator is passed, a default one will be provided.

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. If a nil generator is passed, a default one will be provided.

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. If a nil generator is passed, a default one will be provided.

Jump to

Keyboard shortcuts

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