Table of Contents

Interface IProjectionRebuildService

Namespace
Excalibur.EventSourcing.Projections
Assembly
Excalibur.EventSourcing.dll

Provides projection rebuilding capabilities for replaying events and regenerating projection state from scratch.

public interface IProjectionRebuildService

Remarks

Projection rebuilding is necessary when:

  • A projection's event handlers have been modified
  • A projection has become corrupted
  • A new projection type is introduced for existing events

The rebuild process replays all events through the projection handlers, replacing the existing projection state. Use GetStatusAsync<TProjection>(CancellationToken) or GetAllStatusesAsync(CancellationToken) to monitor progress.

Methods

GetAllStatusesAsync(CancellationToken)

Gets the current rebuild status for all projections that have been rebuilt or are currently rebuilding.

Task<IReadOnlyList<ProjectionRebuildStatus>> GetAllStatusesAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Cancellation token.

Returns

Task<IReadOnlyList<ProjectionRebuildStatus>>

A read-only collection of rebuild statuses. Empty if no rebuilds have been initiated.

GetStatusAsync<TProjection>(CancellationToken)

Gets the current rebuild status for a specific projection type.

Task<ProjectionRebuildStatus> GetStatusAsync<TProjection>(CancellationToken cancellationToken) where TProjection : class

Parameters

cancellationToken CancellationToken

Cancellation token.

Returns

Task<ProjectionRebuildStatus>

The rebuild status for the specified projection, or a status with Idle if no rebuild has been initiated for this type.

Type Parameters

TProjection

The projection type to query.

RebuildAsync<TProjection>(CancellationToken)

Rebuilds a projection by replaying all events through its handlers.

[RequiresUnreferencedCode("Rebuilding re-folds the event stream and persists the result through IProjectionStore, which serializes the projection type reflectively; the rebuild path does not consult the source-generated projection-store capability. Run rebuilds from a host that permits reflection.")]
[RequiresDynamicCode("Rebuilding re-folds the event stream and persists the result through IProjectionStore, which serializes the projection type reflectively; the rebuild path does not consult the source-generated projection-store capability. Run rebuilds from a host that permits reflection.")]
Task RebuildAsync<TProjection>(CancellationToken cancellationToken) where TProjection : class, new()

Parameters

cancellationToken CancellationToken

Cancellation token.

Returns

Task

A task representing the asynchronous rebuild operation.

Type Parameters

TProjection

The projection type to rebuild.

Remarks

Rebuilding writes the rebuilt read model through IProjectionStore, which serializes TProjection reflectively, and the rebuild path does not consult the source-generated projection-store capability. A trimmed or Native AOT host therefore cannot perform a rebuild: run it from a host that permits reflection while the trimmed host serves reads.

Exceptions

NotSupportedException

The projection uses TransactionalInline. Global-stream rebuilding cannot preserve its event-transaction ownership.