pub struct CommandBus<A: Aggregate> { /* private fields */ }Expand description
Command bus for dispatching commands to aggregates.
Implementations§
Source§impl<A: Aggregate> CommandBus<A>
impl<A: Aggregate> CommandBus<A>
pub fn new( event_store: Box<dyn EventStore>, event_bus: Box<dyn EventBus>, ) -> Self
Sourcepub fn with_snapshot_policy(self, policy: SnapshotPolicy) -> Self
pub fn with_snapshot_policy(self, policy: SnapshotPolicy) -> Self
Enable (or change) the snapshot policy for this bus. Snapshots are a rehydrate-path cache only; toggling this never alters command results.
Sourcepub async fn dispatch(
&self,
command: A::Command,
context: CommandContext,
) -> CommandBusResult<Vec<Event>>
pub async fn dispatch( &self, command: A::Command, context: CommandContext, ) -> CommandBusResult<Vec<Event>>
Dispatch a command with its request-scoped CommandContext.
Steps: load → reconstruct → handle → stamp audit → append → publish.
The aggregate’s handle() returns events with placeholder audit; this
method overwrites it with a single validated AuditMetadata per
dispatch (all events from one command share the same audit stamp).
pub fn event_store(&self) -> &dyn EventStore
pub fn event_bus(&self) -> &dyn EventBus
Auto Trait Implementations§
impl<A> !RefUnwindSafe for CommandBus<A>
impl<A> !UnwindSafe for CommandBus<A>
impl<A> Freeze for CommandBus<A>
impl<A> Send for CommandBus<A>
impl<A> Sync for CommandBus<A>
impl<A> Unpin for CommandBus<A>where
A: Unpin,
impl<A> UnsafeUnpin for CommandBus<A>
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