Skip to content

Latest commit

 

History

History
234 lines (90 loc) · 2.59 KB

RetryMiddleware.md

File metadata and controls

234 lines (90 loc) · 2.59 KB

RetryMiddleware

Middleware that retries requests based on the boolean result of invoking the provided "decider" function.

  • Full name: \GuzzleHttp\RetryMiddleware

Properties

nextHandler

private $nextHandler

decider

private callable $decider

delay

private callable|(int) $delay

Methods

__construct

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

exponentialDelay

Default exponential backoff delay function.

public static exponentialDelay(int $retries): int
  • This method is static.

Parameters:

Parameter Type Description
$retries int

Return Value:

milliseconds.


__invoke

public __invoke(\Psr\Http\Message\RequestInterface $request, array $options): \GuzzleHttp\Promise\PromiseInterface

Parameters:

Parameter Type Description
$request \Psr\Http\Message\RequestInterface
$options array

onFulfilled

Execute fulfilled closure

private onFulfilled(\Psr\Http\Message\RequestInterface $request, array $options): callable

Parameters:

Parameter Type Description
$request \Psr\Http\Message\RequestInterface
$options array

onRejected

Execute rejected closure

private onRejected(\Psr\Http\Message\RequestInterface $req, array $options): callable

Parameters:

Parameter Type Description
$req \Psr\Http\Message\RequestInterface
$options array

doRetry

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