backoff

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2024 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 Min. After every call to Duration() it is multiplied by Factor. It is capped at Max. It returns to Min 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)

Returns the current value of the counter and then multiplies it Factor

func (*Backoff) Reset

func (b *Backoff) Reset()

Resets the current value of the counter back to Min

Jump to

Keyboard shortcuts

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