Table of Contents

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

DehydrateSession(ProjectionSessionId, Type, ModelKey)

Dehydrate a session.

Task DehydrateSession(ProjectionSessionId sessionId, Type modelType, ModelKey modelKey)

Parameters

sessionId ProjectionSessionId

The ProjectionSessionId to dehydrate.

modelType Type

Type of model the projection is for.

modelKey ModelKey

ModelKey to get instance for.

Returns

Task

Awaitable task.

Discover()

Discover all projections from entry assembly and dependencies.

Task Discover()

Returns

Task

Awaitable task.

GetFailedPartitionsFor(Type)

Get any failed partitions for a specific projection.

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.

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.

IProjectionHandler GetHandlerFor<TProjection>() where TProjection : IProjection

Returns

IProjectionHandler

IProjectionHandler for the projection.

Type Parameters

TProjection

Type of projection to get for.

GetInstanceById(ProjectionId, ModelKey)

Get an instance by a specific ModelKey for a specific ProjectionId.

Task<ProjectionResultRaw> GetInstanceById(ProjectionId identifier, ModelKey modelKey)

Parameters

identifier ProjectionId

ProjectionId to get for.

modelKey ModelKey

ModelKey to get instance for.

Returns

Task<ProjectionResultRaw>

The raw result of the projection in the form of an ProjectionResultRaw.

GetInstanceById(Type, ModelKey)

Get an instance by a specific ModelKey and type.

Task<ProjectionResult> GetInstanceById(Type modelType, ModelKey modelKey)

Parameters

modelType Type

Type of model the projection is for.

modelKey ModelKey

ModelKey to get instance for.

Returns

Task<ProjectionResult>

The result of the projection in the form of an ProjectionResult.

GetInstanceByIdForSession(ProjectionSessionId, Type, ModelKey)

Get an instance by a specific ModelKey and type for the current session.

Task<ProjectionResult> GetInstanceByIdForSession(ProjectionSessionId sessionId, Type modelType, ModelKey modelKey)

Parameters

sessionId ProjectionSessionId

The ProjectionSessionId to get for.

modelType Type

Type of model the projection is for.

modelKey ModelKey

ModelKey to get instance for.

Returns

Task<ProjectionResult>

The result of the projection in the form of an ProjectionResult.

GetInstanceByIdForSessionWithEventsApplied(ProjectionSessionId, Type, ModelKey, IEnumerable<object>)

Get the current instance for a specific ModelKey and type for the current session and apply events to it.

Task<ProjectionResult> GetInstanceByIdForSessionWithEventsApplied(ProjectionSessionId sessionId, Type modelType, ModelKey modelKey, IEnumerable<object> events)

Parameters

sessionId ProjectionSessionId

The ProjectionSessionId to get for.

modelType Type

Type of model the projection is for.

modelKey ModelKey

ModelKey to get instance for.

events IEnumerable<object>

Collection of events to apply.

Returns

Task<ProjectionResult>

The result of the projection in the form of an ProjectionResult.

GetInstanceById<TModel>(ModelKey)

Get an instance by a specific ModelKey and type specified as generic parameter.

Task<ProjectionResult<TModel>> GetInstanceById<TModel>(ModelKey modelKey)

Parameters

modelKey ModelKey

ModelKey to get instance for.

Returns

Task<ProjectionResult<TModel>>

The result of the projection in the form of an ProjectionResult.

Type Parameters

TModel

Type of model.

GetProjectionIdForModel(Type)

Get the ProjectionId for a specific type.

ProjectionId GetProjectionIdForModel(Type modelType)

Parameters

modelType Type

Type of model to get for.

Returns

ProjectionId

The ProjectionId for the type.

GetProjectionIdForModel<TModel>()

Get the ProjectionId for a specific type.

ProjectionId GetProjectionIdForModel<TModel>()

Returns

ProjectionId

The ProjectionId for the type.

Type Parameters

TModel

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

TProjection

Type of projection to get for.

GetStateFor<TProjection>()

Get the state of a specific projection.

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.

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.

bool HasFor(Type modelType)

Parameters

modelType Type

Type of model to check for.

Returns

bool

True if it exists, false if not.

Register()

Register all projections with Chronicle.

Task Register()

Returns

Task

Awaitable task.

Replay(ProjectionId)

Replay a specific projection by its identifier.

Task Replay(ProjectionId projectionId)

Parameters

projectionId ProjectionId

ProjectionId to replay.

Returns

Task

Awaitable task.

Replay<TProjection>()

Replay a specific projection.

Task Replay<TProjection>() where TProjection : IProjection

Returns

Task

Awaitable task.

Type Parameters

TProjection

Type of projection to replay.

Watch<TModel>()

Observe changes for a specific model with optionally a specific ModelKey.

IObservable<ProjectionChangeset<TModel>> Watch<TModel>()

Returns

IObservable<ProjectionChangeset<TModel>>

An observable of ProjectionChangeset<TModel>.

Type Parameters

TModel

Type of model to observe changes for.