Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Listener to control the change of the circuit state #60

Open
sergioave opened this issue Sep 21, 2023 · 3 comments
Open

Listener to control the change of the circuit state #60

sergioave opened this issue Sep 21, 2023 · 3 comments

Comments

@sergioave
Copy link

sergioave commented Sep 21, 2023

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

@ramykl
Copy link

ramykl commented Sep 25, 2023

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...

@eliasdorneles
Copy link

eliasdorneles commented Sep 26, 2023

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!

@sergioave
Copy link
Author

sergioave commented Sep 27, 2023

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!

The interface we have been testing to contribute is similar to pybreaker but instead of listener we use inheritance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants