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
Implement channel-state API in ManagedChannelImpl #2292
Comments
@zhangkun83 I've talked with @ejona86 about this recently. What design do you have in mind? Simply adding class ManagedChannel {
State getState(boolean tryToConnect);
void notifyWhenStateChanged(State lastObserved, Runnable callback);
} |
@ejona86 has talked with me about that. The idea is that the channel will call It will work in the sense of implementing the channel state API, but I am yet to figure out how it should interact with Conceptually,
Should we allow
I am not sure what you are referring to. |
I mean that API for
That's a tricky one. I'm not sure the In my opinion
I like the idea and with what I wrote above, I think it should be as simple as adding I'm not convinced it should interact with |
And since |
I was confused by you saying that
I mean today's That said, it's not a deal-breaker. We can live with it if we don't have any better options, but I would like to explore other options. |
We don't set state to the Subchannel, because Subchannel manages state on its own. A state getter on Subchannel can race with state changes, and it will be non-trivial to make it right and it won't work well with the serialized threading model of LBv2. |
Yes, that's actually big issue and what I was trying to point out. Results of My point is that I think we can't depend on
Now my question is if @zhangkun83 thoughts? |
@lukaszx0 your confusion is expected. This is because the connectivity state spec is modeled after a single connection or a set of equivalent connections (like in the stock pick-first and round-robin LBs). For those cases the scenario you described should never happen. If the channel works for some requests but not for the others, the spec doesn't define what state the channel should be in as a whole, and we leave the decision to the LB implementation. Because the channel's state is going to be consumed by the user, e.g., for displaying connectivity state on the GUI or for delaying RPCs until the channel is "READY", you should return whatever state you expect your user to see. Discussing this with you has allowed me to re-think my concern that |
Yeah, this is right and is a safe assumption for implementations which don't let provide custom LB implementations (I don't know how C or Go deals with it, I might be wrong and they might be as pluggable as Java).
Yes! Looks like we're on the same page now 😉 I'll take a stab at it later today and we can continue iterating in PR. |
Soooo is it acceptable to just drop this param? Or do we need to have strict API-compat with C version? |
Because round-robin eagerly creates connection, the |
This hasn't been updated in a few months; any chance it'll be in a pretty-soon-ish upcoming release? I'm working on an application where I want mosh-style magical-reconnects as the network comes/goes and AFAIU grpc-java would do that out-of-the-box with keep alives enabled on a ManagedChannel + this API implemented to let my app know when the transport goes up/down. |
The state plumbing in channel has been implemented by #3019, although no |
Nice, thanks @zhangkun83! I don't need load balance support, so I'll start poking around at this. |
To clarify, even if you don't need load balancing, you will be using the default |
ManagedChannel now supports the getState/notifyWhenStateChanged API (grpc#2292).
ManagedChannel now supports the getState/notifyWhenStateChanged API (#2292).
ManagedChannel now supports the getState/notifyWhenStateChanged API (grpc#2292).
ManagedChannel now supports the getState/notifyWhenStateChanged API (#2292).
The API is added by #2286, but is implemented (will throw exception) in ManagedChannelImpl.
The text was updated successfully, but these errors were encountered: