pub trait OutboxWriter<P>{
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§
Sourcetype Executor<'a>: Send
where
Self: 'a
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§
Sourcefn 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,
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".