pub struct Outbox;Expand description
Stateless facade for the durable outbox table.
Implementations§
Source§impl Outbox
impl Outbox
Sourcepub async fn install() -> Result<(), Error>
pub async fn install() -> Result<(), Error>
Installs the portable outbox table and its delivery index.
Release migrations should normally own this DDL. This helper is useful for explicit application setup and tests; it never runs implicitly.
On MySQL/MariaDB the stream, event_key and claim_key columns use
the binary ascii_bin collation, so keys compare case-sensitively as on
PostgreSQL and SQLite. An existing table whose key columns still use
another collation (created by an earlier version) is converted in place
with ALTER TABLE, which rebuilds the table.
Sourcepub async fn enqueue(
stream: impl Into<String>,
event_key: impl Into<String>,
event_kind: impl Into<String>,
payload: &Value,
) -> Result<EnqueuedOutboxEvent, Error>
pub async fn enqueue( stream: impl Into<String>, event_key: impl Into<String>, event_kind: impl Into<String>, payload: &Value, ) -> Result<EnqueuedOutboxEvent, Error>
Enqueues an event inside the current Orm::transaction.
Refusing to open an implicit transaction prevents the domain mutation and its outbox row from accidentally committing independently.
Sourcepub async fn enqueue_with_tx(
transaction: &mut Transaction<'_>,
stream: impl Into<String>,
event_key: impl Into<String>,
event_kind: impl Into<String>,
payload: &Value,
) -> Result<EnqueuedOutboxEvent, Error>
pub async fn enqueue_with_tx( transaction: &mut Transaction<'_>, stream: impl Into<String>, event_key: impl Into<String>, event_kind: impl Into<String>, payload: &Value, ) -> Result<EnqueuedOutboxEvent, Error>
Enqueues through a caller-owned SQLx transaction.
Sourcepub async fn claim_next(
stream: impl Into<String>,
worker_id: impl Into<String>,
lease_seconds: i64,
max_attempts: i32,
) -> Result<Option<ClaimedOutboxEvent>, Error>
pub async fn claim_next( stream: impl Into<String>, worker_id: impl Into<String>, lease_seconds: i64, max_attempts: i32, ) -> Result<Option<ClaimedOutboxEvent>, Error>
Claims one pending or lease-expired event for a stream.
Auto Trait Implementations§
impl Freeze for Outbox
impl RefUnwindSafe for Outbox
impl Send for Outbox
impl Sync for Outbox
impl Unpin for Outbox
impl UnsafeUnpin for Outbox
impl UnwindSafe for Outbox
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more