Skip to main content

MemoryTransactionalProjection

Struct MemoryTransactionalProjection 

Source
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>

Source

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,

Source

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>

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
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,

Source§

fn id(&self) -> &ProjectionId

Returns the stable projection identity.
Source§

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>>

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>
where F: Send, S: Send,

§

impl<E, S, F> Sync for MemoryTransactionalProjection<E, S, F>
where F: Sync, S: Send,

§

impl<E, S, F> Unpin for MemoryTransactionalProjection<E, S, F>
where F: Unpin, S: Unpin,

§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.