Table of Contents

Interface IProjectionRebuilder

Namespace
Opossum.Projections
Assembly
Opossum.dll

Manages projection rebuild operations, including full rebuilds, selective rebuilds, and crash recovery. This interface is the single entry point for all rebuild-related functionality, cleanly separated from the live event processing managed by IProjectionManager.

public interface IProjectionRebuilder

Methods

GetRebuildStatusAsync()

Gets the current rebuild status, including which projections are currently being rebuilt, which are queued, and estimated completion time.

Task<ProjectionRebuildStatus> GetRebuildStatusAsync()

Returns

Task<ProjectionRebuildStatus>

A ProjectionRebuildStatus snapshot of the current rebuild state.

RebuildAllAsync(bool, CancellationToken)

Rebuilds all registered projections in parallel, respecting the MaxConcurrentRebuilds configuration limit.

Task<ProjectionRebuildResult> RebuildAllAsync(bool forceRebuild = false, CancellationToken cancellationToken = default)

Parameters

forceRebuild bool

If true, rebuilds every registered projection regardless of its current checkpoint. If false, only rebuilds projections whose checkpoint is at position 0 (i.e., never built or previously cleared).

cancellationToken CancellationToken

Cancellation token to abort the rebuild.

Returns

Task<ProjectionRebuildResult>

A ProjectionRebuildResult summarising all individual projection rebuilds, including which succeeded and which failed.

RebuildAsync(string, CancellationToken)

Rebuilds a single projection from scratch by replaying all events from position 0. The existing projection data is replaced atomically on successful completion.

Task<ProjectionRebuildResult> RebuildAsync(string projectionName, CancellationToken cancellationToken = default)

Parameters

projectionName string

The name of the registered projection to rebuild. Must match a projection previously registered via RegisterProjection<TState>(IProjectionDefinition<TState>).

cancellationToken CancellationToken

Cancellation token to abort the rebuild.

Returns

Task<ProjectionRebuildResult>

A ProjectionRebuildResult containing timing, event count, and success/failure details for the rebuilt projection.

RebuildAsync(string[], CancellationToken)

Rebuilds a specific set of projections in parallel. Useful for selectively rebuilding projections after a bug fix without affecting other projections. Respects the MaxConcurrentRebuilds configuration limit.

Task<ProjectionRebuildResult> RebuildAsync(string[] projectionNames, CancellationToken cancellationToken = default)

Parameters

projectionNames string[]

Names of the projections to rebuild. Each name must match a projection previously registered via RegisterProjection<TState>(IProjectionDefinition<TState>).

cancellationToken CancellationToken

Cancellation token to abort the rebuild.

Returns

Task<ProjectionRebuildResult>

A ProjectionRebuildResult summarising all individual projection rebuilds, including which succeeded and which failed.

ResumeInterruptedRebuildsAsync(CancellationToken)

Scans for interrupted rebuild journals and resumes any rebuilds that were in progress when the application last shut down or crashed. Completed rebuilds whose journals are still present are committed; orphaned temp directories with no matching journal are cleaned up.

This method is called automatically by ProjectionDaemon on startup before RebuildAllAsync(bool, CancellationToken) and is not intended for direct use by application code. Calling it manually is safe but unnecessary when the daemon is running.

Task ResumeInterruptedRebuildsAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancellation token to abort the recovery operation.

Returns

Task

A task that completes when all interrupted rebuilds have been resumed or discarded.