-
Notifications
You must be signed in to change notification settings - Fork 14
Use iterators in place of QuorumSpec quorum functions. #230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Conversation
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
Contributor
|
Here's the code health analysis summary for commits Analysis Summary
|
meling
added a commit
that referenced
this pull request
Nov 27, 2025
This changes the iterator API from iter.Seq2[uint32, Result[T]] to a cleaner iter.Seq[Result[T]] pattern, and a type alias Results[T] which can serve as receiver for methods on said iterator. This simplifies the API by consolidating node ID and result information into a single Result[T] value, making iteration more ergonomic, despite not following Go's function-based iterator patterns. Key changes: - Introduce Results[T] type alias for iter.Seq[Result[T]] - Change ClientCtx.Responses() return type from iter.Seq2 to Results[T] - Update iterator helper methods to be methods on Results[T]: * IgnoreErrors() now returns Results[T] instead of iter.Seq2[uint32, T] * Add Filter() method for generic result filtering * CollectN() and CollectAll() now methods on Results[T] - Update all iterator consumers to use single-value iteration pattern - Constrain ClientCtx type parameters to msg (proto.Message) type Benefits: - Simpler iteration: `for result := range ctx.Responses()` vs `for nodeID, result := range ctx.Responses()` - More composable: method chaining like `ctx.Responses().IgnoreErrors().CollectAll()` - Consistent: Result[T] already contains NodeID, no need to pass separately - Cleaner: Filter() operates on complete Result[T] values This borrows from Asbjørn Salhus's design in PR #230, which I now agree is better than Go's function-based iterator pattern because of its significantly better composability. That is, you avoid composing with functions that would look like: gorums.IgnoreErrors(ctx.Responses())... and even worse when there are many iterators being composed.
Member
|
A variant of this design was reimplemented and merged in #245 |
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.
This pr replaces QuorumSpec with Responses.
instead of a quorum call returning the result of a quorum function, it returns an iterator called Responses, which can be used to get a quorum result the same way a quorum function could more or less.
Example Comparison
with QuorumSpec:
with Iterator:
Benchmark results
Issues
An example for how to use async/correctable could be added.