Documentation ¶
Index ¶
- func AddJitter(duration time.Duration, jitter time.Duration) time.Duration
- func RetryNWithBackoff(backoff Backoff, n int, fn func() error) error
- func RetryNWithBackoffCtx(ctx context.Context, backoff Backoff, n int, fn func() error) error
- func RetryWithBackoff(backoff Backoff, fn func() error) error
- func RetryWithBackoffCtx(ctx context.Context, backoff Backoff, fn func() error) error
- type Backoff
- type ExponentialBackoff
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddJitter ¶
AddJitter adds an amount of jitter between 0 and the given jitter to the given duration
func RetryNWithBackoff ¶
RetryNWithBackoff takes a Backoff, a maximum number of tries 'n', and a function that returns an error. The function is called until either it does not return an error or the maximum tries have been reached. If the error returned is Retriable, the Retriability of it will be respected. If the number of tries is exhausted, the last error will be returned.
func RetryNWithBackoffCtx ¶
RetryNWithBackoffCtx takes a context, a Backoff, a maximum number of tries 'n', and a function that returns an error. The function is called until it does not return an error, the context is done, or the maximum tries have been reached. If the error returned is Retriable, the Retriability of it will be respected. If the number of tries is exhausted, the last error will be returned.
func RetryWithBackoff ¶
RetryWithBackoff takes a Backoff and a function to call that returns an error If the error is nil then the function will no longer be called If the error is Retriable then that will be used to determine if it should be retried
func RetryWithBackoffCtx ¶
RetryWithBackoffCtx takes a context, a Backoff, and a function to call that returns an error If the context is done, nil will be returned If the error is nil then the function will no longer be called If the error is Retriable then that will be used to determine if it should be retried
Types ¶
type ExponentialBackoff ¶
type ExponentialBackoff struct {
// contains filtered or unexported fields
}
func NewExponentialBackoff ¶
func NewExponentialBackoff(min, max time.Duration, jitterMultiple, multiple float64) *ExponentialBackoff
func (*ExponentialBackoff) Duration ¶
func (sb *ExponentialBackoff) Duration() time.Duration
func (*ExponentialBackoff) Reset ¶
func (sb *ExponentialBackoff) Reset()