Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Retry ¶
Retry retries the given function until no error is returned or max retries are reached. f is the function to be retried; it must return an error on failure or nil on success. expRate defines the exponential backoff base duration between retry attempts. maxRetries specifies the maximum number of retry attempts allowed.
The function implements exponential backoff algorithm for retry delays: t = b^c where:
- t is the time delay between retry attempts (in seconds)
- b is the base duration (expRate in seconds)
- c is the retry attempt number (0-based)
Source: https://en.wikipedia.org/wiki/Exponential_backoff
For example, with expRate=2s and maxRetries=4, the delays will be:
- 1st retry: 2^0 = 1s
- 2nd retry: 2^1 = 2s
- 3rd retry: 2^2 = 4s
- 4th retry: 2^3 = 8s
Returns the last encountered error if all retries fail, or nil if the function eventually succeeds.
Types ¶
This section is empty.