backoff

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2017 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Exponential

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

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. It is a stateless implementation and is safe to use concurrently.

func NewExponential

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

NewExponential returns a new Exponential Backoff Strategy.

func (*Exponential) Duration

func (e *Exponential) Duration(attempts uint) time.Duration

Duration takes an attempt number and returns the duration the caller should wait.

type ExponentialOption

type ExponentialOption func(*exponentialOptions)

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

func BaseJump

func BaseJump(t time.Duration) ExponentialOption

BaseJump sets the default "jump" the exponential backoff strategy will use.

func MaxBackoff

func MaxBackoff(t time.Duration) ExponentialOption

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

func MinBackoff

func MinBackoff(t time.Duration) ExponentialOption

MinBackoff sets absolute min time that will ever be returned for a backoff.

type Strategy

type Strategy func(attempts uint) time.Duration

Strategy defines a function that will return a backoff time given an attempt number.

Jump to

Keyboard shortcuts

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