execute

Function execute 

Source
pub async fn execute<C, S>(
    store: S,
    command: C,
    policy: RetryPolicy,
) -> Result<ExecutionResponse, CommandError>
where C: CommandLogic, S: EventStore,
Expand description

Execute a command against the event store with a custom retry policy.

This is the primary entry point for EventCore. It orchestrates the complete command execution workflow: loading state from multiple streams, validating business rules, and atomically committing resulting events.

§Type Parameters

  • C - A command implementing CommandLogic that defines the business operation
  • S - An event store implementing EventStore for persistence

§Parameters

  • store - The event store for reading/writing events
  • command - The command to execute
  • policy - Retry policy configuration (max attempts, backoff strategy, etc.)

§Errors

Returns CommandError if:

  • Stream resolution fails
  • Event loading fails
  • Business rule validation fails (via command’s handle())
  • Event persistence fails
  • Optimistic concurrency conflicts occur after exhausting retries