Documentation ¶
Index ¶
- type Loop
- type Policy
- func BoundedExponentialBackoff(baseSleepTime time.Duration, maxSleepTime time.Duration, maxRetries int) Policy
- func ExponentialBackoff(baseSleepTime time.Duration, maxRetries int) Policy
- func NTimes(n int, sleepBetweenRetries time.Duration) Policy
- func Once(sleepBetweenRetry time.Duration) Policy
- func UntilElapsed(maxElapsed, sleepBetweenRetries time.Duration) Policy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Loop ¶
type Loop struct {
// contains filtered or unexported fields
}
Loop is an object that manages running the callable function and retrying it based on a give policy.
func NewLoop ¶
NewLoop creates a loop object that executes the cancelable function according to the given policy
type Policy ¶
type Policy interface { Name() string AllowRetry(retryCount int, elapsed time.Duration) (bool, time.Duration) }
Policy is the interface for a retry policy type.
func BoundedExponentialBackoff ¶
func BoundedExponentialBackoff(baseSleepTime time.Duration, maxSleepTime time.Duration, maxRetries int) Policy
BoundedExponentialBackoff returns a policy that will retry up to maxRetries with an exponentially increasing sleep time up to maxSleepTime.
func ExponentialBackoff ¶
ExponentialBackoff returns a policy that will retry up to maxRetries with an exponentially increasing sleep time.
func UntilElapsed ¶
UntilElapsed returns a policy that retries until a given amount of time elapses
Click to show internal directories.
Click to hide internal directories.