Documentation ¶
Overview ¶
Package try provides a set of functions to retry a function with a delay.
nolint: ireturn
Index ¶
- func Do(tries int, delay time.Duration, fn func() error) (err error)
- func DoExponentialBackoff(tries int, delay time.Duration, multiplier time.Duration, ...) (err error)
- func DoExponentialBackoffWithResult[T any](tries int, delay time.Duration, multiplier int, maxBackoff time.Duration, ...) (result T, err error)
- func DoWithResult[T any](tries int, delay time.Duration, fn func(try int) (T, error)) (result T, err error)
- func GenerateDelays(tries int, delay time.Duration, multiplier time.Duration, ...) []time.Duration
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Do ¶
Do tries a function with a delay.
To avoid any deadlock, the function will stop if the errors is context.Canceled or context.DeadlineExceeded.
func DoExponentialBackoff ¶
func DoExponentialBackoff( tries int, delay time.Duration, multiplier time.Duration, maxBackoff time.Duration, fn func() error, ) (err error)
DoExponentialBackoff tries a function with exponential backoff.
To avoid any deadlock, the function will stop if the errors is context.Canceled or context.DeadlineExceeded.
func DoExponentialBackoffWithResult ¶
func DoExponentialBackoffWithResult[T any]( tries int, delay time.Duration, multiplier int, maxBackoff time.Duration, fn func() (T, error), ) (result T, err error)
DoExponentialBackoffWithResult performs an exponential backoff and return a result.
To avoid any deadlock, the function will stop if the errors is context.Canceled.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.