API Network RetryStrategyInterface - evansims/openfga-php GitHub Wiki
Interface for implementing retry strategies. This interface defines the contract for different retry strategies that can be used when operations fail. Implementations can provide various retry algorithms such as exponential backoff, linear retry, or custom strategies based on specific requirements.
Table of Contents
OpenFGA\Network
public function execute(callable $operation, array<string, mixed> $config = []): T
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< string, mixed>
|
T
— The result of the successful operation
public function getRetryDelay(int $attempt, array<string, mixed> $config = []): int
Get the delay before the next retry attempt.
Name | Type | Description |
---|---|---|
$attempt |
int |
The current attempt number (1-based) |
$config |
array< string, mixed>
|
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