-
Notifications
You must be signed in to change notification settings - Fork 185
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
two-step pass check and outcome reporting #4
Comments
Sorry for the late reply. You can use goroutines in the
So I think it's not necessary to add new methods. Could you show a concrete use case for the 2-step way? |
my use case: i have "filters" in a router processing requests and responses before forwarding them, both on the request and response path. They behave a somewhat similar alternative way to chaining standard handlers, when a handler calls the next one, but the difference is that these filters don't know about each other. These filters are small stateless (typically) middleware, not knowing about the outside world. I want to implement the circuit breaker as such a filter. A filter has a Request(Context) and Response(Context) method, and has no notion about the overall control flow. On the request path, I want to check the breaker if a request can proceed and signal to the controlling logic to block if the breaker is open. On the response path, I want to register the outcome of the forwarded request. in very a simplified way, it would look like this:
Of course, i could just put a breaker in the controlling logic, and then the current interface of the gobreaker would be enough. But I want to allow to set different breaker configuration for different routes, and the way in my project of configuring these routes is to apply filters with different settings. (https://github.com/zalando/skipper) The problems with the additional go routines that you're suggesting would be:
As you see in my pull request #5 , this can done without changing the internal logic of gobreaker, only by exporting functionality that is already available in it. |
Thanks. I understand your use case. I’d like to hide internal implementation stuff like
Allow returns the closure
Do you have any other suggestion? |
This sounds good to me. I like that the 'generation' concept is not leaked out this way. I am closing my PR. |
Thank you for your PR. I have merged it. |
thanks 👍 |
Hi, I'd like to have the possibility to check if a request can pass through and setting the outcome in separate steps, outside the
Execute()
method. This would be possible if the breaker had the following additional methods:Allow() bool
: would tell if the breaker is closed, or, in half open state, can the request pass through.Success()
: report a successful outcomeFailure()
: report a failed outcomeAllow()
would be basically a visible wrapper aroundbeforeRequest()
, whileFailure()
andSuccess()
aroundafterRequest()
.This would enable using the breaker in an asynchronous way, where the check for passing and reporting the outcome are not in a single control flow.
I'd be happy to make a pull request.
The text was updated successfully, but these errors were encountered: