Middleware that retries requests based on the boolean result of invoking the provided "decider" function.
- Full name:
\GuzzleHttp\RetryMiddleware
private $nextHandler
private callable $decider
private callable|(int) $delay
public __construct(callable $decider, callable $nextHandler, callable $delay = null): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$decider |
callable | Function that accepts the number of retries, a request, [response], and [exception] and returns true if the request is to be retried. |
$nextHandler |
callable | |
$delay |
callable |
Default exponential backoff delay function.
public static exponentialDelay(int $retries): int
- This method is static.
Parameters:
Parameter | Type | Description |
---|---|---|
$retries |
int |
Return Value:
milliseconds.
public __invoke(\Psr\Http\Message\RequestInterface $request, array $options): \GuzzleHttp\Promise\PromiseInterface
Parameters:
Parameter | Type | Description |
---|---|---|
$request |
\Psr\Http\Message\RequestInterface | |
$options |
array |
Execute fulfilled closure
private onFulfilled(\Psr\Http\Message\RequestInterface $request, array $options): callable
Parameters:
Parameter | Type | Description |
---|---|---|
$request |
\Psr\Http\Message\RequestInterface | |
$options |
array |
Execute rejected closure
private onRejected(\Psr\Http\Message\RequestInterface $req, array $options): callable
Parameters:
Parameter | Type | Description |
---|---|---|
$req |
\Psr\Http\Message\RequestInterface | |
$options |
array |
private doRetry(\Psr\Http\Message\RequestInterface $request, array $options, \Psr\Http\Message\ResponseInterface $response = null): \GuzzleHttp\Promise\PromiseInterface
Parameters:
Parameter | Type | Description |
---|---|---|
$request |
\Psr\Http\Message\RequestInterface | |
$options |
array | |
$response |
\Psr\Http\Message\ResponseInterface |