backoff

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backoff

type Backoff interface {
	// Next returns the next amount of backoff to wait before retrying
	// based on the amount of retries already attempted.
	Next(retries int) time.Duration
}

Backoff allows us to customise the amount of delay (or backoff) between HTTP request retries.

func Constant

func Constant(delay time.Duration) Backoff

Constant returns a backoff strategy which always waits the same amount of time between requests.

func Exponential

func Exponential(initial, max time.Duration) (Backoff, error)

Exponential applies an exponential type strategy from the initial interval up to the defined max using the default growth rate.

func ExponentialWithGrowthRate

func ExponentialWithGrowthRate(initial, max time.Duration, growth float64) (Backoff, error)

ExponentialWithGrowthRate applies an exponential type strategy from the initial interval up to the defined max using the supplied growth rate which should be between 0.1 and 1.0 (1% - 100% growth)

func Zero

func Zero() Backoff

Zero returns a backoff strategy which always allows no time for delay between attempts.

Jump to

Keyboard shortcuts

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