backoff

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: BSD-2-Clause Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backoff

type Backoff struct {

	// Initial value to scale out
	Initial time.Duration
	// Jitter value randomizes an additional delay between 0 and Jitter
	Jitter time.Duration
	// Max maximum values of the backoff
	Max time.Duration
	// contains filtered or unexported fields
}

Backoff is a time.Duration counter. It starts at Initial. After every call to Duration() it is doubled. It is capped at Max before the optional Jitter is added, so the result is at most Max+Jitter. It returns to Initial on every call to Reset(). Used in conjunction with the time package.

func (*Backoff) Attempts

func (b *Backoff) Attempts() int

Attempts returns the number of attempts that we had done so far

func (*Backoff) Duration

func (b *Backoff) Duration() (dur time.Duration)

Duration returns the current value of the counter, then doubles it for the next call. Optional jitter is added to the returned value, and the result is capped at Max before the optional jitter is added, so the result is at most Max+Jitter.

func (*Backoff) Reset

func (b *Backoff) Reset()

Reset sets the current value of the counter back to Initial

Jump to

Keyboard shortcuts

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