danielfm / pybreaker

Python implementation of the Circuit Breaker pattern.
BSD 3-Clause "New" or "Revised" License
508 stars 74 forks source link

define two CircuitBreaker problem #88

Open Mahdi-Ba opened 7 months ago

Mahdi-Ba commented 7 months ago

I define two CircuitBreaker But if one of them changes the state of all CircuitBreaker change!!! I think , need to change the code when set in Redis and use the name of CircuitBreaker to solve it

breaker = pybreaker.CircuitBreaker(name='breaker', fail_max=3, reset_timeout=2, listeners=[NotifyListener()],
                                   state_storage=pybreaker.CircuitRedisStorage(pybreaker.STATE_CLOSED, redis))

other_breaker = pybreaker.CircuitBreaker(name='other_breaker', fail_max=3, reset_timeout=2, listeners=[NotifyListener()],
                                   state_storage=pybreaker.CircuitRedisStorage(pybreaker.STATE_CLOSED, redis))
danielfm commented 7 months ago

I think you need to specify different namespace names for each Redis storage.

https://github.com/danielfm/pybreaker/blob/1ea4fd7a8705eb43d85251b20341b185bedc87dc/src/pybreaker/__init__.py#L517

Maybe the docs should have been more clear about this. If you wish to contribute some improvements in that area, I'd be more than glad to accept.