Skip to content

feat: cancellable OutboxDrainRunner - #203

Open
patrickleet wants to merge 1 commit into
mainfrom
tasks--outbox-background-drain-runner
Open

feat: cancellable OutboxDrainRunner#203
patrickleet wants to merge 1 commit into
mainfrom
tasks--outbox-background-drain-runner

Conversation

@patrickleet

Copy link
Copy Markdown
Collaborator

Summary

Adds the missing background outbox drain loop. Immediate after-commit publish stays the fast path; this runner is the crash/retry safety net.

  • OutboxDrainRunner over OutboxDispatcher::dispatch_batch — full batches continue immediately, empty passes sleep, store errors back off and do not kill the task
  • Worker id drain:<pid> so claims never collide with microsvc-immediate:<pid>
  • Service::outbox_drain builds a runner (does not spawn). run() stays no-timer
  • spawn_outbox_publish_loop now wraps the runner; dropping the handle leaves the task running (e2e-ui fire-and-forget)
  • stop() aborts promptly

Tests:

  • immediate publish → drain finds nothing (no double-send)
  • crash-after-commit (row never attempted) → drain publishes
  • injected store errors → retry, task survives
  • stop() returns in <500ms during a 30s idle sleep
  • Service::outbox_drain sugar publishes leftover rows

Implements [[tasks/outbox-background-drain-runner]]

Independent of #202 (load suite). This branch is from main.

Test plan

  • cargo test --lib outbox_worker::drain
  • cargo test --lib outbox_drain_sugar
  • cargo test --lib outbox_worker::outbox_dispatch
  • CI on this PR

Immediate after-commit publish stays the fast path. This loop is the
safety net: dispatch_batch until the outbox is empty, sleep when idle,
back off on store errors, stop on abort.

Worker id is drain:<pid> so claims never collide with
microsvc-immediate:<pid>. Service::outbox_drain builds the runner;
spawn_outbox_publish_loop now wraps it. Dropping the handle leaves the
task running; stop() aborts.

Implements [[tasks/outbox-background-drain-runner]]
@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown

Warning

Review limit reached

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

Next review available in: 52 minutes

Limit details: You’ve used all 1 included review currently available under your plan.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

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: 7a1e817e-1149-4990-bf64-fc4d17fb0168

📥 Commits

Reviewing files that changed from the base of the PR and between d7835ec and 395701f.

📒 Files selected for processing (5)
  • src/lib.rs
  • src/microsvc/runtime.rs
  • src/microsvc/workers.rs
  • src/outbox_worker/drain.rs
  • src/outbox_worker/mod.rs

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant