danielfm / pybreaker

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

Should `current_state` respect `reset_timeout`? #15

Open phillbaker opened 7 years ago

phillbaker commented 7 years ago

We currently monitor the state of several circuit breakers via the current_state attribute. However, we've noticed that if some of these connections have spiky traffic and trip the breaker, they can stay in the open state until another request is made which clears the state.

The breaker itself is operating as expected, however, our monitoring records in correct data. What do you think of including a check of _state_storage.opened_at in current_state? We're including this check in our code currently, but if this behavior at the library level seems incorrect I can open a PR.

danielfm commented 7 years ago

Whether this behavior is correct can be questioned, but it surely is expected; since the circuit only opens and closes as response to succeeded/failed calls, if there are no calls, the circuit will stay in its current state.

I think it won't hurt to add the opened_at metadata, but I wouldn't change the circuit state based on this information.