Struct 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 / Command
  • AR - Action Result / Event
  • Publisher - Action Publisher
  • Error - 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,

Source

pub fn new(action_publisher: Publisher, saga: Saga) -> Self

Creates a new instance of SagaManager.

Source

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 an event that you react,
  • the actions are commands 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>,

Source§

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,

Source§

async fn publish(&self, action: &[A]) -> Result<Vec<A>, Error>

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> Freeze for SagaManager<A, AR, Publisher, Saga, Error>
where Publisher: Freeze, Saga: Freeze,

§

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>
where Publisher: Send, Saga: Send, A: Send, AR: Send, Error: Send,

§

impl<A, AR, Publisher, Saga, Error> Sync for SagaManager<A, AR, Publisher, Saga, Error>
where Publisher: Sync, Saga: Sync, A: Sync, AR: Sync, Error: Sync,

§

impl<A, AR, Publisher, Saga, Error> Unpin for SagaManager<A, AR, Publisher, Saga, Error>
where Publisher: Unpin, Saga: Unpin, A: Unpin, AR: Unpin, Error: Unpin,

§

impl<A, AR, Publisher, Saga, Error> UnwindSafe for SagaManager<A, AR, Publisher, Saga, Error>
where Publisher: UnwindSafe, Saga: UnwindSafe, A: UnwindSafe, AR: UnwindSafe, Error: 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.