pub struct Effect<C, E, S> { /* private fields */ }Expand description
A command decision for an EventSourcedBehavior.
One main effect is followed by zero or more side effects. Side effects retain registration order and run only after the main effect completes successfully.
Implementations§
Source§impl<C, E, S> Effect<C, E, S>
impl<C, E, S> Effect<C, E, S>
Sourcepub fn persist_with_metadata(
event: E,
metadata: Option<SerializedPayload>,
) -> Self
pub fn persist_with_metadata( event: E, metadata: Option<SerializedPayload>, ) -> Self
Persists one event with an optional already-serialized metadata frame.
Sourcepub fn persist_all(events: impl IntoIterator<Item = E>) -> Self
pub fn persist_all(events: impl IntoIterator<Item = E>) -> Self
Persists all events as one all-or-nothing atomic journal write.
Sourcepub fn persist_all_with_metadata(
events: impl IntoIterator<Item = (E, Option<SerializedPayload>)>,
) -> Self
pub fn persist_all_with_metadata( events: impl IntoIterator<Item = (E, Option<SerializedPayload>)>, ) -> Self
Persists all events and metadata as one all-or-nothing atomic journal write.
Sourcepub fn stash(command: C) -> Self
pub fn stash(command: C) -> Self
Places an owned command in the bounded in-memory manual stash.
Datum handlers consume commands so commands may own one-shot
ReplyPort values. Passing the command explicitly preserves that
ownership without imposing a Clone bound on the command type. If the
stash is full, the command is dropped and chained side effects are not
run because the main effect did not succeed.
Sourcepub fn unstash_all() -> Self
pub fn unstash_all() -> Self
Starts draining the commands that were manually stashed at this point.
Sourcepub fn reply<R>(reply_to: ReplyPort<R>, reply: R) -> ReplyEffect<C, E, S>where
R: Send + 'static,
pub fn reply<R>(reply_to: ReplyPort<R>, reply: R) -> ReplyEffect<C, E, S>where
R: Send + 'static,
Replies immediately after a successful no-persist effect.
Sourcepub fn no_reply() -> ReplyEffect<C, E, S>
pub fn no_reply() -> ReplyEffect<C, E, S>
Explicitly chooses not to reply in an enforced-replies handler.
Sourcepub fn async_effect<F>(future: F) -> Self
pub fn async_effect<F>(future: F) -> Self
Defers the command decision to an asynchronous computation.
This is the Rust-native spelling of Akka’s Effect.async; Akka readers
can treat async_effect as its direct behavioral alias.
Sourcepub fn async_reply<F>(future: F) -> ReplyEffect<C, E, S>
pub fn async_reply<F>(future: F) -> ReplyEffect<C, E, S>
Defers an enforced-replies decision to an asynchronous computation.
Sourcepub fn then_unstash_all(self) -> Self
pub fn then_unstash_all(self) -> Self
Starts a bounded drain of the current manual stash after earlier side effects.
Sourcepub fn then_reply<R, F>(
self,
reply_to: ReplyPort<R>,
reply: F,
) -> ReplyEffect<C, E, S>
pub fn then_reply<R, F>( self, reply_to: ReplyPort<R>, reply: F, ) -> ReplyEffect<C, E, S>
Sends a reply computed from the resulting state.
Sourcepub fn then_no_reply(self) -> ReplyEffect<C, E, S>
pub fn then_no_reply(self) -> ReplyEffect<C, E, S>
Explicitly records that this command will not reply.