backoff

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: BSD-2-Clause Imports: 2 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 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. 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.

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