pub trait WriteHooks<E: PersistentEntity>: Send + Sync {
// Provided methods
fn outbox_schema(&self) -> Option<&str> { ... }
fn before<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
ctx: &'life1 WriteCtx,
change: &'life2 mut Change<'life3, E>,
) -> Pin<Box<dyn Future<Output = ServiceResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait { ... }
fn after<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
ctx: &'life1 WriteCtx,
change: &'life2 Change<'life3, E>,
) -> Pin<Box<dyn Future<Output = ServiceResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait { ... }
}Expand description
Code that runs inside a write’s transaction, before and after the repository write.
Both methods default to doing nothing. An error from either rolls the write back and answers as the service answers any failed write.
Provided Methods§
Sourcefn outbox_schema(&self) -> Option<&str>
fn outbox_schema(&self) -> Option<&str>
The Postgres schema whose outbox_events table WriteCtx::stage writes to. None
(the default) means these hooks stage nothing.
Sourcefn before<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
ctx: &'life1 WriteCtx,
change: &'life2 mut Change<'life3, E>,
) -> Pin<Box<dyn Future<Output = ServiceResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn before<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
ctx: &'life1 WriteCtx,
change: &'life2 mut Change<'life3, E>,
) -> Pin<Box<dyn Future<Output = ServiceResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Before the repository writes change: may refuse it, and may fill fields of the row to
be stored. Runs after the guard and ServiceLifecycle::before_*.
Sourcefn after<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
ctx: &'life1 WriteCtx,
change: &'life2 Change<'life3, E>,
) -> Pin<Box<dyn Future<Output = ServiceResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn after<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
ctx: &'life1 WriteCtx,
change: &'life2 Change<'life3, E>,
) -> Pin<Box<dyn Future<Output = ServiceResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
After the repository wrote change, still inside the transaction: the place to stage
events and to write rows that must commit with it. Runs after
ServiceLifecycle::after_*.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".