retry

package
v0.8.9 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultBaseSleep = 100 * time.Millisecond
	DefaultCapSleep  = 30 * time.Second
	DefaultFactor    = 2.0
)

Defaults for the retries.

Variables

This section is empty.

Functions

func Do

func Do(ctx context.Context, fn func(context.Context) (bool, error), opts ...Option) error

Do an action with exponential randomized backoff.

Types

type OnRetry

type OnRetry func(attempt float64, err error)

type Option

type Option func(*retrier)

An Option changes the default behavior of a retrier.

func UseBaseSleep

func UseBaseSleep(base time.Duration) Option

UseBaseSleep makes the retrier sleep at least `base`.

func UseCapSleep

func UseCapSleep(cap time.Duration) Option

UseCapSleep makes the retrier sleep at most `cap`.

func UseFactor

func UseFactor(factor float64) Option

UseFactor makes the retrier grow its exponential backoff using factor as the base of the exponent.

func UseLog

func UseLog(log OnRetry) Option

UseLog makes the retrier log retries to the given func.

func UseRand

func UseRand(rd *rand.Rand) Option

UseRand makes the retrier use the *rand.Rand for randomization of retries.

Jump to

Keyboard shortcuts

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