Expose CachingStream as a public API - #6831
Conversation
📝 WalkthroughWalkthroughIntroduces a ChangesCachingStream API and RouteStream migration
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@xds/src/main/java/com/linecorp/armeria/xds/stream/SnapshotStream.java`:
- Around line 216-241: The caching API in SnapshotStream.caching is stateful and
backed by CachingStream’s HashMap and ref-counting, so it needs an explicit
single-threaded contract. Update the Javadoc on caching (and, if applicable,
CachingStream.subscribe/close) to state that all apply/subscribe/close calls
must be serialized on the same event-loop thread; alternatively, make
CachingStream thread-safe if that contract cannot be guaranteed. Use the
existing SnapshotStream and CachingStream symbols to keep the documentation
aligned with the public API.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: b183e00c-1f57-48ec-9629-02fa306e9574
📒 Files selected for processing (3)
xds/src/main/java/com/linecorp/armeria/xds/RouteStream.javaxds/src/main/java/com/linecorp/armeria/xds/stream/CachingStream.javaxds/src/main/java/com/linecorp/armeria/xds/stream/SnapshotStream.java
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6831 +/- ##
============================================
+ Coverage 74.46% 75.07% +0.61%
- Complexity 22234 25162 +2928
============================================
Files 1963 2239 +276
Lines 82437 93431 +10994
Branches 10764 12187 +1423
============================================
+ Hits 61385 70147 +8762
- Misses 15918 17462 +1544
- Partials 5134 5822 +688 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Tick the box to add this pull request to the merge queue (same as
|
Motivation:
CachingStreamprovides a useful pattern for deduplicatingSnapshotStreamsubscriptions by key using reference counting. Currently it is package-private incom.linecorp.armeria.xds, making it unavailable to external modules that build on theSnapshotStreamAPI (e.g. Central Dogma had to fork it).Modifications:
SnapshotStream.caching(Function)static factory method that returns aFunction<K, SnapshotStream<T>>for keyed, ref-counted stream deduplicationCachingStreamtocom.linecorp.armeria.xds.streamas a package-private implementation detailRouteStreamto use the newSnapshotStream.caching()APIcom.linecorp.armeria.xds.CachingStreamResult:
SnapshotStreamsubscriptions by key viaSnapshotStream.caching(factory)without forking internal classes