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
- CommandS
- StateE
- EventRepository
- State repositoryVersion
- VersionError
- Error
Implementations§
Source§impl<'a, C, S, E, Repository, Version, Error> StateStoredOrchestratingAggregate<'a, C, S, E, Repository, Version, Error>
impl<'a, C, S, E, Repository, Version, Error> StateStoredOrchestratingAggregate<'a, C, S, E, Repository, Version, Error>
Sourcepub fn new(
repository: Repository,
decider: Decider<'a, C, S, E, Error>,
saga: Saga<'a, E, C>,
) -> Self
pub fn new( repository: Repository, decider: Decider<'a, C, S, E, Error>, saga: Saga<'a, E, C>, ) -> Self
Creates a new instance of StateStoredAggregate.
Sourcepub async fn handle(&self, command: &C) -> Result<(S, Version), Error>
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,
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§impl<C, S, E, Repository, Version, Error> StateRepository<C, S, Version, Error> for StateStoredOrchestratingAggregate<'_, C, S, E, Repository, Version, Error>
impl<C, S, E, Repository, Version, Error> StateRepository<C, S, Version, Error> for StateStoredOrchestratingAggregate<'_, C, S, E, Repository, Version, Error>
Source§async fn fetch_state(&self, command: &C) -> Result<Option<(S, Version)>, Error>
async fn fetch_state(&self, command: &C) -> Result<Option<(S, Version)>, Error>
Fetches current state, based on the command.
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>
impl<'a, C, S, E, Repository, Version, Error> Sync for StateStoredOrchestratingAggregate<'a, C, S, E, Repository, Version, Error>
impl<'a, C, S, E, Repository, Version, Error> Unpin for StateStoredOrchestratingAggregate<'a, C, S, E, Repository, Version, Error>
impl<'a, C, S, E, Repository, Version, Error> !UnwindSafe for StateStoredOrchestratingAggregate<'a, C, S, E, Repository, Version, Error>
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