Table of Contents

Class Projections

Namespace
Cratis.Chronicle.Projections
Assembly
Cratis.Chronicle.dll

Represents an implementation of IProjections.

public class Projections : IProjections
Inheritance
Projections
Implements
Inherited Members
Extension Methods

Remarks

Initializes a new instance of the Projections class.

Constructors

Projections(IEventStore, IEventTypes, IClientArtifactsProvider, INamingPolicy, IClientArtifactsActivator, JsonSerializerOptions, ILogger<Projections>)

Represents an implementation of IProjections.

public Projections(IEventStore eventStore, IEventTypes eventTypes, IClientArtifactsProvider clientArtifacts, INamingPolicy namingPolicy, IClientArtifactsActivator artifactsActivator, JsonSerializerOptions jsonSerializerOptions, ILogger<Projections> logger)

Parameters

eventStore IEventStore

IEventStore the projections belongs to.

eventTypes IEventTypes

All the IEventTypes.

clientArtifacts IClientArtifactsProvider

Optional IClientArtifactsProvider for the client artifacts.

namingPolicy INamingPolicy

The INamingPolicy to use for converting names during serialization.

artifactsActivator IClientArtifactsActivator

IClientArtifactsActivator for activating instances of projections.

jsonSerializerOptions JsonSerializerOptions

The JsonSerializerOptions to use for any JSON serialization.

logger ILogger<Projections>

ILogger<TCategoryName> for logging.

Remarks

Initializes a new instance of the Projections class.

Methods

Discover()

Discover all projections from entry assembly and dependencies.

public Task Discover()

Returns

Task

Awaitable task.

GetAllHandlers()

Get all registered handlers.

public IEnumerable<IProjectionHandler> GetAllHandlers()

Returns

IEnumerable<IProjectionHandler>

Collection of IProjectionHandler.

GetExternalEventStoreSubscriptions()

Get the external event store subscription requirements derived from all discovered projection definitions.

public 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.

public Task<IEnumerable<FailedPartition>> GetFailedPartitionsFor(Type projectionType)

Parameters

projectionType Type

Type of projection.

Returns

Task<IEnumerable<FailedPartition>>

Collection of FailedPartition, if any.

GetFailedPartitionsFor<TProjection>()

Get any failed partitions for a specific projection.

public Task<IEnumerable<FailedPartition>> GetFailedPartitionsFor<TProjection>() where TProjection : IProjection

Returns

Task<IEnumerable<FailedPartition>>

Collection of FailedPartition, if any.

Type Parameters

TProjection

Type of projection.

GetHandlerFor<TProjection>()

Get the IProjectionHandler for a specific projection type.

public IProjectionHandler GetHandlerFor<TProjection>() where TProjection : IProjection

Returns

IProjectionHandler

IProjectionHandler for the projection.

Type Parameters

TProjection

Type of projection to get for.

GetProjectionIdForModel(Type)

Get the ProjectionId for a specific type.

public ProjectionId GetProjectionIdForModel(Type readModelType)

Parameters

readModelType Type

Type of read model to get for.

Returns

ProjectionId

The ProjectionId for the type.

GetProjectionIdForModel<TReadModel>()

Get the ProjectionId for a specific type.

public ProjectionId GetProjectionIdForModel<TReadModel>()

Returns

ProjectionId

The ProjectionId for the type.

Type Parameters

TReadModel

Type of read model to get for.

GetProjectionIdFor<TProjection>()

Get the ProjectionId for a specific type.

public ProjectionId GetProjectionIdFor<TProjection>() where TProjection : IProjection

Returns

ProjectionId

The ProjectionId for the type.

Type Parameters

TProjection

Type of projection to get for.

GetStateFor<TProjection>()

Get the state of a specific projection.

public Task<ProjectionState> GetStateFor<TProjection>() where TProjection : IProjection

Returns

Task<ProjectionState>

ProjectionState.

Type Parameters

TProjection

Type of projection get for.

HasFor(ProjectionId)

Check if there is a definition for a specific projection identifier.

public bool HasFor(ProjectionId projectionId)

Parameters

projectionId ProjectionId

Identifier of projection.

Returns

bool

True if it exists, false if not.

HasFor(Type)

Check if there is a definition for a specific type.

public bool HasFor(Type readModelType)

Parameters

readModelType Type

Type 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.

public bool HasFor<TReadModel>()

Returns

bool

True if it exists, false if not.

Type Parameters

TReadModel

Type of read model to check for.

Query(string, string)

Query a projection declaration against the event log without registering it.

public Task<ProjectionQueryResult> Query(string declaration, string eventSequenceId = "event-log")

Parameters

declaration string

The Projection Declaration Language string to query.

eventSequenceId string

Optional 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.

public Task Register()

Returns

Task

Awaitable task.

Replay(ProjectionId)

Replay a specific projection by its identifier.

public Task Replay(ProjectionId projectionId)

Parameters

projectionId ProjectionId

ProjectionId to replay.

Returns

Task

Awaitable task.

Replay<TProjection>()

Replay a specific projection.

public Task Replay<TProjection>() where TProjection : IProjection

Returns

Task

Awaitable task.

Type Parameters

TProjection

Type of projection to replay.