Skip to main content

Module outbox_worker

Module outbox_worker 

Source
Expand description

Outbox Worker - Drains and publishes outbox messages.

This module provides the worker infrastructure for processing outbox messages.

Items:

  • OutboxStore - Store operations for claiming and completing messages
  • OutboxDispatcher / BusPublisher - the async production drain path
  • OutboxSource - outbox-backed durable receive
  • BusOutboxPublishHook - after-commit immediate publish hook

§Separation of Concerns

The outbox pattern has two distinct phases:

  1. Commit phase (see outbox module) - Atomically commit aggregate + outbox message
  2. Worker phase (this module) - Drain outbox and publish to external systems

§Example

use distributed::OutboxDispatcher;
use std::time::Duration;

let dispatcher =
    OutboxDispatcher::new(outbox, publisher, "worker-1", Duration::from_secs(60), 3);
let outcome = dispatcher.dispatch_batch(10).await?;

Structs§

BusOutboxPublishHook
Publishes committed outbox rows through publisher and settles their claims in store. The store must be the same outbox store the commit wrote to.
BusPublisher
Publishes outbox-derived Messages through a Bus, routing by kind: commands to send_message (point-to-point), events to publish_message (fan-out).
ClaimOutboxMessages
OutboxBacklogStats
Lightweight outbox backlog summary for metrics and diagnostics.
OutboxClaimRef
OutboxDispatchOutcome
Counts of what one dispatch pass did. Raced/unclaimable ids are reflected as claimed < requested, not as an error; publish failures are released (retryable) or failed (attempt ceiling reached), not errors.
OutboxDispatcher
Bridges outbox claims to a MessagePublisher, shared by immediate after-commit dispatch and background worker polling.
OutboxSource
A MessageSource backed by an OutboxStore.
ReceivedOutboxMessage
A claimed outbox row, settled back to the store on ack/nack.

Enums§

OutboxPublishFailureAction

Constants§

DEFAULT_OUTBOX_SOURCE_BATCH
Default number of rows claimed per recv refill.
DEFAULT_OUTBOX_SOURCE_LEASE
Default lease held on a claimed row while it is being dispatched.
SOURCED_METADATA_PREFIX
Reserved metadata key prefix for framework-derived keys. User metadata must not use this prefix; keys here (payload codec, destination, source context) carry decode/routing semantics and must not be shadowable by user metadata.

Traits§

OutboxStore
Store capability for claiming and updating durable outbox messages.