Reference documentation and code samples for the Google Cloud PHP shared dependency, providing functionality useful to all components. Client class ExponentialBackoff.
Exponential backoff implementation.
Namespace
Google \ Cloud \ CoreMethods
__construct
retries
int
[optional] Number of retries for a failed request.
retryFunction
callable
[optional] returns bool for whether or not to retry
retryListener
callable
[optional] Runs after the $retryFunction. Unlike the $retryFunction,this function isn't responsible to decide if a retry should happen or not, but it gives the users flexibility to consume exception messages and add custom logic. Function definition should match: function (\Exception $e, int $attempt, array $arguments): array Ex: One might want to change headers on every retry, this function can be used to achieve such a functionality.
execute
Executes the retry process.
function
callable
arguments
array
[optional]
mixed
setDelayFunction
If not set, defaults to using usleep
.
delayFunction
callable
void
setCalcDelayFunction
If not set, defaults to using ExponentialBackoff::calculateDelay() .
calcDelayFunction
callable
void
static::calculateDelay
Calculates exponential delay.
attempt
int
The attempt number used to calculate the delay.
int
Constants
MAX_DELAY_MICROSECONDS
Value: 60000000