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 implementingCommandLogicthat defines the business operationS- An event store implementingEventStorefor persistence
§Parameters
store- The event store for reading/writing eventscommand- The command to executepolicy- 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