Trait eventually::command::Handler
source · pub trait Handler<T>: Send + Syncwhere
T: Message,{
type Error: Send + Sync;
// Required method
fn handle<'life0, 'async_trait>(
&'life0 self,
command: Envelope<T>
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}
Expand description
A software component that is able to handle [Command]s of a certain type, and mutate the state as a result of the command handling, or fail.
In an event-sourced system, the [Command] Handler should use an Aggregate to evaluate a [Command] to ensure business invariants are respected.
Required Associated Types§
Required Methods§
sourcefn handle<'life0, 'async_trait>(
&'life0 self,
command: Envelope<T>
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn handle<'life0, 'async_trait>(
&'life0 self,
command: Envelope<T>
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Handles a [Command] and returns an error if the handling has failed.
Since [Command]s are solely modifying the state of the system, they do not return anything to the caller but the result of the operation (expressed by a Result type).