pub struct PostgresWriter;Expand description
Stateless writer for the outbox_events table.
The writer carries no connection or pool. The actual database handle is
passed per-call via OutboxWriter::insert_event’s executor argument —
idiomatically &mut *tx from a held sqlx::Transaction, so the outbox
row lands in the same commit as the caller’s business write.
§Example
ⓘ
use outbox_core::prelude::*;
use outbox_postgres::PostgresWriter;
use std::sync::Arc;
let service = OutboxService::new(Arc::new(PostgresWriter), config);
let mut tx = pool.begin().await.map_err(|e| OutboxError::DatabaseError(e.to_string()))?;
// ... INSERT INTO orders ... .execute(&mut *tx).await? ...
service.add_event("OrderCreated", payload, None, &mut *tx).await?;
tx.commit().await.map_err(|e| OutboxError::DatabaseError(e.to_string()))?;Trait Implementations§
Source§impl Clone for PostgresWriter
impl Clone for PostgresWriter
Source§fn clone(&self) -> PostgresWriter
fn clone(&self) -> PostgresWriter
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for PostgresWriter
Source§impl Debug for PostgresWriter
impl Debug for PostgresWriter
Source§impl Default for PostgresWriter
impl Default for PostgresWriter
Source§fn default() -> PostgresWriter
fn default() -> PostgresWriter
Returns the “default value” for a type. Read more
Source§impl<P> OutboxWriter<P> for PostgresWriter
impl<P> OutboxWriter<P> for PostgresWriter
Source§type Executor<'a> = &'a mut PgConnection
type Executor<'a> = &'a mut PgConnection
The executor handle accepted by
insert_event. Read moreSource§fn insert_event<'a, 'life0, 'async_trait>(
&'life0 self,
event: Event<P>,
executor: &'a mut PgConnection,
) -> 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: &'a mut PgConnection,
) -> Pin<Box<dyn Future<Output = Result<(), OutboxError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Auto Trait Implementations§
impl Freeze for PostgresWriter
impl RefUnwindSafe for PostgresWriter
impl Send for PostgresWriter
impl Sync for PostgresWriter
impl Unpin for PostgresWriter
impl UnsafeUnpin for PostgresWriter
impl UnwindSafe for PostgresWriter
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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 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>
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