backoff

package
v1.0.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2022 License: MIT Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = Config{
	BaseDelay:  1.0 * time.Second,
	Multiplier: 1.0,
	Jitter:     0.2,
	MaxDelay:   120 * time.Second,
}

DefaultConfig is a backoff configuration with default values. This should be useful for callers who want to configure backoff with non-default values only for a subset of the options.

Functions

This section is empty.

Types

type Config

type Config struct {
	BaseDelay  time.Duration
	Multiplier float64
	Jitter     float64
	MaxDelay   time.Duration
}

Config defines the configuration options for backoff.

type Constant

type Constant struct {
	BaseDelay time.Duration
}

Constant is a default implementation for a backoff strategy with constant backoff.

func (Constant) Backoff

func (b Constant) Backoff(retries int) time.Duration

Backoff returns the duration to wait.

type Exponential

type Exponential struct {
	Config
}

Exponential is an implementation of a backoff strategy applying an exponential function.

func (Exponential) Backoff

func (b Exponential) Backoff(retries int) time.Duration

Backoff returns the duration to wait.

type Linear

type Linear struct {
	Config
}

Linear is an implementation of a backoff strategy applying a linear function.

func (Linear) Backoff

func (b Linear) Backoff(retries int) time.Duration

Backoff returns the duration to wait.

Jump to

Keyboard shortcuts

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