Skip to main content

OutboxWriter

Trait OutboxWriter 

Source
pub trait OutboxWriter<P>
where P: Debug + Clone + Serialize + Send + Sync,
{ type Executor<'a>: Send where Self: 'a; // Required method fn insert_event<'a, 'life0, 'async_trait>( &'life0 self, event: Event<P>, executor: Self::Executor<'a>, ) -> Pin<Box<dyn Future<Output = Result<(), OutboxError>> + Send + 'async_trait>> where Self: 'async_trait, 'a: 'async_trait, 'life0: 'async_trait; }
Expand description

Producer-side storage contract.

Separated from OutboxStorage so a service that only writes events can depend on the narrow surface it actually uses.

The associated Executor type lets the caller decide what kind of connection or transaction handle is threaded into the insert, which is what makes a transactional outbox write possible: a single &mut sqlx::Transaction can carry both the caller’s business INSERT and the outbox row in the same commit.

Required Associated Types§

Source

type Executor<'a>: Send where Self: 'a

The executor handle accepted by insert_event.

For sqlx-based backends this is typically &'a mut sqlx::PgConnection, which can be borrowed from a held transaction via &mut *tx. Backends that do not need transactional control can set this to () (the in-memory test writer does so).

Required Methods§

Source

fn insert_event<'a, 'life0, 'async_trait>( &'life0 self, event: Event<P>, executor: Self::Executor<'a>, ) -> Pin<Box<dyn Future<Output = Result<(), OutboxError>> + Send + 'async_trait>>
where Self: 'async_trait, 'a: 'async_trait, 'life0: 'async_trait,

Persists a single Event row through executor.

Called by OutboxService::add_event after any configured idempotency reservation has succeeded.

§Errors

Returns an OutboxError if the insert fails — typically a DatabaseError on a unique-constraint violation or connection issue.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§