Skip to content

feat: expose topic_stats in the Node and Java shells#506

Merged
pratyush618 merged 4 commits into
ByteVeda:masterfrom
stromanni:feat/topic-stats-node-java
Jul 23, 2026
Merged

feat: expose topic_stats in the Node and Java shells#506
pratyush618 merged 4 commits into
ByteVeda:masterfrom
stromanni:feat/topic-stats-node-java

Conversation

@stromanni

@stromanni stromanni commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Closes #478.

Python exposes queue.topic_stats() over the core Storage::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)
  • async topicBacklogStats() on JsQueue, offloaded to the blocking pool like its pub/sub siblings
  • queue.topicStats(topic?) in the SDK, filtering client-side exactly as Python does

Java

  • TopicStatsView (serde camelCase) in crates/taskito-java/src/convert.rs
  • JNI topicBacklogStats(handle) returning a JSON array
  • The usual chain: NativeQueueQueueBackend.topicBacklogStatsJson() (defaulted, so third-party backends keep compiling) → JniQueueBackendDefaultTaskito.topicStats() / topicStats(topic) → new model/TopicStat

Fields 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.rs needed 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/fmt clean on both crates
  • Node: tsc, biome, pubsub.test.ts 22/22
  • Java: ./gradlew build green, PubSubTest 18/18

Summary by CodeRabbit

  • New Features

    • Added pub/sub backlog statistics APIs for Node and Java.
    • View per-subscription pending, running, dead, and oldest pending age metrics.
    • Filter statistics by topic; subscriptions appear even with zero backlog.
  • Documentation

    • Added Node and Java API reference documentation and changelog entries.
  • Tests

    • Added coverage for idle subscriptions, failed deliveries, backlog counts, and topic filtering.

Binds the core topic_backlog_stats aggregate, mirroring Python's topic_stats().
Binds the core topic_backlog_stats aggregate, mirroring Python's topic_stats().
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@stromanni, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 22 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5f32d515-5003-48e1-87bc-e8268a6b2e36

📥 Commits

Reviewing files that changed from the base of the PR and between 5fa2356 and 8f54100.

📒 Files selected for processing (3)
  • sdks/java/src/main/java/org/byteveda/taskito/DefaultTaskito.java
  • sdks/java/src/main/java/org/byteveda/taskito/Taskito.java
  • sdks/java/src/test/java/org/byteveda/taskito/core/PubSubTest.java
📝 Walkthrough

Walkthrough

Node 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.

Changes

Pub/Sub topic statistics

Layer / File(s) Summary
Node topic statistics binding
crates/taskito-node/..., sdks/node/src/{native.ts,queue.ts,types.ts}
Core backlog snapshots are converted to JavaScript objects, exposed through N-API, re-exported as TopicStat, and returned by Queue.topicStats(topic?).
Java topic statistics binding
crates/taskito-java/..., sdks/java/src/main/java/org/byteveda/taskito/{model,internal,spi}/*, sdks/java/src/main/java/org/byteveda/taskito/{Taskito,DefaultTaskito}.java
Java receives a TopicStat model, backend and JNI plumbing, and topicStats() / topicStats(String topic) APIs backed by serialized native snapshots.
Validation and documentation
sdks/node/test/core/pubsub.test.ts, sdks/java/src/test/.../PubSubTest.java, docs/content/docs/{node,java}/api-reference/queue/pubsub.mdx, CHANGELOG.md
Tests cover backlog counters, idle subscriptions, failed deliveries, filtering, and non-pub/sub jobs; documentation and release notes describe the APIs and fields.

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[]
Loading
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>
Loading

Possibly related PRs

  • ByteVeda/taskito#412: Added the pub/sub infrastructure used by the new Node and Java inspection endpoints.
  • ByteVeda/taskito#416: Added the core backlog statistics and subscription attribution used by these bindings.

Suggested labels: storage

Suggested reviewers: pratyush618

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 62.96% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: exposing topic stats in the Node and Java shells.
Linked Issues check ✅ Passed The PR implements the linked issue by binding core topic_backlog_stats into Node and Java and matching the expected return shape.
Out of Scope Changes check ✅ Passed The changes are focused on topic_stats plumbing, models, docs, and tests, with no clear unrelated additions.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3e1ba3c and 5fa2356.

📒 Files selected for processing (19)
  • CHANGELOG.md
  • crates/taskito-java/src/convert.rs
  • crates/taskito-java/src/queue/pubsub.rs
  • crates/taskito-node/src/convert/mod.rs
  • crates/taskito-node/src/convert/pubsub.rs
  • crates/taskito-node/src/queue/pubsub.rs
  • docs/content/docs/java/api-reference/queue/pubsub.mdx
  • docs/content/docs/node/api-reference/queue/pubsub.mdx
  • sdks/java/src/main/java/org/byteveda/taskito/DefaultTaskito.java
  • sdks/java/src/main/java/org/byteveda/taskito/Taskito.java
  • sdks/java/src/main/java/org/byteveda/taskito/internal/JniQueueBackend.java
  • sdks/java/src/main/java/org/byteveda/taskito/internal/NativeQueue.java
  • sdks/java/src/main/java/org/byteveda/taskito/model/TopicStat.java
  • sdks/java/src/main/java/org/byteveda/taskito/spi/QueueBackend.java
  • sdks/java/src/test/java/org/byteveda/taskito/core/PubSubTest.java
  • sdks/node/src/native.ts
  • sdks/node/src/queue.ts
  • sdks/node/src/types.ts
  • sdks/node/test/core/pubsub.test.ts

Comment thread sdks/java/src/main/java/org/byteveda/taskito/DefaultTaskito.java
@pratyush618
pratyush618 merged commit 78d988d into ByteVeda:master Jul 23, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose topic_stats in the Node and Java shells

2 participants