Documentation
¶
Index ¶
Constants ¶
const ( Cancelled = cancelReason("context cancelled") Stopped = cancelReason("retry stopped") AttemptsExhausted = cancelReason("attempts exhausted") )
Variables ¶
This section is empty.
Functions ¶
func Stop ¶
Stop forces the retry to cancel with the provided error and retry.Err.Reason == retry.Stopped
Types ¶
type Async ¶
type Async struct {
// contains filtered or unexported fields
}
func NewRetryAsync ¶
func NewRetryAsync() *Async
Given a function that takes a context, run the provided function; if it fails, retry the function asynchronously and return Async{}. Subsequent calls to with the same 'key' will return Async{} if the function is still retrying, this continues until the retry period has exhausted or the context expires or is cancelled. Then the final error returned by f() is returned to the caller on the final call with the same 'key'
The code assumes the caller will continue to call `Async()` until either the retries have exhausted or an Async{Retrying: false} is returned.
type AttemptsBackOff ¶
type AttemptsBackOff struct { Interval time.Duration Attempts int64 // contains filtered or unexported fields }
Retry for `attempts` number of retries sleeping for `interval` between each retry
func (*AttemptsBackOff) New ¶
func (b *AttemptsBackOff) New() BackOff
func (*AttemptsBackOff) NumRetries ¶
func (b *AttemptsBackOff) NumRetries() int
func (*AttemptsBackOff) Reset ¶
func (b *AttemptsBackOff) Reset()
type ConstBackOff ¶
Retry indefinitely sleeping for `interval` between each retry
func Interval ¶
func Interval(t time.Duration) *ConstBackOff
func (*ConstBackOff) New ¶
func (b *ConstBackOff) New() BackOff
func (*ConstBackOff) NumRetries ¶
func (b *ConstBackOff) NumRetries() int
func (*ConstBackOff) Reset ¶
func (b *ConstBackOff) Reset()
type ExponentialBackOff ¶
type ExponentialBackOff struct {
Min, Max time.Duration
Factor float64
Attempts int64
// contains filtered or unexported fields
}
func (*ExponentialBackOff) New ¶
func (b *ExponentialBackOff) New() BackOff
func (*ExponentialBackOff) NumRetries ¶
func (b *ExponentialBackOff) NumRetries() int
func (*ExponentialBackOff) Reset ¶
func (b *ExponentialBackOff) Reset()