Struct esrs::rebuilder::PgRebuilder
source · pub struct PgRebuilder<A, Schema = <A as Aggregate>::Event>where
A: Aggregate,{ /* private fields */ }
Implementations§
source§impl<A> PgRebuilder<A>where
A: Aggregate,
impl<A> PgRebuilder<A>where
A: Aggregate,
pub fn new() -> Self
pub fn with_event_handlers( self, event_handlers: Vec<Box<dyn ReplayableEventHandler<A> + Send>>, ) -> Self
pub fn with_transactional_event_handlers( self, transactional_event_handlers: Vec<Box<dyn TransactionalEventHandler<A, PgStoreError, PgConnection> + Send>>, ) -> Self
pub fn with_event_buses( self, event_buses: Vec<Box<dyn EventBus<A> + Send>>, ) -> Self
Trait Implementations§
source§impl<A> Default for PgRebuilder<A>where
A: Aggregate,
impl<A> Default for PgRebuilder<A>where
A: Aggregate,
source§impl<A, S> Rebuilder<A> for PgRebuilder<A, S>
impl<A, S> Rebuilder<A> for PgRebuilder<A, S>
source§fn by_aggregate_id<'life0, 'async_trait>(
&'life0 self,
pool: Pool<Postgres>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn by_aggregate_id<'life0, 'async_trait>(
&'life0 self,
pool: Pool<Postgres>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
To optimize performance, the code can be modified to open a single transaction for all the
aggregate IDs fetched by a pre-made query. Within this transaction, the list of events for
each aggregate ID is extracted. Then, for every TransactionalEventHandler
and
crate::handler::EventHandler
, the corresponding aggregate is deleted, and the list of
events is processed by the mentioned handlers.
Finally the events are passed to every configured EventBus
.
source§fn all_at_once<'life0, 'async_trait>(
&'life0 self,
pool: Pool<Postgres>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn all_at_once<'life0, 'async_trait>(
&'life0 self,
pool: Pool<Postgres>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
To process all events in the database, a single transaction is opened, and within this
transaction, all aggregates are deleted and for each TransactionalEventHandler
, the
events are handled. After the transaction ends, for each crate::handler::EventHandler
and EventBus
, the events are handled.
type Executor = Pool<Postgres>
type Error = PgStoreError
Auto Trait Implementations§
impl<A, Schema> Freeze for PgRebuilder<A, Schema>
impl<A, Schema = <A as Aggregate>::Event> !RefUnwindSafe for PgRebuilder<A, Schema>
impl<A, Schema> Send for PgRebuilder<A, Schema>where
Schema: Send,
impl<A, Schema> Sync for PgRebuilder<A, Schema>where
Schema: Sync,
impl<A, Schema> Unpin for PgRebuilder<A, Schema>where
Schema: Unpin,
impl<A, Schema = <A as Aggregate>::Event> !UnwindSafe for PgRebuilder<A, Schema>
Blanket Implementations§
source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> 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