Utils
in package
Table of Contents
Methods
- withExponentialBackoff() : the
- The function `withExponentialBackoff` retries a given callback function with an increasing delay between retries, up to a maximum number of retries and maximum delay time.
Methods
withExponentialBackoff()
The function `withExponentialBackoff` retries a given callback function with an increasing delay between retries, up to a maximum number of retries and maximum delay time.
public
static withExponentialBackoff(callable $cb[, int $maxRetries = 5 ][, int $maxMs = 64 * 1000 ][, int $baseMs = 250 ]) : the
NOTE: Please return a non-empty value from the callback function or the function will continue to retry until it reaches the maximum number of retries.
Parameters
- $cb : callable
-
The
cb
parameter is a callable function or method that will be executed within thewithExponentialBackoff
function. It is the code that you want to retry with exponential backoff. - $maxRetries : int = 5
-
The
maxRetries
parameter specifies the maximum number of times the callback function will be retried before giving up. - $maxMs : int = 64 * 1000
-
The
maxMs
parameter represents the maximum backoff time in milliseconds. It determines the maximum amount of time to wait between retries. In the provided code, themaxMs
value is set to64 * 1000
, which means the maximum backoff time is 64 seconds. - $baseMs : int = 250
-
The baseMs parameter represents the initial delay in milliseconds before the first retry attempt.
Return values
the —result of the callback function.