backoff

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2021 License: Apache-2.0 Imports: 6 Imported by: 158

README

CircleCI

backoff

Backoff is a library abstracting retry functionality using https://godoc.org/github.com/cenkalti/backoff. We use this library to have a unified interface and the opportunity to wrap and extend backoff implementations as we need them.

Documentation

Index

Constants

View Source
const (
	LongMaxWait   = 40 * time.Minute
	MediumMaxWait = 10 * time.Minute
	ShortMaxWait  = 2 * time.Minute
)
View Source
const (
	LongMaxInterval  = 60 * time.Second
	ShortMaxInterval = 5 * time.Second
)
View Source
const Stop = backoff.Stop

Variables

This section is empty.

Functions

func NewNotifier

func NewNotifier(l micrologger.Logger, ctx context.Context) func(error, time.Duration)

func Permanent

func Permanent(err error) error

func Retry

func Retry(o Operation, b BackOff) error

Retry retries the operation o until it does not return error or BackOff stops. See https://godoc.org/github.com/cenkalti/backoff#Retry for details.

func RetryNotify

func RetryNotify(o Operation, b BackOff, n Notify) error

RetryNotify does what Retry do with notification between each try.

Types

type BackOff

type BackOff interface {
	NextBackOff() time.Duration
	Reset()
}

BackOff describes how a backoff has to be implemented. Also see https://godoc.org/github.com/cenkalti/backoff/v4#BackOff.

func NewConstant

func NewConstant(maxWait, maxInterval time.Duration) BackOff

func NewExponential

func NewExponential(maxWait, maxInterval time.Duration) BackOff

func NewMaxRetries

func NewMaxRetries(maxRetries uint64, maxInterval time.Duration) BackOff

func NewStop

func NewStop() BackOff

type Interface

type Interface = BackOff

Interface is an alias for backward compatibility.

type Notify

type Notify func(error, time.Duration)

Notify is a notify-on-error function. It receives an operation error and backoff delay if the operation failed (with an error).

NOTE that if the backoff policy stated to stop retrying, the notify function isn't called.

type Operation

type Operation func() error

An Operation is executing by Retry() or RetryNotify(). The operation will be retried using a backoff policy if it returns an error.

Jump to

Keyboard shortcuts

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