pub struct SagaManager<A, AR, Publisher, Saga, Error>where
Publisher: ActionPublisher<A, Error>,
Saga: ActionComputation<AR, A>,{ /* private fields */ }
Expand description
Saga Manager.
It is using a Saga
to react to the action result and to publish the new actions.
It is using an ActionPublisher to publish the new actions.
Generic parameters:
A
- Action / CommandAR
- Action Result / EventPublisher
- Action PublisherError
- Error
Implementations§
Source§impl<A, AR, Publisher, Saga, Error> SagaManager<A, AR, Publisher, Saga, Error>where
Publisher: ActionPublisher<A, Error> + Sync,
Saga: ActionComputation<AR, A> + Sync,
A: Sync,
AR: Sync,
Error: Sync,
impl<A, AR, Publisher, Saga, Error> SagaManager<A, AR, Publisher, Saga, Error>where
Publisher: ActionPublisher<A, Error> + Sync,
Saga: ActionComputation<AR, A> + Sync,
A: Sync,
AR: Sync,
Error: Sync,
Sourcepub fn new(action_publisher: Publisher, saga: Saga) -> Self
pub fn new(action_publisher: Publisher, saga: Saga) -> Self
Creates a new instance of SagaManager.
Sourcepub async fn handle(&self, action_result: &AR) -> Result<Vec<A>, Error>
pub async fn handle(&self, action_result: &AR) -> Result<Vec<A>, Error>
Handles the action result
by computing new actions
based on action result
, and publishing new actions
to the external system.
In most cases:
- the
action result
is anevent
that you react, - the
actions
arecommands
that you publish downstream.
Trait Implementations§
Source§impl<A, AR, Publisher, Saga, Error> ActionComputation<AR, A> for SagaManager<A, AR, Publisher, Saga, Error>where
Publisher: ActionPublisher<A, Error>,
Saga: ActionComputation<AR, A>,
impl<A, AR, Publisher, Saga, Error> ActionComputation<AR, A> for SagaManager<A, AR, Publisher, Saga, Error>where
Publisher: ActionPublisher<A, Error>,
Saga: ActionComputation<AR, A>,
Source§fn compute_new_actions(&self, action_result: &AR) -> Vec<A>
fn compute_new_actions(&self, action_result: &AR) -> Vec<A>
Computes new actions based on the action result.
Source§impl<A, AR, Publisher, Saga, Error> ActionPublisher<A, Error> for SagaManager<A, AR, Publisher, Saga, Error>where
Publisher: ActionPublisher<A, Error> + Sync,
Saga: ActionComputation<AR, A> + Sync,
A: Sync,
AR: Sync,
Error: Sync,
impl<A, AR, Publisher, Saga, Error> ActionPublisher<A, Error> for SagaManager<A, AR, Publisher, Saga, Error>where
Publisher: ActionPublisher<A, Error> + Sync,
Saga: ActionComputation<AR, A> + Sync,
A: Sync,
AR: Sync,
Error: Sync,
Auto Trait Implementations§
impl<A, AR, Publisher, Saga, Error> Freeze for SagaManager<A, AR, Publisher, Saga, Error>
impl<A, AR, Publisher, Saga, Error> RefUnwindSafe for SagaManager<A, AR, Publisher, Saga, Error>where
Publisher: RefUnwindSafe,
Saga: RefUnwindSafe,
A: RefUnwindSafe,
AR: RefUnwindSafe,
Error: RefUnwindSafe,
impl<A, AR, Publisher, Saga, Error> Send for SagaManager<A, AR, Publisher, Saga, Error>
impl<A, AR, Publisher, Saga, Error> Sync for SagaManager<A, AR, Publisher, Saga, Error>
impl<A, AR, Publisher, Saga, Error> Unpin for SagaManager<A, AR, Publisher, Saga, Error>
impl<A, AR, Publisher, Saga, Error> UnwindSafe for SagaManager<A, AR, Publisher, Saga, 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