Table of Contents

Class ReadModels

Namespace
Cratis.Chronicle.ReadModels
Assembly
Cratis.Chronicle.dll

Represents an implementation of IReadModels.

public class ReadModels : IReadModels
Inheritance
ReadModels
Implements
Inherited Members

Constructors

ReadModels(IEventStore, INamingPolicy, IProjections, IReducers, IEventTypes, IJsonSchemaGenerator, JsonSerializerOptions, IReadModelWatcherManager, IReducerObservers)

Represents an implementation of IReadModels.

public ReadModels(IEventStore eventStore, INamingPolicy namingPolicy, IProjections projections, IReducers reducers, IEventTypes eventTypes, IJsonSchemaGenerator schemaGenerator, JsonSerializerOptions jsonSerializerOptions, IReadModelWatcherManager readModelWatcherManager, IReducerObservers reducerObservers)

Parameters

eventStore IEventStore

The IEventStore to use.

namingPolicy INamingPolicy

The INamingPolicy to use for converting names during serialization.

projections IProjections

Projections to get read models from.

reducers IReducers

Reducers to get read models from.

eventTypes IEventTypes

The IEventTypes for resolving event types.

schemaGenerator IJsonSchemaGenerator

Schema generator to use.

jsonSerializerOptions JsonSerializerOptions

The JsonSerializerOptions to use for JSON serialization.

readModelWatcherManager IReadModelWatcherManager

IReadModelWatcherManager for managing watchers.

reducerObservers IReducerObservers

IReducerObservers for managing reducer observers.

Methods

DehydrateSession(ReadModelSessionId, Type, ReadModelKey)

Dehydrate a session.

public Task DehydrateSession(ReadModelSessionId sessionId, Type readModelType, ReadModelKey readModelKey)

Parameters

sessionId ReadModelSessionId

The ReadModelSessionId to dehydrate.

readModelType Type

Type of read model.

readModelKey ReadModelKey

ReadModelKey to dehydrate for.

Returns

Task

Awaitable task.

GetInstanceById(Type, ReadModelKey, ReadModelSessionId?)

Get a read model instance by its key.

public Task<object> GetInstanceById(Type readModelType, ReadModelKey key, ReadModelSessionId? sessionId = null)

Parameters

readModelType Type

The read model type.

key ReadModelKey

The ReadModelKey to get instance for.

sessionId ReadModelSessionId

Optional ReadModelSessionId to get for a specific session.

Returns

Task<object>

The read model instance.

GetInstanceById<TReadModel>(ReadModelKey, ReadModelSessionId?)

Get a read model instance by its key.

public Task<TReadModel> GetInstanceById<TReadModel>(ReadModelKey key, ReadModelSessionId? sessionId = null)

Parameters

key ReadModelKey

The ReadModelKey to get instance for.

sessionId ReadModelSessionId

Optional ReadModelSessionId to get for a specific session.

Returns

Task<TReadModel>

The read model instance.

Type Parameters

TReadModel

The read model type.

GetInstances<TReadModel>(EventCount?)

Get all instances of a read model by applying all events.

public Task<IEnumerable<TReadModel>> GetInstances<TReadModel>(EventCount? eventCount = null)

Parameters

eventCount EventCount

Optional maximum number of events to process. Defaults to Unlimited.

Returns

Task<IEnumerable<TReadModel>>

Collection of read model instances.

Type Parameters

TReadModel

The read model type.

GetSnapshotsById<TReadModel>(ReadModelKey)

Get snapshots of a read model grouped by CorrelationId by walking through events from the beginning.

public Task<IEnumerable<ReadModelSnapshot<TReadModel>>> GetSnapshotsById<TReadModel>(ReadModelKey readModelKey)

Parameters

readModelKey ReadModelKey

ReadModelKey to get snapshots for.

Returns

Task<IEnumerable<ReadModelSnapshot<TReadModel>>>

Collection of ReadModelSnapshot<TReadModel>.

Type Parameters

TReadModel

Type of read model.

Register()

Register the read models in the system.

public Task Register()

Returns

Task

An awaitable task.

Register<TReadModel>()

Register a specific read model type.

public Task Register<TReadModel>()

Returns

Task

An awaitable task.

Type Parameters

TReadModel

The type of the read model to register.

Watch<TReadModel>()

Observe changes for a specific read model.

public IObservable<ReadModelChangeset<TReadModel>> Watch<TReadModel>()

Returns

IObservable<ReadModelChangeset<TReadModel>>

An observable of ReadModelChangeset<TReadModel>.

Type Parameters

TReadModel

Type of read model to observe changes for.