grpc-js: Add ChildLoadBalancerHandler and use it for refactoring #1406
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.
The
ChildLoadBalancerHandler
encapsulates the logic of taking a newLoadBalancingConfig
that may be for a different load balancer type than the one currently in use, and performing the switchover when the new balancer becomes ready. The behavior should be identical to the corresponding core class. This allows that behavior to be factored out of theResolvingLoadBalancer
class, and it will also be used by future load balancer types likepriority
andweighted_target
.With that logic factored out of
ResolvingLoadBalancer
, thereplaceChannelControlHelper
method on theLoadBalancer
type is no longer used anywhere, so it can be removed entirely, and thechannelControlHelper
constructor argument and private member can be madereadonly
for a stronger guarantee.The
LoadBalancingConfig
type is modified to much more closely match theoneof
type in the protobuf definition, and thename
attribute makes it much easier to check which type a givenLoadBalancingConfig
is.The
priority
load balancing config types are in here because this PR was originally adding that load balancer implementation and I didn't feel like extracting that from the rest of the changes to that file.One thing to note: with this change, we no longer remove child load balancers that go IDLE. I think that is no longer necessary because I have since fixed the bugs with making those load balancers leave IDLE, and this change makes the logic simpler.