-
Notifications
You must be signed in to change notification settings - Fork 4k
Description
Is your feature request related to a problem?
gRPC usage within our organization requires creation of several managed channels, each with a unique authority, for various endpoints within the same server app. This leads to creation of multiple redundant HTTP/2 connections that could've just been re-used. The current NettyChannelBuilder impl doesn't feature any option to enable transport level connection re-use.
Describe the solution you'd like
NettyChannelBuilder currently defines NettyTransportFactory as a nested class and the implementation spawns a new NettyClientTransport each time it's called.
I'd like to:
- Add a new method to
NettyChannelBuilderthat allows injecting a customClientTransportFactoryBuilder. If this is too much flexibility, then we can just add a new method to enable connection re-use. - Create a new implementation of
ClientTransportFactorythat returns a preexisting (if available) NettyClientTransport wrapped by a new decorator. The decorator object will ensure that methods like start will still provide appropriate lifecycle notifications to the supplied listeners.
Describe alternatives you've considered
We tried re-using subchannels within the loadbalancer but it isn't clean. For e.g., the synchronization context isn't shared across different loadbalancer objects.
Additional context
If the gRPC maintainers see value in this addition and agree with the proposed approach, I can send a PR for this feature soon.