Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ForDuration ¶
ForDuration will retry the given function until it either returns without error, or the given duration has elapsed. The function is invoked immediately at first and then successively with an exponential backoff starting at 1ns and ending at the specified duration.
This function is DEPRECATED! Please use one of the other functions in this package that takes context cancellation into account.
TODO(benesch): remove this function and port its callers to a context- sensitive API.
Types ¶
type Options ¶
type Options struct { InitialBackoff time.Duration // Default retry backoff interval MaxBackoff time.Duration // Maximum retry backoff interval Multiplier float64 // Default backoff constant MaxRetries int // Maximum number of attempts (0 for infinite) RandomizationFactor float64 // Randomize the backoff interval by constant Closer <-chan struct{} // Optionally end retry loop channel close. }
Options provides reusable configuration of Retry objects.
type Retry ¶
type Retry struct {
// contains filtered or unexported fields
}
Retry implements the public methods necessary to control an exponential- backoff retry loop.
func Start ¶
Start returns a new Retry initialized to some default values. The Retry can then be used in an exponential-backoff retry loop.
func StartWithCtx ¶
StartWithCtx returns a new Retry initialized to some default values. The Retry can then be used in an exponential-backoff retry loop. If the provided context is canceled (see Context.Done), the retry loop ends early.
func (*Retry) Next ¶
Next returns whether the retry loop should continue, and blocks for the appropriate length of time before yielding back to the caller. If a stopper is present, Next will eagerly return false when the stopper is stopped.