Skip to main content

Module tx_outbox

Module tx_outbox 

Source
Expand description

FR-9 — Transactional outbox: atomic event + outbox write.

Distinct from crate::outbox, which is a journal-tailing relay that re-publishes already-committed events at-least-once on a polling loop. This module instead writes the event row and its outbox row inside the same sqlx::Transaction the caller controls, so the two either commit together or roll back together — there is no window where an event exists without its outbox entry (or vice versa).

The caller owns commit/rollback: TxOutbox::persist_with only enqueues both INSERTs on the supplied transaction.

let mut tx = pool.begin().await?;
TxOutbox.persist_with(&mut tx, event_row, outbox_row).await?;
tx.commit().await?; // both rows land atomically

Structs§

EventRow
The event row to append to event_journal. A small param struct so we never need to touch atomr_persistence::PersistentRepr.
OutboxRow
The outbox row to append to outbox in the same transaction.
TxOutbox
Zero-sized handle for the transactional outbox write.

Enums§

OutboxError
Errors from the transactional outbox write.