Struct StateStoredOrchestratingAggregate

Source
pub struct StateStoredOrchestratingAggregate<'a, C, S, E, Repository, Version, Error>
where Repository: StateRepository<C, S, Version, Error>,
{ /* private fields */ }
Expand description

Orchestrating State Stored Aggregate.

It is using a Decider and Saga to compute new state based on the current state and the command. If the decider is combined out of many deciders via combine function, a saga could be used to react on new events and send new commands to the decider recursively, in single transaction. It is using a StateRepository to fetch the current state and to save the new state.

Generic parameters:

  • C - Command
  • S - State
  • E - Event
  • Repository - State repository
  • Version - Version
  • Error - Error

Implementations§

Source§

impl<'a, C, S, E, Repository, Version, Error> StateStoredOrchestratingAggregate<'a, C, S, E, Repository, Version, Error>
where Repository: StateRepository<C, S, Version, Error> + Sync, C: Sync, S: Sync + Clone, E: Sync, Version: Sync, Error: Sync,

Source

pub fn new( repository: Repository, decider: Decider<'a, C, S, E, Error>, saga: Saga<'a, E, C>, ) -> Self

Creates a new instance of StateStoredAggregate.

Source

pub async fn handle(&self, command: &C) -> Result<(S, Version), Error>

Handles the command by fetching the state from the repository, computing new state based on the current state and the command, and saving the new state to the repository.

Trait Implementations§

Source§

impl<C, S, E, Repository, Version, Error> StateComputation<C, S, E, Error> for StateStoredOrchestratingAggregate<'_, C, S, E, Repository, Version, Error>
where Repository: StateRepository<C, S, Version, Error>, S: Clone,

Source§

fn compute_new_state( &self, current_state: Option<S>, command: &C, ) -> Result<S, Error>

Computes new state based on the current state and the command.

Source§

impl<C, S, E, Repository, Version, Error> StateRepository<C, S, Version, Error> for StateStoredOrchestratingAggregate<'_, C, S, E, Repository, Version, Error>
where Repository: StateRepository<C, S, Version, Error> + Sync, C: Sync, S: Sync, E: Sync, Version: Sync, Error: Sync,

Source§

async fn fetch_state(&self, command: &C) -> Result<Option<(S, Version)>, Error>

Fetches current state, based on the command.

Source§

async fn save( &self, state: &S, version: &Option<Version>, ) -> Result<(S, Version), Error>

Saves state.

Auto Trait Implementations§

§

impl<'a, C, S, E, Repository, Version, Error> Freeze for StateStoredOrchestratingAggregate<'a, C, S, E, Repository, Version, Error>
where Repository: Freeze,

§

impl<'a, C, S, E, Repository, Version, Error> !RefUnwindSafe for StateStoredOrchestratingAggregate<'a, C, S, E, Repository, Version, Error>

§

impl<'a, C, S, E, Repository, Version, Error> Send for StateStoredOrchestratingAggregate<'a, C, S, E, Repository, Version, Error>
where Repository: Send, C: Send, S: Send, E: Send, Version: Send, Error: Send,

§

impl<'a, C, S, E, Repository, Version, Error> Sync for StateStoredOrchestratingAggregate<'a, C, S, E, Repository, Version, Error>
where Repository: Sync, C: Sync, S: Sync, E: Sync, Version: Sync, Error: Sync,

§

impl<'a, C, S, E, Repository, Version, Error> Unpin for StateStoredOrchestratingAggregate<'a, C, S, E, Repository, Version, Error>
where Repository: Unpin, C: Unpin, S: Unpin, E: Unpin, Version: Unpin, Error: Unpin,

§

impl<'a, C, S, E, Repository, Version, Error> !UnwindSafe for StateStoredOrchestratingAggregate<'a, C, S, E, Repository, Version, Error>

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.