RetryMiddleware
extends AbstractMiddleware
in package
Middleware for retrying failed requests with exponential backoff
Table of Contents
Properties
- $config : array<string, mixed>
Methods
- __construct() : mixed
- __invoke() : callable
- Get the Guzzle middleware callable
- configure() : void
- Set configuration for the middleware
- getName() : string
- Get the name of the middleware
- getConfig() : mixed
- Get a configuration value
- getDefaultConfig() : array<string, mixed>
- Get default configuration for the middleware
- calculateDelay() : int
- Calculate the delay before the next retry
- doRetry() : PromiseInterface
- Perform the retry
- isCanvasRateLimit() : bool
- Check if a 403 response is a Canvas rate limit error
- shouldRetry() : bool
- Determine if the request should be retried
Properties
$config
protected
array<string, mixed>
$config
= []
Methods
__construct()
public
__construct([array<string, mixed> $config = [] ]) : mixed
Parameters
- $config : array<string, mixed> = []
__invoke()
Get the Guzzle middleware callable
public
__invoke() : callable
Tags
Return values
callableconfigure()
Set configuration for the middleware
public
configure(array<string|int, mixed> $config) : void
Parameters
- $config : array<string|int, mixed>
Tags
getName()
Get the name of the middleware
public
getName() : string
Tags
Return values
stringgetConfig()
Get a configuration value
protected
getConfig(string $key[, mixed $default = null ]) : mixed
Parameters
- $key : string
- $default : mixed = null
getDefaultConfig()
Get default configuration for the middleware
protected
getDefaultConfig() : array<string, mixed>
Tags
Return values
array<string, mixed>calculateDelay()
Calculate the delay before the next retry
private
calculateDelay(int $attempt) : int
Parameters
- $attempt : int
Return values
int —Delay in milliseconds
doRetry()
Perform the retry
private
doRetry(RequestInterface $request, callable $handler, array<string, mixed> $options) : PromiseInterface
Parameters
- $request : RequestInterface
- $handler : callable
- $options : array<string, mixed>
Return values
PromiseInterfaceisCanvasRateLimit()
Check if a 403 response is a Canvas rate limit error
private
isCanvasRateLimit(ResponseInterface $response) : bool
Parameters
- $response : ResponseInterface
Return values
boolshouldRetry()
Determine if the request should be retried
private
shouldRetry(int $attempt, ResponseInterface|null $response, mixed $reason) : bool
Parameters
- $attempt : int
- $response : ResponseInterface|null
- $reason : mixed