Google Cloud PHP shared dependency, providing functionality useful to all components. Client - Class ExponentialBackoff (1.52.11)

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 \ Core

Methods

__construct

Parameters
NameDescription
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.

Parameters
NameDescription
function callable
arguments array

[optional]

Returns
TypeDescription
mixed

setDelayFunction

If not set, defaults to using usleep.

Parameter
NameDescription
delayFunction callable
Returns
TypeDescription
void

setCalcDelayFunction

Parameter
NameDescription
calcDelayFunction callable
Returns
TypeDescription
void

static::calculateDelay

Calculates exponential delay.

Parameter
NameDescription
attempt int

The attempt number used to calculate the delay.

Returns
TypeDescription
int

Constants

MAX_DELAY_MICROSECONDS

Value: 60000000