Do performs the given operation. Based on the options, it can retry the operation, if it failed.
The following options are supported: * RetryChecker(func(err error) bool) - If this func returns true for the returned error, the operation is tried again * MaxTries(int) - Maximum number of calls to op() before aborting with MaxRetriesReached * Timeout(time.Duration) - Maximum number of time to try to perform this op before aborting with TimeoutReached * Sleep(time.Duration) - time to sleep after error failed op()
Timeout = 15 seconds MaxRetries = 5 Retryer = errgo.Any Sleep = No sleep
IsMaxRetriesReached returns true if the cause of the given error is a MaxRetriesReachedError.
IsTimeout returns true if the cause of the given error is a TimeoutError.
Not is a helper to invert another .
type RetryOption func(options *retryOptions)
AfterRetry is called after a retry and can be used e.g. to emit events.
AfterRetryLimit is called after a retry limit is reached and can be used e.g. to emit events.
MaxTries specifies the maximum number of times op will be called by Do().
RetryChecker defines whether the given error is an error that can be retried.
Timeout specifies the maximum time that should be used before aborting the retry loop. Note that this does not abort the operation in progress.