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, IProjectionWatcherManager, IClientArtifactsProvider, IJsonSchemaGenerator, IModelNameResolver, IEventSerializer, IServiceProvider, JsonSerializerOptions)
Represents an implementation of IProjections.
public Projections(IEventStore eventStore, IEventTypes eventTypes, IProjectionWatcherManager projectionWatcherManager, IClientArtifactsProvider clientArtifacts, IJsonSchemaGenerator schemaGenerator, IModelNameResolver modelNameResolver, IEventSerializer eventSerializer, IServiceProvider serviceProvider, JsonSerializerOptions jsonSerializerOptions)
Parameters
eventStore
IEventStoreIEventStore the projections belongs to.
eventTypes
IEventTypesAll the IEventTypes.
projectionWatcherManager
IProjectionWatcherManagerIProjectionWatcherManager for managing watchers.
clientArtifacts
IClientArtifactsProviderOptional IClientArtifactsProvider for the client artifacts.
schemaGenerator
IJsonSchemaGeneratorIJsonSchemaGenerator for generating JSON schemas.
modelNameResolver
IModelNameResolverThe IModelNameConvention to use for naming the models.
eventSerializer
IEventSerializerIEventSerializer for serializing events.
serviceProvider
IServiceProviderIServiceProvider for getting instances of projections.
jsonSerializerOptions
JsonSerializerOptionsThe JsonSerializerOptions to use for any JSON serialization.
Remarks
Initializes a new instance of the Projections class.
Methods
DehydrateSession(ProjectionSessionId, Type, ModelKey)
Dehydrate a session.
public Task DehydrateSession(ProjectionSessionId sessionId, Type modelType, ModelKey modelKey)
Parameters
sessionId
ProjectionSessionIdThe ProjectionSessionId to dehydrate.
modelType
TypeType of model the projection is for.
modelKey
ModelKeyModelKey to get instance for.
Returns
- Task
Awaitable task.
Discover()
Discover all projections from entry assembly and dependencies.
public Task Discover()
Returns
- Task
Awaitable task.
GetFailedPartitionsFor(Type)
Get any failed partitions for a specific projection.
public Task<IEnumerable<FailedPartition>> GetFailedPartitionsFor(Type projectionType)
Parameters
projectionType
TypeType 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.
GetInstanceById(ProjectionId, ModelKey)
Get an instance by a specific ModelKey for a specific ProjectionId.
public Task<ProjectionResultRaw> GetInstanceById(ProjectionId identifier, ModelKey modelKey)
Parameters
identifier
ProjectionIdProjectionId to get for.
modelKey
ModelKeyModelKey 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.
public Task<ProjectionResult> GetInstanceById(Type modelType, ModelKey modelKey)
Parameters
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.
public Task<ProjectionResult> GetInstanceByIdForSession(ProjectionSessionId sessionId, Type modelType, ModelKey modelKey)
Parameters
sessionId
ProjectionSessionIdThe ProjectionSessionId to get for.
modelType
TypeType of model the projection is for.
modelKey
ModelKeyModelKey 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.
public Task<ProjectionResult> GetInstanceByIdForSessionWithEventsApplied(ProjectionSessionId sessionId, Type modelType, ModelKey modelKey, IEnumerable<object> events)
Parameters
sessionId
ProjectionSessionIdThe ProjectionSessionId to get for.
modelType
TypeType of model the projection is for.
modelKey
ModelKeyModelKey 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.
public Task<ProjectionResult<TModel>> GetInstanceById<TModel>(ModelKey modelKey)
Parameters
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.
public ProjectionId GetProjectionIdForModel(Type modelType)
Parameters
modelType
TypeType of model to get for.
Returns
- ProjectionId
The ProjectionId for the type.
GetProjectionIdForModel<TModelType>()
Get the ProjectionId for a specific type.
public ProjectionId GetProjectionIdForModel<TModelType>()
Returns
- ProjectionId
The ProjectionId for the type.
Type Parameters
TModelType
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
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
ProjectionIdIdentifier 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 modelType)
Parameters
modelType
TypeType of model to check for.
Returns
- bool
True if it exists, false if not.
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
ProjectionIdProjectionId 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.
Watch<TModel>()
Observe changes for a specific model with optionally a specific ModelKey.
public IObservable<ProjectionChangeset<TModel>> Watch<TModel>()
Returns
- IObservable<ProjectionChangeset<TModel>>
An observable of ProjectionChangeset<TModel>.
Type Parameters
TModel
Type of model to observe changes for.