backoff

package
v1.34.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2022 License: BSD-3-Clause Imports: 4 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

Overview

Package backoff provides a back-off timer type.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backoff

type Backoff struct {

	// NewTimer is the function that acts like time.NewTimer.
	// It's for use in unit tests.
	NewTimer func(time.Duration) *time.Timer

	// LogLongerThan sets the minimum time of a single backoff interval
	// before we mention it in the log.
	LogLongerThan time.Duration
	// contains filtered or unexported fields
}

Backoff tracks state the history of consecutive failures and sleeps an increasing amount of time, up to a provided limit.

func NewBackoff added in v0.98.1

func NewBackoff(name string, logf logger.Logf, maxBackoff time.Duration) *Backoff

NewBackoff returns a new Backoff timer with the provided name (for logging), logger, and max backoff time. By default, all failures (calls to BackOff with a non-nil err) are logged unless the returned Backoff.LogLongerThan is adjusted.

func (*Backoff) BackOff

func (b *Backoff) BackOff(ctx context.Context, err error)

Backoff sleeps an increasing amount of time if err is non-nil. and the context is not a It resets the backoff schedule once err is nil.

Jump to

Keyboard shortcuts

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