-
-
Notifications
You must be signed in to change notification settings - Fork 83
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
Manual channel handling in client #111
Comments
Hi @alexdupre , if you want a single channel/client to live for the entire app, you can:
Having the channel created and shutdown independently from the client can violate resource safety since the client can be called after the channel is shutdown. You are correct that currently there's no way for two clients to share a single channel, but we can probably change that by introducing a function of the form: Let me know if getting the clients created at the top level helps, or I must have misunderstood what you're trying to do. |
As far as I've understood the use of the layer with In my case I have a dynamic set of servers (all implementing the same set of services) and I need to connect to a different subset of them from time to time, so I need a dynamic set of clients. The sub-optimal things I'm seeing are two:
What I'm probably looking for at a higher abstraction level is a sort of channel manager that all service clients can use. |
A single channel can represent a set of underlying TLS connections that change over time, see Java docs. You can implement your own Channel interface that switches between servers as you need and shares the underlying TCP connection. In other words, a single Channel and a single Client created as a top level layer can still end up talking to any number of servers which you can freely control. |
A single channel can be used to communicate with multiple servers in a load-balancing or fail-over scenario, it doesn't seem the right way to communicate with different servers when you need to target a specific one (ie. when each server is a separate entity with different state). |
Scenario:
I'm quite new to zio and zio-grpc, so I might have missed some obvious things, but as far as I've seen the current implementation is not able to share a channel between two service clients, and doesn't seem to have a friendly way to keep a channel open for more than a
use
block but not for the entire app. The result is that the overhead in establishing multiple TLS connections (while one persistent connection per server would be enough) becomes evident. With the plain java API and scalapb wrapper this is possible, because the channel can be created/shutdown independently from the client. My current workaround is to use the scalapb async wrapper withIO.fromFuture
to have the best from both worlds.Is my analysis correct? Is this something your are going to improve or should I stick with my workaround?
The text was updated successfully, but these errors were encountered: