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

Support event listener of circuit breaker state change event #951

Closed
huangxfchn opened this issue Jul 31, 2019 · 7 comments · Fixed by #1490
Closed

Support event listener of circuit breaker state change event #951

huangxfchn opened this issue Jul 31, 2019 · 7 comments · Fixed by #1490
Assignees
Labels
area/circuit-breaking Issues or PRs related to circuit breaking good first issue Good for newcomers kind/feature Category issues or prs related to feature request.
Milestone

Comments

@huangxfchn
Copy link
Contributor

For example, if sentinel start to switch off, then can call back an interface to notify the application. The same is true when sentinel is out of circuit breaker mode.

@sentinel-bot sentinel-bot added kind/feature Category issues or prs related to feature request. kind/notice Some notice issue sent from project labels Jul 31, 2019
@sczyh30 sczyh30 added kind/question Category issues related to questions or problems and removed kind/feature Category issues or prs related to feature request. kind/notice Some notice issue sent from project labels Jul 31, 2019
@sczyh30
Copy link
Member

sczyh30 commented Jul 31, 2019

In fact, Sentinel has provided callback support for StatisticSlot:

  • ProcessorSlotEntryCallback: callback when resource entry passed (onPass) or has been blocked (onBlocked)
  • ProcessorSlotExitCallback: callback when resource entry successfully exited (onExit)

We can register your own callback via StatisticSlotCallbackRegistry. Maybe here we can just leverage the onBlocked callback to handle the rule trigger alarm. You could get the triggered rule from the BlockException.

You may also refer to #418

@huangxfchn
Copy link
Contributor Author

Looks a bit like.

I need to catch DegradeException, and determine the count = = 1 representative to downgrade strategy, but onBlocked method should be invoked after the circuit breaker mode, this method was invoked every time during until out of fusing time window. Is that right?

So, what if I knew when to jump out of the circuit breaker mode.

@sczyh30
Copy link
Member

sczyh30 commented Aug 3, 2019

You mean notification for circuit breaker CLOSE event? This hasn't been supported yet, but it seems helpful. Maybe we could provide a listener registry for circuit breaker state change events. We could discuss the design here.

@sczyh30 sczyh30 added area/circuit-breaking Issues or PRs related to circuit breaking kind/discussion For further discussion kind/feature Category issues or prs related to feature request. and removed kind/question Category issues related to questions or problems labels Aug 3, 2019
@sczyh30 sczyh30 changed the title Are there plans to develop Degrade notice feature? Support event listener of circuit breaker state change event Aug 3, 2019
@huangxfchn
Copy link
Contributor Author

Yeah, circuit breaker START and CLOSE event.

@sczyh30 sczyh30 added good first issue Good for newcomers and removed kind/discussion For further discussion labels Aug 8, 2019
@linlinisme
Copy link
Collaborator

I am doing something like that, may be it can assign to me.

@sczyh30
Copy link
Member

sczyh30 commented Aug 12, 2019

I am doing something like that, maybe it can assign to me.

Nice, looking forward to your PR~

@sczyh30
Copy link
Member

sczyh30 commented Jul 30, 2020

The CircuitBreakerStateChangeObserver will be available in 1.8.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/circuit-breaking Issues or PRs related to circuit breaking good first issue Good for newcomers kind/feature Category issues or prs related to feature request.
Projects
None yet
4 participants