pub struct Outbox { /* private fields */ }Expand description
A durable work queue over the Database port. Construct it with the table
the owning module declares (e.g. "<module>_outbox").
Implementations§
Source§impl Outbox
impl Outbox
pub fn new(table: impl Into<String>) -> Self
Sourcepub fn create_table_sql(&self) -> String
pub fn create_table_sql(&self) -> String
The portable DDL for the outbox table. The owning module ships this as a forward-only migration.
Sourcepub fn enqueue_statement(
&self,
id: &str,
topic: &str,
payload: &str,
subject: Option<&str>,
at: &str,
) -> Statement
pub fn enqueue_statement( &self, id: &str, topic: &str, payload: &str, subject: Option<&str>, at: &str, ) -> Statement
The INSERT that enqueues one unit of work. Return it into the module’s
own db.batch_atomic(..) alongside the state change, so the row is durable
exactly when the change is. id is a caller-supplied ULID; at is an
RFC 3339 timestamp used for both created_at and the initial
next_attempt_at (deliver as soon as possible).
subject is the person the work is for — an account id, a waitlist
entry id — or None for work that names nobody. Writing it is what
makes the queued row reachable for export and erasure (issue #266):
the payload JSON is the module’s own dialect and no predicate can
match into it. Pass it for every per-person job even when it feels
redundant with the payload; None rows drain identically but are
returned for nobody’s subject, so a forgotten Some is a silent
hole in the erasure catalogue rather than an error.