Documentation ¶
Overview ¶
Package retry provides functional mechanism to perform actions repetitively until successful.
Index ¶
- func IsInterrupted(err error) bool
- func IsRecovered(err error) (interface{}, bool)
- func Retry(breaker BreakCloser, action func(attempt uint) error, ...) error
- func Try(breaker Breaker, action func(attempt uint) error, ...) error
- func TryContext(ctx context.Context, action func(ctx context.Context, attempt uint) error, ...) error
- type BreakCloser
- type Breaker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsInterrupted ¶
IsInterrupted checks that the error is related to the Breaker interruption on Retry call.
func IsRecovered ¶
IsRecovered checks that the error is related to unhandled Action's panic and returns an original cause of panic.
func Retry ¶
func Retry( breaker BreakCloser, action func(attempt uint) error, strategies ...func(attempt uint, err error) bool, ) error
Retry takes action and performs it, repetitively, until successful. When it is done it releases resources associated with the Breaker.
Optionally, strategies may be passed that assess whether or not an attempt should be made.
func Try ¶
func Try( breaker Breaker, action func(attempt uint) error, strategies ...func(attempt uint, err error) bool, ) error
Try takes action and performs it, repetitively, until successful.
Optionally, strategies may be passed that assess whether or not an attempt should be made.
func TryContext ¶
func TryContext( ctx context.Context, action func(ctx context.Context, attempt uint) error, strategies ...func(attempt uint, err error) bool, ) error
TryContext takes action and performs it, repetitively, until successful. It uses the Context as a Breaker to prevent unnecessary action execution.
Optionally, strategies may be passed that assess whether or not an attempt should be made.
Types ¶
type BreakCloser ¶
type BreakCloser interface { Breaker // Close closes the Done channel and releases resources associated with it. Close() }
A BreakCloser carries a cancellation signal to break an action execution and can release resources associated with it.
It is a subset of github.com/kamilsk/breaker.Breaker.
Directories ¶
Path | Synopsis |
---|---|
Package backoff provides stateless methods of calculating durations based on a number of attempts made.
|
Package backoff provides stateless methods of calculating durations based on a number of attempts made. |
Package jitter provides methods of transforming durations.
|
Package jitter provides methods of transforming durations. |
Package strategy provides a way to change the way that retry is performed.
|
Package strategy provides a way to change the way that retry is performed. |