pub struct EventSourcedBehavior<C, E, S, J = E> { /* private fields */ }Expand description
Immutable, side-effect-free event-sourced behavior blueprint.
Implementations§
Source§impl<C, E, S> EventSourcedBehavior<C, E, S, E>
impl<C, E, S> EventSourcedBehavior<C, E, S, E>
Sourcepub fn new<CH, EH, O>(
persistence_id: PersistenceId,
empty_state: S,
command_handler: CH,
event_handler: EH,
) -> Self
pub fn new<CH, EH, O>( persistence_id: PersistenceId, empty_state: S, command_handler: CH, event_handler: EH, ) -> Self
Creates a side-effect-free behavior blueprint.
A serializer/adapter is selected separately with
Self::with_event_adapter; no journal, snapshot, topic, actor, or task
is touched until Self::spawn.
Sourcepub fn with_enforced_replies<CH, EH, O>(
persistence_id: PersistenceId,
empty_state: S,
command_handler: CH,
event_handler: EH,
) -> Self
pub fn with_enforced_replies<CH, EH, O>( persistence_id: PersistenceId, empty_state: S, command_handler: CH, event_handler: EH, ) -> Self
Creates a blueprint whose command handler must return a ReplyEffect.
Source§impl<C, E, S, J> EventSourcedBehavior<C, E, S, J>
impl<C, E, S, J> EventSourcedBehavior<C, E, S, J>
Sourcepub fn with_event_adapter<J2, A>(
self,
adapter: A,
catalog: SerializerCatalog<J2>,
) -> EventSourcedBehavior<C, E, S, J2>where
A: EventAdapter<E, J2>,
J2: 'static,
pub fn with_event_adapter<J2, A>(
self,
adapter: A,
catalog: SerializerCatalog<J2>,
) -> EventSourcedBehavior<C, E, S, J2>where
A: EventAdapter<E, J2>,
J2: 'static,
Selects an event adapter and serializer catalog, possibly changing J.
Sourcepub fn with_state_adapter<SJ, A>(
self,
adapter: A,
catalog: SerializerCatalog<SJ>,
) -> Selfwhere
A: StateAdapter<S, SJ>,
SJ: 'static,
S: 'static,
pub fn with_state_adapter<SJ, A>(
self,
adapter: A,
catalog: SerializerCatalog<SJ>,
) -> Selfwhere
A: StateAdapter<S, SJ>,
SJ: 'static,
S: 'static,
Selects the state adapter and serializer catalog used for snapshots.
Sourcepub fn snapshot_when<F>(self, predicate: F) -> Self
pub fn snapshot_when<F>(self, predicate: F) -> Self
Saves a snapshot after a batch when any post-event predicate invocation matches.
Sourcepub fn with_retention(self, retention: RetentionCriteria) -> Self
pub fn with_retention(self, retention: RetentionCriteria) -> Self
Configures count-based snapshots and asynchronous cleanup.
Sourcepub fn with_tagger<F>(self, tagger: F) -> Self
pub fn with_tagger<F>(self, tagger: F) -> Self
Tags stored events using the domain event.
Sourcepub fn with_state_tagger<F>(self, tagger: F) -> Self
pub fn with_state_tagger<F>(self, tagger: F) -> Self
Tags stored events using post-event state and the domain event.
Sourcepub fn on_persist_failure(self, settings: RestartSettings) -> Self
pub fn on_persist_failure(self, settings: RestartSettings) -> Self
Restarts this persistent behavior with recovery after journal failures.
Exponential delay, jitter, restart limits, and reset windows come from
Datum’s shared RestartSettings. The actor remains responsive during
the delayed backoff and automatically stashes domain commands.
Sourcepub fn with_recovery(self, recovery: Recovery) -> Self
pub fn with_recovery(self, recovery: Recovery) -> Self
Changes recovery mode and snapshot selection.
Sourcepub fn with_event_publishing(self, enabled: bool) -> Self
pub fn with_event_publishing(self, enabled: bool) -> Self
Enables or disables confirmed domain-event publishing (enabled by default).
Sourcepub fn with_stash_capacity(self, capacity: usize) -> Self
pub fn with_stash_capacity(self, capacity: usize) -> Self
Sets the manual stash capacity.
Overflow follows Akka’s default drop strategy: the newest command is
dropped and chained effects registered on that stash decision do not
run. If it owns a ReplyPort, dropping that command closes the port.
Source§impl<C, E, S, J> EventSourcedBehavior<C, E, S, J>
impl<C, E, S, J> EventSourcedBehavior<C, E, S, J>
Sourcepub async fn spawn(
self,
runtime: EventSourcedRuntime,
) -> PersistenceResult<EventSourcedHandle<C, E, S>>
pub async fn spawn( self, runtime: EventSourcedRuntime, ) -> PersistenceResult<EventSourcedHandle<C, E, S>>
Spawns the Ractor runtime and begins recovery.
Sourcepub async fn run_on(
self,
runtime: EventSourcedRuntime,
) -> PersistenceResult<EventSourcedHandle<C, E, S>>
pub async fn run_on( self, runtime: EventSourcedRuntime, ) -> PersistenceResult<EventSourcedHandle<C, E, S>>
Alias for Self::spawn emphasizing execution on the active Tokio runtime.