Documentation
¶
Overview ¶
Package retry calls an operation again after failures that may pass (a data plane that is still starting, a busy lock), with exponential backoff, until it succeeds, fails for good, its budget is spent or its context ends.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Do ¶
Do calls fn until it returns nil or a Permanent error, until it fails once the budget has passed, or until ctx ends while Do waits for the next attempt. It returns nil, fn's last error (a permanent one still marked) or ctx.Err().
func IsPermanent ¶
IsPermanent reports whether err, or an error it wraps, was marked by Permanent.
Types ¶
type Policy ¶
type Policy struct {
// Budget is how long failures are retried: a failure once Budget has
// passed since the first attempt is the last one.
Budget time.Duration
// Delay is the pause after the first failure; it doubles after every
// further one, up to MaxDelay.
Delay, MaxDelay time.Duration
// Attempt bounds each attempt; 0 leaves that to the operation.
Attempt time.Duration
}
Policy is a retry schedule.