backoff

package
v1.4.8 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultRetryTimes = 5

Variables

This section is empty.

Functions

func Delay

func Delay(f func() error) error

func DelayIn

func DelayIn(times int, f func() error) (err error)

Types

type Backoff

type Backoff interface {
	Delay(retries int) time.Duration
}
var DefaultBackoff Backoff = &PowerBackoff{
	MaxDelay:  30 * time.Second,
	InitDelay: 1 * time.Second,
	Factor:    1.6,
}

func GetBackoff

func GetBackoff() Backoff

type PowerBackoff

type PowerBackoff struct {
	MaxDelay  time.Duration
	InitDelay time.Duration
	Factor    float64
}

delay = min(MaxDelay, InitDelay * power(Factor, retries))

func (*PowerBackoff) Delay

func (pb *PowerBackoff) Delay(retries int) time.Duration

Jump to

Keyboard shortcuts

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