Documentation ¶
Index ¶
- Constants
- func Retry(f Retryable) error
- type Backoff
- func (b Backoff) Retry(f Retryable) error
- func (b *Backoff) WithMaxIterationTime(v time.Duration) *Backoff
- func (b *Backoff) WithMaxIterations(v uint64) *Backoff
- func (b *Backoff) WithMaxTotalTime(v time.Duration) *Backoff
- func (b *Backoff) WithMinIterationTime(v time.Duration) *Backoff
- func (b *Backoff) WithMultiplier(v float64) *Backoff
- type Retryable
Constants ¶
const ( // Default value to use for number of iterations: infinite DefaultMaxIterations uint64 = 0 // Default value to use for maximum iteration time DefaultMaxIterationTime = 60 * time.Second // Default value to use for maximum execution time: infinite DefaultMaxTotalTime time.Duration = 0 // Default value to use for initial iteration time DefaultMinIterationTime = 100 * time.Millisecond // Default multiplier to apply to iteration time after each iteration DefaultMultipler float64 = 1.5 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Backoff ¶
type Backoff struct { MaxIterations uint64 MaxIterationTime time.Duration MaxTotalTime time.Duration MinIterationTime time.Duration Multiplier float64 }
Backoff holds the configuration for backoff function retries
func NewBackoff ¶
func NewBackoff() *Backoff
NewBackoff creates a new Backoff configuration with default values (see constants)
func (Backoff) Retry ¶
Retry executes the function and waits for it to end successul or for the given limites to be reached. The returned error uses Go1.13 wrapping of errors and can be unwrapped into the error of the function itself.
func (*Backoff) WithMaxIterationTime ¶ added in v2.11.0
WithMaxIterationTime is a wrapper around setting the MaxIterationTime and then returning the Backoff object to use in chained creation
func (*Backoff) WithMaxIterations ¶ added in v2.11.0
WithMaxIterations is a wrapper around setting the MaxIterations and then returning the Backoff object to use in chained creation
func (*Backoff) WithMaxTotalTime ¶ added in v2.11.0
WithMaxTotalTime is a wrapper around setting the MaxTotalTime and then returning the Backoff object to use in chained creation
func (*Backoff) WithMinIterationTime ¶ added in v2.11.0
WithMinIterationTime is a wrapper around setting the MinIterationTime and then returning the Backoff object to use in chained creation
func (*Backoff) WithMultiplier ¶ added in v2.11.0
WithMultiplier is a wrapper around setting the Multiplier and then returning the Backoff object to use in chained creation