Categorygithub.com/intrising/backoff
modulepackage
2.2.1+incompatible
Repository: https://github.com/intrising/backoff.git
Documentation: pkg.go.dev

# README

Exponential Backoff GoDoc Build Status Coverage Status

This is a Go port of the exponential backoff algorithm from Google's HTTP Client Library for Java.

Exponential backoff is an algorithm that uses feedback to multiplicatively decrease the rate of some process, in order to gradually find an acceptable rate. The retries exponentially increase and stop increasing when a certain threshold is met.

Usage

See https://godoc.org/github.com/cenkalti/backoff#pkg-examples

Contributing

  • I would like to keep this library as small as possible.
  • Please don't send a PR without opening an issue and discussing it first.
  • If proposed change is not a common use case, I will probably not accept it.

# Functions

No description provided by the author
NewExponentialBackOff creates an instance of ExponentialBackOff using default values.
NewTicker returns a new Ticker containing a channel that will send the time at times specified by the BackOff argument.
Permanent wraps the given err in a *PermanentError.
Retry the operation o until it does not return error or BackOff stops.
RetryNotify calls notify function with the error and wait duration for each failed attempt before sleep.
WithContext returns a BackOffContext with context ctx ctx must not be nil.
WithMaxRetries creates a wrapper around another BackOff, which will return Stop if NextBackOff() has been called too many times since the last time Reset() was called Note: Implementation is not thread-safe.

# Constants

Default values for ExponentialBackOff.
Default values for ExponentialBackOff.
Default values for ExponentialBackOff.
Default values for ExponentialBackOff.
Default values for ExponentialBackOff.
Stop indicates that no more retries should be made for use in NextBackOff().

# Variables

SystemClock implements Clock interface that uses time.Now().

# Structs

ConstantBackOff is a backoff policy that always returns the same backoff delay.
ExponentialBackOff is a backoff implementation that increases the backoff period for each retry attempt using a randomization function that grows exponentially.
PermanentError signals that the operation should not be retried.
StopBackOff is a fixed backoff policy that always returns backoff.Stop for NextBackOff(), meaning that the operation should never be retried.
Ticker holds a channel that delivers `ticks' of a clock at times reported by a BackOff.
ZeroBackOff is a fixed backoff policy whose backoff time is always zero, meaning that the operation is retried immediately without waiting, indefinitely.

# Interfaces

BackOff is a backoff policy for retrying an operation.
BackOffContext is a backoff policy that stops retrying after the context is canceled.
Clock is an interface that returns current time for BackOff.

# Type aliases

Notify is a notify-on-error function.
An Operation is executing by Retry() or RetryNotify().