ksaveras / guzzle-circuit-breaker-middleware
1.0.1
2023-06-25 09:50 UTC
Requires
- php: ^8.1
- guzzlehttp/guzzle: ^6.0|^7.0
- ksaveras/circuit-breaker: ^2.0.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.19
- phpstan/phpstan: ^1.10
- phpstan/phpstan-phpunit: ^1.3
- phpunit/phpunit: ^10.2
- rector/rector: ^0.17.1
README
Installation
composer require ksaveras/guzzle-circuit-breaker-middleware
Use
It's recommended to use CB (Circuit Breaker) Middleware on top of the stack, but after the cache middleware if you use any. This allows to utilize the cache layer and fail fast when the service is not available.
use GuzzleHttp\Client; use GuzzleHttp\HandlerStack; use Ksaveras\GuzzleCircuitBreakerMiddleware\CircuitBreakerMiddleware; // $factory is instance of CircuitBreakerFactory $middleware = new CircuitBreakerMiddleware($factory->create('CB Name')); $handlerStack = HandlerStack::create(); $handlerStack->push($middleware); $client = new Client(['handler' => $handlerStack]);
Tests
composer test
Code quality
composer static-analysis