lemonde / php-circuit-breaker-bundle
Circuit breaker to symfony
Installs: 1 278
Dependents: 0
Suggesters: 0
Security: 0
Stars: 11
Watchers: 43
Forks: 3
Open Issues: 1
Type:bundle
Requires
- php: >=7
- symfony/config: ~3.2
- symfony/http-kernel: ~3.0
Requires (Dev)
- phpunit/phpunit: ^5.4
This package is not auto-updated.
Last update: 2023-08-19 14:29:33 UTC
README
Description
Everything is MIT licensed and unsupported unless otherwise stated. Use at your own risk.
Implement circuit breaker pattern see here http://martinfowler.com/bliki/CircuitBreaker.html.
You can find explanation in french here https://medium.com/eleven-labs/le-circuit-breaker-k%C3%A9sako-4763e13a4a03
How to install ?
Requirements
-
=PHP 7
- use LoggerInterface
- use CacheInterface
composer require lemonde/php-circuit-breaker-bundle:lastest
Add in your AppKernel.php
public function registerBundles() { $bundles = [ .... new CircuitBreakerBundle\CircuitBreakerBundle(), ]; return $bundles; }
Add in your config.yml
circuit_breaker: # Number fail possible in circuit breaker threshold: 5 # Time in seconds resend call after circuit breaker is open timeout: 20
And add config to CacheInterface in your config.yml
framework: cache: app: cache.adapter.filesystem
How to use ?
Before your service's call
if ($this->get('circuit.breaker')->isOpen('your-service')) { // If service is down }
You need to send status on service to each call
// $status is bool $this->get('dispatcher')->dispatch('circuit.breaker', new CircuitBreakerEvent('your-service', $status));
How to contribute ?
You can add issue, and create pull request. https://github.com/lemonde/php-circuit-breaker-bundle/blob/master/.github/CONTRIBUTING.md