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


Namespace

OpenFGA\Network


Source

View source code


Methods

execute

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.

View source


Parameters

Name Type Description
$operation callable
$config array&lt;string, mixed&gt;

Returns

T — The result of the successful operation


getRetryDelay

public function getRetryDelay(int $attempt, array<string, mixed> $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&lt;string, mixed&gt;

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** ⚠️