Documentation ¶
Overview ¶
Package retry implements retry functionality.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Do ¶
func Do(ctx context.Context, maxDuration time.Duration, fn func() error, matches ...MatchFunc) error
Do implements retry using fibonacci backoff, up to a total execution time of maxDuration (use zero to indicate no max). The maximum interval between retries is 5 seconds.
If len(matches) is zero, retry will be attempted until ctx is canceled or times out, or maxDuration is reached. If one or more MatchFuncs are supplied, retry is performed only if the error returned by fn is matched by one of the MatchFunc args.
For simple string matching, use retry.Match("value") for convenience.
err = retry.Do(ctx, time.Second*10, dbConnect, retry.Match("connection refused"))
func DoConstant ¶ added in v0.31.0
func DoConstant(ctx context.Context, interval, maxDuration time.Duration, fn func() error, matches ...MatchFunc) error
DoConstant is similar to Do, but uses a constant backoff instead of fibonacci.
func SleepJitter ¶ added in v0.31.0
func SleepJitter()
SleepJitter sleeps for a jittery amount of time.