Documentation ¶
Overview ¶
Package backoff implements a simple exponential backoff algorithms for retrying operations.
Use Do function for retrying operations that may fail.
Simple example:
boff := backoff.New( backoff.Exponential(), backoff.MaxRetries(30), backoff.Notify(func(err error, next time.Duration, count uint) { log.Println(count, next, err) }), ) err := boff.Do(ctx, func(ctx) error { // if fail return err // if fail but not retry return backoff.Continue(err) // if ok return nil })
Index ¶
- Variables
- func Continue(err error) error
- type Backoff
- type Handle
- type NotifyHandle
- type Option
- func Exponential() Option
- func Interval(duration time.Duration) Option
- func MaxElapsedTime(duration time.Duration) Option
- func MaxInterval(duration time.Duration) Option
- func MaxRetries(v uint) Option
- func Multiplier(multiplier float64) Option
- func Notify(fn NotifyHandle) Option
- func RandomizationFactor(randomizationFactor float64) Option
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrMaxRetries = errors.New("") ErrMaxElapsedTime = errors.New("") )
Functions ¶
Types ¶
type Option ¶
type Option func(*internal.BackoffSettings)
func Exponential ¶
func Exponential() Option
func MaxElapsedTime ¶
func MaxInterval ¶
func MaxRetries ¶
func Multiplier ¶
func Notify ¶
func Notify(fn NotifyHandle) Option
func RandomizationFactor ¶
Click to show internal directories.
Click to hide internal directories.