Conversation
|
|
Overall Grade |
Security Reliability Complexity Hygiene |
Code Review Summary
| Analyzer | Status | Updated (UTC) | Details |
|---|---|---|---|
| Go | Apr 11, 2026 10:06a.m. | Review ↗ | |
| Shell | Apr 11, 2026 10:06a.m. | Review ↗ |
Important
AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.
There was a problem hiding this comment.
Pull request overview
Adds an explicit, caller-controlled way to order and subset configurations by observed round-trip latency, avoiding implicit behavior changes while enabling “fast node” selection patterns.
Changes:
- Add
Configuration.SortBy(stable sort + copy) to derive ordered configurations without mutating the original. - Add a
gorums.Latencynode comparator (with “unmeasured last” semantics) and expandNode.Latency()documentation. - Add tests for the comparator and
SortBy, plus user-guide documentation describing how to apply latency-based selection safely.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
node.go |
Expands Node.Latency() docs and introduces Latency comparator alongside existing comparators. |
config.go |
Introduces Configuration.SortBy using stable sort over a cloned node slice. |
internal/stream/router.go |
Adds a test helper constructor to preset router latency. |
node_test.go |
Adds unit tests for latency comparator ordering and tie-breaking composition with ID. |
config_test.go |
Adds tests for SortBy behavior (size preservation, immutability, empty handling, composition). |
doc/user-guide.md |
Documents latency-based node selection patterns, cautions, and re-sort guidance. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Add Configuration.SortBy and the Latency node comparator so callers can explicitly order or subset nodes by observed round-trip latency without hiding mutable network measurements behind implicit call behavior. - internal/stream: add NewMessageRouterWithLatency test helper - node.go: expand Node.Latency() doc with measurement limits; add Latency comparator (compatible with slices.SortFunc and Configuration.SortBy) - config.go: add Configuration.SortBy using stable sort - node_test.go: tests for Latency comparator ordering and tie-breaking - config_test.go: tests for SortBy including empty config and composition - doc/user-guide.md: new "Latency-Based Node Selection" section covering fast sub-configurations, re-sort frequency guidance, and measurement limits Fixes #320
Introduces Configuration.Watch, a new method that starts a background goroutine to periodically re-derive a sub-configuration and emit it on a channel only when it differs from the previous result. The initial result is always emitted before the first tick, ensuring callers receive a valid configuration immediately. The returned channel has a 1-element buffer; if the consumer is slow, emissions are skipped and re-evaluated on the next tick. This replaces the bespoke mutex-based refresh pattern previously documented in the user guide. Examples are updated to show common use cases: latency-based top-k selection and error-filtering with latency sorting. Also adds SetLatency test helper to MessageRouter to support configuration watch tests via latency simulation.
8b24cfd to
87a7ef4
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The Latency comparator orders nodes without latency measurements last.
The LLM hallucinated some bad calculations for the quorum size and tolerated failures value.
This fixes some LLM misconceptions in the measurement limits section and adds some additional limitations to clarify what the latency measurement is actually measuring (RPC compute included and shared across all RPCs hosted on the node).
Add Configuration.SortBy and the Latency node comparator so callers can explicitly order or subset nodes by observed round-trip latency without hiding mutable network measurements behind implicit call behavior.
Note: Using Configuration.SortBy does not magically make quorum calls faster, since quorum calls contact all nodes independent of their placement in the Configuration slice. Thus, to take advantage of a latency-sorted configuration, a quorum call's Configuration should be sliced to the fastest quorum size. This assumes that the quorum call does not update the Node's state, which should be updated on all nodes. However, for read-only quorum calls, using only the fastest quorum size should be fine.
Co-Authored-By: Claude Sonnet 4.6
Fixes #320