Back to godoc.org
go.uber.org/yarpc / api / backoff

Package backoff

v1.46.0
Latest Go to latest

The latest major version is .

Published: May 21, 2020 | License: MIT | Module: go.uber.org/yarpc

Index

type Backoff

type Backoff interface {
	Duration(attempts uint) time.Duration
}

Backoff is an algorithm for determining how long to wait after a number of attempts to perform some action. Backoff strategies typically use a random number generator that uses some state for feedback. Instances of backoff are intended to be used in the stack of a single goroutine and must therefore either be referentially independent or lock safe.

type Strategy

type Strategy interface {
	Backoff() Backoff
}

Strategy is a factory for backoff algorithms. Each backoff instance may capture some state, typically a random number generator. The strategy guarantees that these backoff instances are either referentially independent and lockless or thread safe.

Backoff strategies are useful for configuring retry loops, balancing the need to recover quickly against denial of service as a failure mode.

var None Strategy = &none{}

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.

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier