Skip to main content

Module command_bus

Module command_bus 

Source
Expand description

§Command Bus Module

Coordinates command handling through aggregates with event persistence and publishing.

§Flow

  1. Load events from EventStore for the target aggregate
  2. Reconstruct aggregate state via Aggregate::from_events()
  3. Handle command through Aggregate::handle() to produce new events (events leave handle() with audit = AuditMetadata::pending())
  4. Stamp each event with a fully-validated AuditMetadata derived from the request-scoped CommandContext
  5. Append events to EventStore with optimistic concurrency check; the store re-validates audit (defense-in-depth)
  6. Publish events to EventBus for projections and side effects

§Audit invariant

Every persisted event carries AuditMetadata (HIPAA §164.312(b)). dispatch requires a CommandContext argument; production code cannot omit it. Internal jobs use CommandContext::system.

Structs§

CommandBus
Command bus for dispatching commands to aggregates.
CommandContext
Request-scoped context for command dispatch.

Enums§

CommandBusError
Errors that can occur during command bus operations.
SnapshotPolicy
Controls whether CommandBus maintains snapshots on the command/write rehydrate path.

Type Aliases§

CommandBusResult