Table of Contents

Class ProjectionGenerationReader<TProjection>

Namespace
Excalibur.EventSourcing.Projections
Assembly
Excalibur.EventSourcing.dll

Reads the active generation without changing the store used by projection writers.

public sealed class ProjectionGenerationReader<TProjection> where TProjection : class

Type Parameters

TProjection

The supported read schema.

Inheritance
ProjectionGenerationReader<TProjection>
Inherited Members

Remarks

Each operation resolves routing afresh and confirms the pointer revision after reading. A generation change retries the read up to three times; sustained contention fails explicitly. This confirms the selected generation, not freshness relative to newly appended events. Retain retired physical destinations until in-flight readers have drained.

Constructors

ProjectionGenerationReader(ISubscriptionCheckpointStore, IProjectionStore<TProjection>, string, string, IReadOnlyCollection<string>?)

Creates a reader over the outer configured store, preserving its capability boundary.

public ProjectionGenerationReader(ISubscriptionCheckpointStore checkpoints, IProjectionStore<TProjection> store, string subscriptionName, string readerName, IReadOnlyCollection<string>? compatibleProjectionKeys = null)

Parameters

checkpoints ISubscriptionCheckpointStore

The checkpoint store providing atomic generation routing.

store IProjectionStore<TProjection>

The configured store, including tenant and encryption decorators.

subscriptionName string

The stable subscription name.

readerName string

The stable reader name.

compatibleProjectionKeys IReadOnlyCollection<string>

Explicitly compatible member keys. Defaults to the declared projection version only.

Methods

CountAsync(IDictionary<string, object>?, JsonTypeInfo<TProjection>, CancellationToken)

Counts the active generation through the generated-reader capability.

public Task<long> CountAsync(IDictionary<string, object>? filters, JsonTypeInfo<TProjection> typeInfo, CancellationToken cancellationToken)

Parameters

filters IDictionary<string, object>

Filters compatible with every explicitly supported generation.

typeInfo JsonTypeInfo<TProjection>

Generated metadata for the supported read schema.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<long>

The matching count.

CountAsync(IDictionary<string, object>?, CancellationToken)

Counts the active generation using the conventional provider capability.

[RequiresUnreferencedCode("Opening a conventional reader requires reflection. Supply generated metadata for trimming.")]
[RequiresDynamicCode("Opening a conventional reader can require dynamic code. Supply generated metadata for NativeAOT.")]
public Task<long> CountAsync(IDictionary<string, object>? filters, CancellationToken cancellationToken)

Parameters

filters IDictionary<string, object>

Filters compatible with every explicitly supported generation.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<long>

The matching count.

GetByIdAsync(string, JsonTypeInfo<TProjection>, CancellationToken)

Reads by identifier using generated metadata, refusing providers without that capability.

public Task<TProjection?> GetByIdAsync(string id, JsonTypeInfo<TProjection> typeInfo, CancellationToken cancellationToken)

Parameters

id string

Projection identifier.

typeInfo JsonTypeInfo<TProjection>

Generated metadata for the supported read schema.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<TProjection>

The projection, or null when absent.

GetByIdAsync(string, CancellationToken)

Reads by identifier using the provider's conventional serializer.

[RequiresUnreferencedCode("The conventional reader requires reflection. Supply generated metadata for trimming.")]
[RequiresDynamicCode("The conventional reader can require dynamic code. Supply generated metadata for NativeAOT.")]
public Task<TProjection?> GetByIdAsync(string id, CancellationToken cancellationToken)

Parameters

id string

Projection identifier.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<TProjection>

The projection, or null when absent.

QueryAsync(IDictionary<string, object>?, QueryOptions?, JsonTypeInfo<TProjection>, CancellationToken)

Queries the active generation using generated metadata.

public Task<IReadOnlyList<TProjection>> QueryAsync(IDictionary<string, object>? filters, QueryOptions? options, JsonTypeInfo<TProjection> typeInfo, CancellationToken cancellationToken)

Parameters

filters IDictionary<string, object>

Filters compatible with every explicitly supported generation.

options QueryOptions

Sorting and pagination.

typeInfo JsonTypeInfo<TProjection>

Generated metadata for the supported read schema.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<IReadOnlyList<TProjection>>

Matching projections.

QueryAsync(IDictionary<string, object>?, QueryOptions?, CancellationToken)

Queries the active generation using the conventional serializer.

[RequiresUnreferencedCode("The conventional reader requires reflection. Supply generated metadata for trimming.")]
[RequiresDynamicCode("The conventional reader can require dynamic code. Supply generated metadata for NativeAOT.")]
public Task<IReadOnlyList<TProjection>> QueryAsync(IDictionary<string, object>? filters, QueryOptions? options, CancellationToken cancellationToken)

Parameters

filters IDictionary<string, object>

Filters compatible with every explicitly supported generation.

options QueryOptions

Sorting and pagination.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<IReadOnlyList<TProjection>>

Matching projections.