Interface IProjections
- Namespace
- Cratis.Chronicle.Projections
- Assembly
- Cratis.Chronicle.dll
Defines a system that works with projections in the system.
public interface IProjections
- Extension Methods
Methods
Discover()
Discover all projections from entry assembly and dependencies.
Task Discover()
Returns
- Task
Awaitable task.
FastForward(ProjectionId)
Fast forward a specific projection by its identifier to the tail of the event log, skipping every event it has not yet handled without invoking it.
Task<FastForwardResult> FastForward(ProjectionId projectionId)
Parameters
projectionIdProjectionIdProjectionId to fast forward.
Returns
- Task<FastForwardResult>
The FastForwardResult describing what happened.
FastForward<TProjection>()
Fast forward a projection to the tail of the event log, skipping every event it has not yet handled without invoking it.
Task<FastForwardResult> FastForward<TProjection>() where TProjection : IProjection
Returns
- Task<FastForwardResult>
The FastForwardResult describing what happened.
Type Parameters
TProjectionType of projection to fast forward.
GetAllHandlers()
Get all registered handlers.
IEnumerable<IProjectionHandler> GetAllHandlers()
Returns
- IEnumerable<IProjectionHandler>
Collection of IProjectionHandler.
GetExternalEventStoreSubscriptions()
Get the external event store subscription requirements derived from all discovered projection definitions.
IEnumerable<(string EventStoreName, IEnumerable<EventTypeId> EventTypeIds)> GetExternalEventStoreSubscriptions()
Returns
- IEnumerable<(string EventStoreName, IEnumerable<EventTypeId> EventTypeIds)>
A collection of tuples mapping external event store names to their event type identifiers.
Remarks
Returns one entry per external event store name, collecting all event type identifiers used by projections whose event sequence is an inbox sequence for that store.
GetFailedPartitionsFor(Type)
Get any failed partitions for a specific projection.
Task<IEnumerable<FailedPartition>> GetFailedPartitionsFor(Type projectionType)
Parameters
projectionTypeTypeType of projection, or the type of read model it projects to.
Returns
- Task<IEnumerable<FailedPartition>>
Collection of FailedPartition, if any.
Remarks
This one accepts either handle. It only ever resolved read model types, so narrowing it to what its parameter name says would break every caller it has - and model-bound projections, which have no projection type at all, would lose their only handle. Prefer GetFailedPartitionsForModel(Type) or GetFailedPartitionsFor<TProjection>(), which each say which handle they take.
GetFailedPartitionsForModel(Type)
Get any failed partitions for the projection that maintains a specific read model.
Task<IEnumerable<FailedPartition>> GetFailedPartitionsForModel(Type readModelType)
Parameters
readModelTypeTypeType of read model to get for.
Returns
- Task<IEnumerable<FailedPartition>>
Collection of FailedPartition, if any.
GetFailedPartitionsForModel<TReadModel>()
Get any failed partitions for the projection that maintains a specific read model.
Task<IEnumerable<FailedPartition>> GetFailedPartitionsForModel<TReadModel>()
Returns
- Task<IEnumerable<FailedPartition>>
Collection of FailedPartition, if any.
Type Parameters
TReadModelType of read model to get for.
GetFailedPartitionsFor<TProjection>()
Get any failed partitions for a specific projection.
Task<IEnumerable<FailedPartition>> GetFailedPartitionsFor<TProjection>() where TProjection : IProjection
Returns
- Task<IEnumerable<FailedPartition>>
Collection of FailedPartition, if any.
Type Parameters
TProjectionType of projection.
GetHandlerFor<TProjection>()
Get the IProjectionHandler for a specific projection type.
IProjectionHandler GetHandlerFor<TProjection>() where TProjection : IProjection
Returns
- IProjectionHandler
IProjectionHandler for the projection.
Type Parameters
TProjectionType of projection to get for.
GetProjectionIdForModel(Type)
Get the ProjectionId for a specific type.
ProjectionId GetProjectionIdForModel(Type readModelType)
Parameters
readModelTypeTypeType of read model to get for.
Returns
- ProjectionId
The ProjectionId for the type.
GetProjectionIdForModel<TReadModel>()
Get the ProjectionId for a specific type.
ProjectionId GetProjectionIdForModel<TReadModel>()
Returns
- ProjectionId
The ProjectionId for the type.
Type Parameters
TReadModelType of read model to get for.
GetProjectionIdFor<TProjection>()
Get the ProjectionId for a specific type.
ProjectionId GetProjectionIdFor<TProjection>() where TProjection : IProjection
Returns
- ProjectionId
The ProjectionId for the type.
Type Parameters
TProjectionType of projection to get for.
GetStateForModel(Type)
Get the state of the projection that maintains a specific read model.
Task<ProjectionState> GetStateForModel(Type readModelType)
Parameters
readModelTypeTypeType of read model to get for.
Returns
GetStateForModel<TReadModel>()
Get the state of the projection that maintains a specific read model.
Task<ProjectionState> GetStateForModel<TReadModel>()
Returns
Type Parameters
TReadModelType of read model to get for.
Remarks
Model-bound projections are declared on the read model and have no type of their own, so this is the only way to ask for their state. Fluent projections answer to it as well, by the model they project to.
GetStateFor<TProjection>()
Get the state of a specific projection.
Task<ProjectionState> GetStateFor<TProjection>() where TProjection : IProjection
Returns
Type Parameters
TProjectionType of projection get for.
Remarks
A model-bound projection has no projection type to name here - use GetStateForModel<TReadModel>() for those.
HasFor(ProjectionId)
Check if there is a definition for a specific projection identifier.
bool HasFor(ProjectionId projectionId)
Parameters
projectionIdProjectionIdIdentifier of projection.
Returns
- bool
True if it exists, false if not.
HasFor(Type)
Check if there is a definition for a specific type.
bool HasFor(Type readModelType)
Parameters
readModelTypeTypeType of read model to check for.
Returns
- bool
True if it exists, false if not.
HasFor<TReadModel>()
Check if there is a definition for a specific type.
bool HasFor<TReadModel>()
Returns
- bool
True if it exists, false if not.
Type Parameters
TReadModelType of read model to check for.
Query(string, string)
Query a projection declaration against the event log without registering it.
Task<ProjectionQueryResult> Query(string declaration, string eventSequenceId = "event-log")
Parameters
declarationstringThe Projection Declaration Language string to query.
eventSequenceIdstringOptional event sequence identifier to query. Defaults to
"event-log".
Returns
- Task<ProjectionQueryResult>
A ProjectionQueryResult containing the resulting read model entries.
Remarks
The declaration may omit the => ReadModelType target — in that case the read model
schema is inferred from the events used in the projection. An inferred read model can never
be registered as a permanent projection; query-only declarations are exclusively for
ad-hoc exploration.
Exceptions
- UnableToQueryProjection
Thrown when the declaration contains errors.
Register()
Register all projections with Chronicle.
Task Register()
Returns
- Task
Awaitable task.
Register<TReadModel>()
Register the model-bound projection declared by the attributes on a read model explicitly, for a read model that is not among the discovered artifacts.
Task<IProjectionHandler> Register<TReadModel>()
Returns
- Task<IProjectionHandler>
The IProjectionHandler for the projection.
Type Parameters
TReadModelType of read model carrying the model-bound projection attributes.
Remarks
A read model that discovery already found is not registered twice - its existing handler is returned. The
projection is identified by the full name of TReadModel, as a discovered one is, and it is
sent to Chronicle and included in later registration passes the same way
Register<TReadModel>(Action<IProjectionBuilderFor<TReadModel>>, ProjectionId?) describes.
Exceptions
- ReadModelIsNotModelBound
Thrown when
TReadModelhas no model-bound projection attributes.- ReadModelAlreadyHasProjection
Thrown when a different projection already maintains
TReadModel.- VariantReadModelsCannotBeRegisteredExplicitly
Thrown when
TReadModelis a variant.
Register<TReadModel>(Action<IProjectionBuilderFor<TReadModel>>, ProjectionId?)
Register a projection for a read model explicitly, defining it through the same builder an IProjectionFor<TReadModel> uses, without the read model or the projection having to be discovered.
Task<IProjectionHandler> Register<TReadModel>(Action<IProjectionBuilderFor<TReadModel>> define, ProjectionId? id = null)
Parameters
defineAction<IProjectionBuilderFor<TReadModel>>Callback that defines the projection on the IProjectionBuilderFor<TReadModel>.
idProjectionIdOptional ProjectionId. Defaults to the full name of
TReadModel, which is also what a model-bound projection for it would be identified by.
Returns
- Task<IProjectionHandler>
The IProjectionHandler for the registered projection.
Type Parameters
TReadModelType of read model the projection maintains.
Remarks
The result is an ordinary projection and read model: IReadModels reads it, watches it and resolves it by key exactly as it does a discovered one, and a projection defined with Passive() is computed on demand rather than materialized.
The definition is built immediately, so a mistake in it surfaces here. When the client is connected the read model and projection are sent to Chronicle before this returns. Either way the registration becomes part of every later discovery and registration pass, including the one that runs when the connection is re-established. Registering the same projection identifier for the same read model again replaces its definition.
Exceptions
- ReadModelAlreadyHasProjection
Thrown when another projection already maintains
TReadModel.- VariantReadModelsCannotBeRegisteredExplicitly
Thrown when the definition declares
TReadModela variant.
Replay(ProjectionId)
Replay a specific projection by its identifier.
Task<JobId> Replay(ProjectionId projectionId)
Parameters
projectionIdProjectionIdProjectionId to replay.
Returns
- Task<JobId>
The JobId of the replay job that was started or resumed, or NotSet if the projection is not replayable or its observer is not in a state it can replay from (disconnected, quarantined); reconnect or release it before replaying.
Replay<TProjection>()
Replay a specific projection.
Task<JobId> Replay<TProjection>() where TProjection : IProjection
Returns
- Task<JobId>
The JobId of the replay job that was started or resumed, or NotSet if the projection is not replayable or its observer is not in a state it can replay from (disconnected, quarantined); reconnect or release it before replaying.
Type Parameters
TProjectionType of projection to replay.