RetryMiddleware
in package
Builds the decider/delay pair for GuzzleHttp\Middleware::retry -- exponential backoff with jitter on a 429 or 5xx, honoring a server-sent Retry-After (seconds or an HTTP-date, RFC 9110 section 10.2.3) ahead of the computed backoff, and never retrying any other 4xx (rules/sdk-generation.md's "Client shape").
Table of Contents
Properties
- $baseDelaySeconds : float
- $maxRetries : int
Methods
- __construct() : mixed
- decider() : callable(int, RequestInterface, Array=, mixed=): bool
- Guzzle calls this with the raw rejection reason as its fourth argument (untyped -- GuzzleHttp\RetryMiddleware itself only documents it as `mixed`), which in practice is always a Throwable for an HTTP middleware chain -- a ConnectException for a network-level failure before any response arrived, or nothing at all when a response (even an error one) came back, since the retry middleware sits closer to the transport than Guzzle's http_errors middleware and sees the raw response first.
- delay() : callable(int, Array=): int
- retryAfterMillis() : int|null
Properties
$baseDelaySeconds
private
float
$baseDelaySeconds
= 0.25
$maxRetries
private
int
$maxRetries
= 3
Methods
__construct()
public
__construct([int $maxRetries = 3 ][, float $baseDelaySeconds = 0.25 ]) : mixed
Parameters
- $maxRetries : int = 3
- $baseDelaySeconds : float = 0.25
decider()
Guzzle calls this with the raw rejection reason as its fourth argument (untyped -- GuzzleHttp\RetryMiddleware itself only documents it as `mixed`), which in practice is always a Throwable for an HTTP middleware chain -- a ConnectException for a network-level failure before any response arrived, or nothing at all when a response (even an error one) came back, since the retry middleware sits closer to the transport than Guzzle's http_errors middleware and sees the raw response first.
public
decider() : callable(int, RequestInterface, Array=, mixed=): bool
Return values
callable(int, RequestInterface, Array=, mixed=): booldelay()
public
delay() : callable(int, Array=): int
Return values
callable(int, Array=): int —Delay in milliseconds -- the unit GuzzleHttp\Middleware::retry expects. Guzzle itself calls this with a third $request argument too; it's irrelevant to the delay calculation and safely dropped.
retryAfterMillis()
private
retryAfterMillis(ResponseInterface $response) : int|null
Parameters
- $response : ResponseInterface