feat(a2a-nats): nats + jetstream push dispatchers - #319
Conversation
yordis
commented
Jun 18, 2026
- Two transport-specific impls of PushDispatcher land together because they share the same retry shape + Nats-Msg-Id header contract — splitting them later would invite drift between the core-NATS and JetStream paths on rules like duplicate-ack handling and per-attempt budget collapse under exactly-once.
- JetStream's duplicate-ack flag is treated as success rather than a publish error so the exactly-once dedup behaviour stays observable to operators as "JetStream already accepted this" without triggering downstream retry loops.
NatsPublishPushDispatcher fans out push notifications onto core NATS subjects (subject:...) with optional Nats-Msg-Id stamping for the exactly-once path; the publish budget collapses to 1 attempt under exactly-once so a redelivered terminal can't double-publish via core NATS. JetStreamPublishPushDispatcher takes the durable JetStream side (jetstream:...) — same Msg-Id header, but the duplicate-ack flag is treated as success so an exactly-once redelivery is observable as 'JetStream already accepted this' rather than a publish error. Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
PR SummaryMedium Risk Overview Both dispatchers parse the push target from
Unit tests cover subject resolution, header stamping, retries, error paths, and JetStream duplicate-ack behavior. Reviewed by Cursor Bugbot for commit 3478f65. Bugbot is set up for automated code reviews on this repo. Configure here. |
|
Warning Review limit reached
More reviews will be available in 53 minutes and 9 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?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 credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. 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, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughAdds two new ChangesNATS and JetStream PushDispatcher backends
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
🚥 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 |
Code Coverage SummaryDetailsDiff against mainResults for commit: 3478f65 Minimum allowed coverage is ♻️ This comment has been updated with latest results |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
rsworkspace/crates/a2a-nats/src/push/dispatcher/jetstream.rs (1)
83-85: 💤 Low valueConsider extracting shared
next_retry_delayhelper.This function is identical in both
nats.rsandjetstream.rs. Extracting it to the parentdispatcher/mod.rsor a common utilities module would reduce duplication.🤖 Prompt for 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. In `@rsworkspace/crates/a2a-nats/src/push/dispatcher/jetstream.rs` around lines 83 - 85, The next_retry_delay function in jetstream.rs is duplicated in nats.rs. Extract this function from jetstream.rs and move it to the parent dispatcher/mod.rs module so both nats.rs and jetstream.rs can share the same implementation. Then update the imports in both jetstream.rs and nats.rs to use the shared next_retry_delay function from the parent module instead of having duplicate definitions.
🤖 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.
Nitpick comments:
In `@rsworkspace/crates/a2a-nats/src/push/dispatcher/jetstream.rs`:
- Around line 83-85: The next_retry_delay function in jetstream.rs is duplicated
in nats.rs. Extract this function from jetstream.rs and move it to the parent
dispatcher/mod.rs module so both nats.rs and jetstream.rs can share the same
implementation. Then update the imports in both jetstream.rs and nats.rs to use
the shared next_retry_delay function from the parent module instead of having
duplicate definitions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 91843dd6-1f12-4f6f-acc3-0da5270cd023
📒 Files selected for processing (3)
rsworkspace/crates/a2a-nats/src/push/dispatcher/jetstream.rsrsworkspace/crates/a2a-nats/src/push/dispatcher/mod.rsrsworkspace/crates/a2a-nats/src/push/dispatcher/nats.rs
…coverage gap Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>