Interface IReadModels
- Namespace
- Cratis.Chronicle.ReadModels
- Assembly
- Cratis.Chronicle.dll
Defines a system that works with read models in the system.
public interface IReadModels
Methods
DehydrateSession(ReadModelSessionId, Type, ReadModelKey)
Dehydrate a session.
Task DehydrateSession(ReadModelSessionId sessionId, Type readModelType, ReadModelKey readModelKey)
Parameters
sessionIdReadModelSessionIdThe ReadModelSessionId to dehydrate.
readModelTypeTypeType of read model.
readModelKeyReadModelKeyReadModelKey to dehydrate for.
Returns
- Task
Awaitable task.
GetInstanceById(Type, ReadModelKey, ReadModelSessionId?)
Get a read model instance by its key.
Task<object> GetInstanceById(Type readModelType, ReadModelKey key, ReadModelSessionId? sessionId = null)
Parameters
readModelTypeTypeThe read model type.
keyReadModelKeyThe ReadModelKey to get instance for.
sessionIdReadModelSessionIdOptional ReadModelSessionId to get for a specific session.
Returns
GetInstanceById<TReadModel>(ReadModelKey, ReadModelSessionId?)
Get a read model instance by its key.
Task<TReadModel> GetInstanceById<TReadModel>(ReadModelKey key, ReadModelSessionId? sessionId = null)
Parameters
keyReadModelKeyThe ReadModelKey to get instance for.
sessionIdReadModelSessionIdOptional ReadModelSessionId to get for a specific session.
Returns
- Task<TReadModel>
The read model instance.
Type Parameters
TReadModelThe read model type.
GetInstances<TReadModel>(EventCount?)
Get all instances of a read model by applying all events.
Task<IEnumerable<TReadModel>> GetInstances<TReadModel>(EventCount? eventCount = null)
Parameters
eventCountEventCountOptional maximum number of events to process. Defaults to Unlimited.
Returns
- Task<IEnumerable<TReadModel>>
Collection of read model instances.
Type Parameters
TReadModelThe read model type.
GetSnapshotsById<TReadModel>(ReadModelKey)
Get snapshots of a read model grouped by CorrelationId by walking through events from the beginning.
Task<IEnumerable<ReadModelSnapshot<TReadModel>>> GetSnapshotsById<TReadModel>(ReadModelKey readModelKey)
Parameters
readModelKeyReadModelKeyReadModelKey to get snapshots for.
Returns
- Task<IEnumerable<ReadModelSnapshot<TReadModel>>>
Collection of ReadModelSnapshot<TReadModel>.
Type Parameters
TReadModelType of read model.
Register()
Register the read models in the system.
Task Register()
Returns
- Task
An awaitable task.
Register<TReadModel>()
Register a specific read model type.
Task Register<TReadModel>()
Returns
- Task
An awaitable task.
Type Parameters
TReadModelThe type of the read model to register.
Watch<TReadModel>()
Observe changes for a specific read model.
IObservable<ReadModelChangeset<TReadModel>> Watch<TReadModel>()
Returns
- IObservable<ReadModelChangeset<TReadModel>>
An observable of ReadModelChangeset<TReadModel>.
Type Parameters
TReadModelType of read model to observe changes for.