backoff

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultFactor float64 = 2.0
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Backoff

type Backoff struct {
	// contains filtered or unexported fields
}

Backoff calculation utility for retries.

func New

func New(conf Conf) *Backoff

func (*Backoff) Get

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

func (*Backoff) GetIncr

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

func (*Backoff) GetRetries

func (b *Backoff) GetRetries() int

func (*Backoff) Incr

func (b *Backoff) Incr() int

func (*Backoff) Reset

func (b *Backoff) Reset()

type Conf

type Conf struct {
	// Base start duration - backoff can be no shorter than the BaseStart.Add(JitterMin).
	BaseStart time.Duration
	// Base max duration - backoff can be no longer than the BaseMax.Add(JitterMax).
	BaseMax time.Duration
	// Backoff exponential growth factor.
	Factor float64
	// Min random duration to add to the backoff value to prevent potential
	// upstream overloading during the simultaneous retry among clients implementing backoff.
	// Must be less than JitterMax.
	JitterMin time.Duration
	// Max random duration to add to the backoff value to prevent potential
	// upstream overloading during the simultaneous retry among clients implementing backoff.
	// Must be greater than JitterMin.
	JitterMax time.Duration
}

Jump to

Keyboard shortcuts

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