GithubHelp home page GithubHelp logo

circuit-breaker's People

Contributors

dav-m85 avatar eljam avatar garak avatar guilhermednt avatar vasseur-bax avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

circuit-breaker's Issues

Provide a more realistic example

Documentation is currently providing a single example, that doesn't explain so much.
The example mentions a GitHub API, but then no reference to any call is shown in the code (not even in an abstract way, e.g. via code comments).

Can I throw an exception without opening the circuit breaker?

tl;dr: add a list of "allowed exceptions" that will be thrown without opening the circuit.

I'm using this lib to, among other things, protect the interaction with my SMS service.

This service eventually throws some validation exceptions like InvalidCountryException when the phone I try to text is not within the list of supported/allowed countries.

I'd like to catch this exception without opening the circuit since the service itself didn't actually fail.

Do you think this would make sense? If so I can arrange the PR so you don't have to bother with it.

BTW, do you have some way I could donate you a coffee?

Thanks for the lib!

PHP 5.4 compatibility

Any chance you'd be willing to make this PHP 5.4-compatible?

I'm currently using ejsmont-artur/php-circuit-breaker but your solution seems more elegant and I'd like to give it a try.

(I know 5.4 is dead, but Red Hat insists on using it and in my company they don't allow installing anything that is not Red Hat-approved -- they won't even use Red Hat Software Collections, go figure...)

Replace AbstractAdapter with AdapterInterface

The current implementation of Breaker class requires to inject \Symfony\Component\Cache\Adapter\AbstractAdapter.
I think it should type hint for more generic \Symfony\Component\Cache\Adapter\AdapterInterface, since the concrete object makes harder to use dependency injection (for example, with Symfony).

I can provide a PR.

Breaker Box to collect them all

It would be nice to have a Breaker Box / Panel where you can retrieve all declared Breakers and be able to fetch their status. I'm currently working on an UX that would allow people to close/open Breaker manually, and solely relying on events is not possible. Would go like this:

$breaker = new Breaker("some_breaker");
$breakerBox = new BreakerBox();
$breakerBox->add($breaker);
foreach ($breakerBox->getBreakers() as $name) {
    $breakerBox->isOpen($name); // let's say it is false
    $breakerBox->close($name); // use its own writeToStore function to update the Breaker's Circuit
    $breakerBox->isOpen($name); // now it would be true

By cleverly using bind(..., Breaker::class), BreakerBox would be able to access Handler and Circuit of a Breaker without changing its interface contract.

I know it's kinda replicating the Feature Flag here, and before working on a PR, I'm pinging to know if it's the intended direction for this repo.

Btw your quite high on libraries.io for php circuit breakers, good job pal !

Events are dispatched in legacy mode

Events should be dispatched using the object as the first argument (and maybe the name as the second argument, for legacy compatibility).
The current implementation of dispatching names as the first argument is incompatible with modern libraries/frameworks.

I can provide a PR.

Cache::contains() not reliable?

I've noticed Doctrine's Cache::contains() is always returning true when using MemcacheCache.

    // on Breaker.php
    protected function loadCircuit($name)
    {
        if ($this->store->contains($name)) {
            $circuit = $this->store->fetch($name); // always true when using MemcacheCache
        } else {
            $circuit = new Circuit($name);
        }
    // ...

Would it be a problem if we just checked for a false response on fetch() or are there known issues with other cache drivers?

It seems this would not be a problem:

@return mixed The cached data or FALSE, if no cache entry exists for the given id.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.