lemonde/php-circuit-breaker-bundle

This package is abandoned and no longer maintained. No replacement package was suggested.

Circuit breaker to symfony

1.1.1 2017-06-06 10:44 UTC

This package is not auto-updated.

Last update: 2023-08-19 14:29:33 UTC


README

Build Status Build Status Scrutinizer Code Quality Code Coverage

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