feat(transport): Connect lazily in the load balanced channel #493
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
If the first connection to the endpoint in an
Insert
changeset fails, the service goes into a failed state and the channel is dropped:This is not coherent with the behavior we observe if the connection is broken after having successfully connected at least once - the channel remains open and we try to reconnect without disrupting calls.
Solution
The current PR makes the connection step lazy by default in the load balanced channel.
An alternative approach would be to allow the caller to choose if it should connect eagerly (and crash if the first connection fails) or be lazy - maybe as an additional parameter on
balance_channel
? Or abalance_channel_lazy
? Or alazy
property on theEndpoint
?Why are we touching this?
We have been trying to build a client-side load balanced gRPC client on top of
tonic
load balanced channel using a background task probing the DNS on a schedule. We'd be happy to add it as an example totonic
itself (including the test that got us here 😅 )