grpc-js-xds: Implement ring_hash LB policy #2568
Merged
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.
This implements gRFC A42: xDS Ring Hash LB Policy, with modifications described in gRFC A61 (grpc/proposal#356).
In addition to the changes specified in A42, I had to make the following changes to get ring_hash to work:
channelId
argument, to be hashed in the "CHANNEL_ID" hash policy.xxhash-wasm
dependency has been added.Awaited
utility type used in the loader code forxxhash-wasm
.ResolvingLoadBalancer
,XdsClusterManagerLoadBalancer
, andPriorityLoadBalancer
now consistently delegate to the child when in a connectivity state other thanREADY
.Note: Hash generation only works on Node 15+, because that is when support for
bigint
representations of 64 bit integers from WASM modules was introduced. If the feature is enabled by the environment variable, the library will not work at all on Node 14 and below. For reference, Node 16 is currently the lowest supported LTS version.Experimental API changes:
EndpointMap
, an implementation of severalMap
APIs that considersEndpoint
equality based on the unordered set of addresses. Not efficient.ConfigSelector
function signature has an additional argumentchannelId: number
, which is randomly generated for each channel, and has a consistent value for the lifetime of the channel. Implementations that don't use it can ignore it.QueuePicker
class has an additional optional argumentchildPicker: Picker
, which theQueuePicker
instance will delegate to if provided.