backoff

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2022 License: MIT Imports: 3 Imported by: 1

README

backoff

Go Reference

Backoff algorithms in Go for retrying operations

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultSuccess

func DefaultSuccess(err error) bool

The default success condition

Types

type Backoff

type Backoff func(ctx context.Context, operation Operation, onErr OnErr) error

The backoff function

func ExponentialBackoff

func ExponentialBackoff(min time.Duration, max time.Duration, factor float64) Backoff

Performs an operation with an exponential backoff

func ExponentialBackoffWithSuccess

func ExponentialBackoffWithSuccess(min time.Duration, max time.Duration, factor float64, success Success) Backoff

Performs an operation with an exponential backoff using a custom success condition

func LinearBackoff

func LinearBackoff(attempts int, duration time.Duration) Backoff

Performs an operation with a linear backoff

func LinearBackoffWithSuccess

func LinearBackoffWithSuccess(attempts int, duration time.Duration, success Success) Backoff

Performs an operation with a linear backoff using a custom success condition

type OnErr

type OnErr func(err error)

Callback when we have an error

type Operation

type Operation func() error

The operation to perform in the backoff

type Success

type Success func(err error) bool

Returns true if the operation succeeded

Jump to

Keyboard shortcuts

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