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
TProjectionThe 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
checkpointsISubscriptionCheckpointStoreThe checkpoint store providing atomic generation routing.
storeIProjectionStore<TProjection>The configured store, including tenant and encryption decorators.
subscriptionNamestringThe stable subscription name.
readerNamestringThe stable reader name.
compatibleProjectionKeysIReadOnlyCollection<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
filtersIDictionary<string, object>Filters compatible with every explicitly supported generation.
typeInfoJsonTypeInfo<TProjection>Generated metadata for the supported read schema.
cancellationTokenCancellationTokenCancellation token.
Returns
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
filtersIDictionary<string, object>Filters compatible with every explicitly supported generation.
cancellationTokenCancellationTokenCancellation token.
Returns
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
idstringProjection identifier.
typeInfoJsonTypeInfo<TProjection>Generated metadata for the supported read schema.
cancellationTokenCancellationTokenCancellation 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
idstringProjection identifier.
cancellationTokenCancellationTokenCancellation 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
filtersIDictionary<string, object>Filters compatible with every explicitly supported generation.
optionsQueryOptionsSorting and pagination.
typeInfoJsonTypeInfo<TProjection>Generated metadata for the supported read schema.
cancellationTokenCancellationTokenCancellation 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
filtersIDictionary<string, object>Filters compatible with every explicitly supported generation.
optionsQueryOptionsSorting and pagination.
cancellationTokenCancellationTokenCancellation token.
Returns
- Task<IReadOnlyList<TProjection>>
Matching projections.