Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
Context stores state related to an operation that should be retried.
func NewDefault ¶
func NewDefault() *Context
NewDefault returns a new retry context with default settings.
func (*Context) Retry ¶
Retry records an error that was retried (accessible in LastError) If a consumer was passed, it'll pause progress, and log the error. It's also in charge of sleeping (following exponential backoff)
func (*Context) ShouldTry ¶
ShouldTry must be used in a loop, like so:
----------------------------------------
for rc.ShouldRetry() { err := someOperation() if err != nil { if isRetriable(err) { rc.Retry(err.Error()) continue } } // succeeded! return nil // escape from loop }
// THIS IS IMPORTANT return errors.New("task: too many failures, giving up") ----------------------------------------
If you forget to return an error after the loop, if there are too many errors you'll just keep running.