pub struct MemoryTransactionalProjection<E, S, F> { /* private fields */ }Expand description
In-memory reference projection with an atomic read-model/checkpoint boundary.
The update closure receives a cloned candidate read model. The candidate and checkpoint become visible together only when the closure succeeds.
Implementations§
Source§impl<E, S, F> MemoryTransactionalProjection<E, S, F>
impl<E, S, F> MemoryTransactionalProjection<E, S, F>
Sourcepub fn new(id: ProjectionId, read_model: S, apply: F) -> Self
pub fn new(id: ProjectionId, read_model: S, apply: F) -> Self
Creates a projection from its stable identity, initial model, and update function.
Source§impl<E, S, F> MemoryTransactionalProjection<E, S, F>where
S: Clone,
impl<E, S, F> MemoryTransactionalProjection<E, S, F>where
S: Clone,
Sourcepub fn snapshot(&self) -> SoapResult<(S, Option<GlobalPosition>)>
pub fn snapshot(&self) -> SoapResult<(S, Option<GlobalPosition>)>
Returns a consistent copy of the read model and its checkpoint.
Trait Implementations§
Source§impl<E, S, F> Debug for MemoryTransactionalProjection<E, S, F>
impl<E, S, F> Debug for MemoryTransactionalProjection<E, S, F>
Source§impl<E, S, F> TransactionalProjection<E> for MemoryTransactionalProjection<E, S, F>where
E: DomainEvent,
S: Clone + Send,
F: Fn(&mut S, &RecordedEvent<E>) -> SoapResult<()> + Send + Sync,
impl<E, S, F> TransactionalProjection<E> for MemoryTransactionalProjection<E, S, F>where
E: DomainEvent,
S: Clone + Send,
F: Fn(&mut S, &RecordedEvent<E>) -> SoapResult<()> + Send + Sync,
Source§fn id(&self) -> &ProjectionId
fn id(&self) -> &ProjectionId
Returns the stable projection identity.
Source§fn checkpoint(&self) -> BoxFuture<'_, SoapResult<Option<GlobalPosition>>>
fn checkpoint(&self) -> BoxFuture<'_, SoapResult<Option<GlobalPosition>>>
Loads the last atomically committed global position.
Source§fn project_and_checkpoint<'a>(
&'a self,
event: &'a RecordedEvent<E>,
) -> BoxFuture<'a, SoapResult<ProjectionApplyOutcome>>
fn project_and_checkpoint<'a>( &'a self, event: &'a RecordedEvent<E>, ) -> BoxFuture<'a, SoapResult<ProjectionApplyOutcome>>
Applies one event and advances its checkpoint in the same transaction.
Auto Trait Implementations§
impl<E, S, F> !Freeze for MemoryTransactionalProjection<E, S, F>
impl<E, S, F> RefUnwindSafe for MemoryTransactionalProjection<E, S, F>where
F: RefUnwindSafe,
impl<E, S, F> Send for MemoryTransactionalProjection<E, S, F>
impl<E, S, F> Sync for MemoryTransactionalProjection<E, S, F>
impl<E, S, F> Unpin for MemoryTransactionalProjection<E, S, F>
impl<E, S, F> UnsafeUnpin for MemoryTransactionalProjection<E, S, F>where
F: UnsafeUnpin,
S: UnsafeUnpin,
impl<E, S, F> UnwindSafe for MemoryTransactionalProjection<E, S, F>where
F: UnwindSafe,
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