feat: expose topic_stats in the Node and Java shells#506
Conversation
Binds the core topic_backlog_stats aggregate, mirroring Python's topic_stats().
Binds the core topic_backlog_stats aggregate, mirroring Python's topic_stats().
|
Warning Review limit reached
Next review available in: 22 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughNode and Java now expose per-subscription pub/sub backlog statistics, including pending, running, dead, and oldest-pending-age values. Native bindings, SDK models and methods, topic filtering, integration tests, API documentation, and changelog entries were added. ChangesPub/Sub topic statistics
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant NodeQueue
participant NativeQueue
participant Storage
NodeQueue->>NativeQueue: topicStats(topic?)
NativeQueue->>Storage: topic_backlog_stats()
Storage-->>NativeQueue: per-subscription snapshots
NativeQueue-->>NodeQueue: TopicStat[]
sequenceDiagram
participant JavaTaskito
participant JniQueueBackend
participant NativeQueue
participant Storage
JavaTaskito->>JniQueueBackend: topicStats()
JniQueueBackend->>NativeQueue: topicBacklogStats(handle)
NativeQueue->>Storage: topic_backlog_stats()
Storage-->>NativeQueue: JSON snapshots
NativeQueue-->>JavaTaskito: List<TopicStat>
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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 `@sdks/java/src/main/java/org/byteveda/taskito/DefaultTaskito.java`:
- Around line 933-942: Update DefaultTaskito.topicStats(String topic) to return
the unfiltered topicStats() result immediately when topic is null; retain the
existing filtering behavior for non-null topic values.
🪄 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: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 3d75e5d0-a001-4821-a56e-66f5b8528634
📒 Files selected for processing (19)
CHANGELOG.mdcrates/taskito-java/src/convert.rscrates/taskito-java/src/queue/pubsub.rscrates/taskito-node/src/convert/mod.rscrates/taskito-node/src/convert/pubsub.rscrates/taskito-node/src/queue/pubsub.rsdocs/content/docs/java/api-reference/queue/pubsub.mdxdocs/content/docs/node/api-reference/queue/pubsub.mdxsdks/java/src/main/java/org/byteveda/taskito/DefaultTaskito.javasdks/java/src/main/java/org/byteveda/taskito/Taskito.javasdks/java/src/main/java/org/byteveda/taskito/internal/JniQueueBackend.javasdks/java/src/main/java/org/byteveda/taskito/internal/NativeQueue.javasdks/java/src/main/java/org/byteveda/taskito/model/TopicStat.javasdks/java/src/main/java/org/byteveda/taskito/spi/QueueBackend.javasdks/java/src/test/java/org/byteveda/taskito/core/PubSubTest.javasdks/node/src/native.tssdks/node/src/queue.tssdks/node/src/types.tssdks/node/test/core/pubsub.test.ts
Closes #478.
Python exposes
queue.topic_stats()over the coreStorage::topic_backlog_stats; neither shell bound it. This binds the existing core method in both and mirrors the Python return shape.Node
JsTopicStat+topic_stat_to_js(crates/taskito-node/src/convert/pubsub.rs)topicBacklogStats()onJsQueue, offloaded to the blocking pool like its pub/sub siblingsqueue.topicStats(topic?)in the SDK, filtering client-side exactly as Python doesJava
TopicStatsView(serde camelCase) incrates/taskito-java/src/convert.rstopicBacklogStats(handle)returning a JSON arrayNativeQueue→QueueBackend.topicBacklogStatsJson()(defaulted, so third-party backends keep compiling) →JniQueueBackend→DefaultTaskito.topicStats()/topicStats(topic)→ newmodel/TopicStatFields match Python's dict keys, camelCased:
topic,subscription,taskName,queue,active,durable,pending,running,dead,oldestPendingAgeMs. Every registered subscription gets a row — paused and ephemeral included — even at zero backlog.The FFM (Panama) seam covers only the enqueue/getResult hot path, so
ffi_c.rsneeded no change.Tests
Four per shell, mirroring the Python coverage in
tests/core/test_pubsub.py::TestTopicStats: per-subscription counts, zeroed rows for idle subscriptions, a failed delivery counting as dead, and the topic filter with non-pub/sub jobs staying invisible.cargo clippy/fmtclean on both cratestsc, biome,pubsub.test.ts22/22./gradlew buildgreen,PubSubTest18/18Summary by CodeRabbit
New Features
Documentation
Tests