Listener to control the change of the circuit state
I would like to know if you have in the roadmap the implementation of some kind of listener to control the state changes of the circuits, I think it is very interesting and especially useful for metric control.
Would you be open to any kind of contribution?.
We have been develop a first version using inheritance.
def state_change(self, old_state, new_state):
# Called when the circuit breaker state changes.
pass
def before_callfunc(self, func, *args, **kwargs):
# Called before the circuit breaker decorated function has been called
pass
def succes(self):
# Called when the circuit breaker decorated function finished ok"
pass
def failure(self, exc_type, exc_value, _traceback):
# Called when the circuit breaker decorated function finished with selected exception"
pass
Best regards
I've been looking for something like this as well. Would be great to be able to send notifications when a circuit changes state for monitoring purposes...
Just in case, I noticed that there is a competing library called pybreaker that implements that feature: https://github.com/danielfm/pybreaker#event-listening
EDIT: the other library doesn't seem to support coroutines, this one does!
Just in case, I noticed that there is a competing library called
pybreakerthat implements that feature: https://github.com/danielfm/pybreaker#event-listeningEDIT: the other library doesn't seem to support coroutines, this one does!
The interface we have been testing to contribute is similar to pybreaker but instead of listener we use inheritance.