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 messagesOutboxDispatcher/BusPublisher- the async production drain pathOutboxSource- outbox-backed durable receiveBusOutboxPublishHook- after-commit immediate publish hook
§Separation of Concerns
The outbox pattern has two distinct phases:
- Commit phase (see
outboxmodule) - Atomically commit aggregate + outbox message - 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§
- BusOutbox
Publish Hook - Publishes committed outbox rows through
publisherand settles their claims instore. Thestoremust be the same outbox store the commit wrote to. - BusPublisher
- Publishes outbox-derived
Messages through aBus, routing by kind: commands tosend_message(point-to-point), events topublish_message(fan-out). - Claim
Outbox Messages - Outbox
Backlog Stats - Lightweight outbox backlog summary for metrics and diagnostics.
- Outbox
Claim Ref - Outbox
Dispatch Outcome - Counts of what one dispatch pass did. Raced/unclaimable ids are reflected as
claimed < requested, not as an error; publish failures arereleased(retryable) orfailed(attempt ceiling reached), not errors. - Outbox
Dispatcher - Bridges outbox claims to a
MessagePublisher, shared by immediate after-commit dispatch and background worker polling. - Outbox
Source - A
MessageSourcebacked by anOutboxStore. - Received
Outbox Message - A claimed outbox row, settled back to the store on ack/nack.
Enums§
Constants§
- DEFAULT_
OUTBOX_ SOURCE_ BATCH - Default number of rows claimed per
recvrefill. - 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§
- Outbox
Store - Store capability for claiming and updating durable outbox messages.