backoff

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2017 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultExponential = &ExponentialStrategy{
	opts: defaultExponentialOpts,
}

DefaultExponential is an exponential backoff.Strategy with full jitter. The first attempt has a range of 0 to 10ms and each successive attempt doubles the range of the possible delay.

Exponential strategies are not thread safe. The Backoff() method returns a referentially independent backoff generator and random number generator.

View Source
var None backoff.Strategy = &ExponentialStrategy{
	opts: noneOpts,
}

None is a shorted backoff strategy that will always produce a 0ms duration. This strategy is intended to minimize arbitrary delays during tests or maximize load on a benchmark.

Functions

This section is empty.

Types

type ExponentialOption

type ExponentialOption func(*exponentialOptions)

ExponentialOption defines options that can be applied to an exponential backoff stragety

func FirstBackoff added in v1.10.0

func FirstBackoff(t time.Duration) ExponentialOption

FirstBackoff sets the initial range of durations that the first backoff duration will provide. The range of durations will double for each successive attempt.

func MaxBackoff

func MaxBackoff(t time.Duration) ExponentialOption

MaxBackoff sets absolute max time that will ever be returned for a backoff.

type ExponentialStrategy added in v1.10.0

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

ExponentialStrategy can create instances of the exponential backoff strategy with full jitter. Each instance has referentially independent random number generators.

func NewExponential

func NewExponential(opts ...ExponentialOption) (*ExponentialStrategy, error)

NewExponential returns a new exponential backoff strategy, which in turn returns backoff functions.

Exponential is an exponential backoff strategy with jitter. Under the AWS backoff strategies this is a "Full Jitter" backoff implementation https://www.awsarchitectureblog.com/2015/03/backoff.html with the addition of a Min and Max Value. The range of durations will be contained in a closed [Min, Max] interval.

Backoff functions are lockless and referentially independent, but not thread-safe.

func (*ExponentialStrategy) Backoff added in v1.10.0

func (e *ExponentialStrategy) Backoff() backoff.Backoff

Backoff returns an instance of the exponential backoff strategy with its own random number generator.

func (*ExponentialStrategy) IsEqual added in v1.10.0

IsEqual returns whether this strategy is equivalent to another strategy.

Jump to

Keyboard shortcuts

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