Documentation
¶
Overview ¶
Package retry provides the most advanced interruptible mechanism to perform actions repetitively until successful.
The retry based on https://github.com/Rican7/retry but fully reworked and focused on integration with the https://github.com/kamilsk/breaker and the built-in https://pkg.go.dev/context package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Do ¶
func Do( breaker Breaker, action func(context.Context) error, strategies ...func(Breaker, uint, error) bool, ) error
Do takes the action and performs it, repetitively, until successful.
Optionally, strategies may be passed that assess whether or not an attempt should be made.
func Go ¶
func Go( breaker Breaker, action func(context.Context) error, strategies ...func(Breaker, uint, error) bool, ) error
Go takes the action and performs it, repetitively, until successful. It differs from the Do method in that it performs the action in a goroutine.
Optionally, strategies may be passed that assess whether or not an attempt should be made.
Types ¶
type Breaker ¶
type Breaker = interface { // Done returns a channel that's closed when a cancellation signal occurred. Done() <-chan struct{} // If Done is not yet closed, Err returns nil. // If Done is closed, Err returns a non-nil error. // After Err returns a non-nil error, successive calls to Err return the same error. Err() error }
A Breaker carries a cancellation signal to interrupt an action execution.
It is a subset of the built-in context and github.com/kamilsk/breaker interfaces.
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 define how retry is performed.
|
Package strategy provides a way to define how retry is performed. |