API Network ExponentialBackoffRetryStrategy - evansims/openfga-php GitHub Wiki

Exponential backoff retry strategy implementation. This strategy implements exponential backoff with jitter for retrying failed operations. It increases the delay between retries exponentially to reduce load on the server during failure scenarios, while adding random jitter to prevent thundering herd problems.

Table of Contents


Namespace

OpenFGA\Network


Source

View source code


Implements


Methods

execute

public function execute(callable $operation, array $config = []): mixed

Execute an operation with retry logic. Executes the given operation and retries it according to the strategy's implementation if it fails. The strategy determines when to retry, how long to wait between retries, and when to give up.

View source


Parameters

Name Type Description
$operation callable
$config array

Returns

mixed — The result of the successful operation


getRetryDelay

public function getRetryDelay(int $attempt, array $config = []): int

Get the delay before the next retry attempt.

View source


Parameters

Name Type Description
$attempt int The current attempt number (1-based)
$config array

Returns

int — The delay in milliseconds


isRetryable

public function isRetryable(Throwable $exception): bool

Determine if an exception is retryable.

View source


Parameters

Name Type Description
$exception Throwable The exception to check

Returns

bool — True if the operation should be retried, false otherwise

⚠️ **GitHub.com Fallback** ⚠️