pub async fn run_projection<P, B>(
projector: P,
backend: &B,
) -> Result<(), ProjectionError>where
P: Projector,
P::Event: Event + Clone,
P::Context: Default,
P::Error: Debug,
B: EventReader + CheckpointStore + ProjectorCoordinator,Expand description
Runs a projector against a backend that provides events, checkpoints, and coordination.
This is the primary entry point for running projections in EventCore. It orchestrates:
- Leadership acquisition via
ProjectorCoordinator - Event reading via
EventReader - Checkpoint management via
CheckpointStore
§Arguments
projector- The projector implementation to runbackend- A reference to a backend implementing EventReader, CheckpointStore, and ProjectorCoordinator
§Returns
Returns when the projector completes processing all events (batch mode), is cancelled, or encounters a fatal error.
§Example
ⓘ
// PostgreSQL provides all three traits
run_projection(my_projector, &postgres_store).await?;