Conversation
Applications that route work by hashring key need to know which member owns a key before they dial. One example is a batch: to group the items by owner, the caller must query the ring. The ring lives inside the balancer, and gRPC constructs balancers lazily and internally, so callers had no way to reach it. The builder is the rendezvous point. RingFor(target) returns a stable RingView handle with these properties: - Callers can get a view before any balancer exists for the target. - A view returns ErrNoRing until its balancer publishes a ring. - A view follows ring replacements (ReplicationFactor changes). - A view shows membership changes as they happen. - A view empties again when its balancer closes. A view reads the same ring object that the picker routes with, so callers and the picker agree on ownership. The one exception is a membership change that races the query.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
Applications that route work by hashring key need to know which member owns a key before they dial. One example is a batch: to group the items by owner, the caller must query the ring. The ring lives inside the balancer, and gRPC constructs balancers lazily and internally, so callers had no way to reach it.
The concrete motivation is object-based dispatch in SpiceDB: a Check dispatch carries up to 100 resource IDs, and routing by object requires the dispatcher to group those IDs by ring owner before it sends one RPC per owner.
Change
The builder is the rendezvous point, because the application already holds it.
RingFor(target)returns a stableRingViewhandle with these properties:ErrNoRinguntil its balancer publishes a ring.A view reads the same ring object that the picker routes with, so callers and the picker agree on ownership. The one exception is a membership change that races the query, which costs locality for that one request, never delivery.
RingForis a new method on theBuilderinterface. That breaks external implementers of the interface. Callers ofNewBuilderare unaffected.Tests
Six new tests cover the view lifecycle: before the balancer exists, against the live ring, across membership changes, across ring replacement, after
Close, and across two targets. The suite passes with-race.