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
OpenFGA\Network
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.
Name | Type | Description |
---|---|---|
$operation |
callable |
|
$config |
array |
mixed
— The result of the successful operation
public function getRetryDelay(int $attempt, array $config = []): int
Get the delay before the next retry attempt.
Name | Type | Description |
---|---|---|
$attempt |
int |
The current attempt number (1-based) |
$config |
array |
int
— The delay in milliseconds
public function isRetryable(Throwable $exception): bool
Determine if an exception is retryable.
Name | Type | Description |
---|---|---|
$exception |
Throwable |
The exception to check |
bool
— True if the operation should be retried, false otherwise