Struct fmodel_rust::saga_manager::SagaManager
source · 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,
source§fn publish<'life0, 'life1, 'async_trait>(
&'life0 self,
action: &'life1 [A]
) -> Pin<Box<dyn Future<Output = Result<Vec<A>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn publish<'life0, 'life1, 'async_trait>(
&'life0 self,
action: &'life1 [A]
) -> Pin<Box<dyn Future<Output = Result<Vec<A>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Publishes the action/command to some external system, returning either the actions that are successfully published or error.
Auto Trait Implementations§
impl<A, AR, Publisher, Saga, Error> RefUnwindSafe for SagaManager<A, AR, Publisher, Saga, Error>where
A: RefUnwindSafe,
AR: RefUnwindSafe,
Error: RefUnwindSafe,
Publisher: RefUnwindSafe,
Saga: 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