backoff

package
v1.19.1 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 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.

Functions

This section is empty.

Types

type ExponentialOption

type ExponentialOption func(*exponentialOptions)

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

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