Skip to content

kisztof/MintGuzzleRetryMiddleware

Repository files navigation

Mint Retry Middleware

Build Status

This is a Guzzle v6 middleware, which retry requests with response status codes 503 or 429 by default, also can retry timeout requests. Both options are configurable. When response provide a Retry-After header, this middleware has option to delay requests by provided time amount.

Features:

  • Automatically retries HTTP requests when a server responds with a configurable statues (429 or 503 by default).
  • Add retry delay based on the Retry-After header.
  • Specify a maximum number of retry attempts.
  • Optional callback when a retry occurs for eg. logging / custom actions.

Require

"php": "~7.1"
"guzzlehttp/guzzle": "^6.0"

Installation

composer require mintsoftware/guzzle_retry_middleware

Configurable options

Option Type Default
\MintSoftware\GuzzleRetry\RetryMiddleware::OPTIONS_RETRY_ENABLED boolean true
\MintSoftware\GuzzleRetry\RetryMiddleware::OPTIONS_MAX_RETRY_ATTEMPTS integer 10
\MintSoftware\GuzzleRetry\RetryMiddleware::OPTIONS_RETRY_AFTER_SECONDS integer 1
\MintSoftware\GuzzleRetry\RetryMiddleware::OPTIONS_RETRY_ONLY_IF_RETRY_AFTER_HEADER boolean false
\MintSoftware\GuzzleRetry\RetryMiddleware::OPTIONS_RETRY_ON_STATUS array 503, 429
\MintSoftware\GuzzleRetry\RetryMiddleware::OPTIONS_CALLBACK callable null
\MintSoftware\GuzzleRetry\RetryMiddleware::OPTIONS_RETRY_ON_TIMEOUT boolean false
\MintSoftware\GuzzleRetry\RetryMiddleware::OPTIONS_RETRY_HEADER string null

Tests

composer test

Contirubtion

Feel free to contribute.

Static Analysis

Code Sniffer

We are using Easy Coding Standard.

composer style-check

To fix errors which can be fixed automatic use:

composer style-fix

PHP Stan

For finding errors we are using PHPStan. Simply run:

composer phpstan

Build

composer build

About

Mint Software Guzzle retry middleware

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages