Skip to main content

Outbox

Struct Outbox 

Source
pub struct Outbox;
Expand description

Stateless facade for the durable outbox table.

Implementations§

Source§

impl Outbox

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub async fn acknowledge( id: i64, claim_key: impl Into<String>, ) -> Result<bool, Error>

Marks an event delivered only when the exact claim token still owns it.

Source

pub async fn fail( id: i64, claim_key: impl Into<String>, error: impl Into<String>, max_attempts: i32, retry_delay_seconds: i64, ) -> Result<bool, Error>

Releases an event for retry or dead-letters it at the attempt limit.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more