Table of Contents

Interface IProjectionSessionReader

Namespace
Excalibur.EventSourcing
Assembly
Excalibur.EventSourcing.Abstractions.dll

Reads a projection, optionally waiting until it has caught up to a write the caller made.

public interface IProjectionSessionReader

Remarks

This is the read half of session consistency. A save returns a SaveResult carrying a session token; passing that token here makes the read observe the write that produced it, or say plainly that it could not confirm so within the configured bound.

The read validates consistency at its own observation boundary. Async projections do not delay the save. Inline projections perform a bounded save-time wait and can return Attested, but that receipt does not replace the validation here: the roster and destination may change before the caller reads.

A separate interface rather than a member on IProjectionStore<TProjection>. That interface already carries five methods, the ceiling this codebase holds interfaces to, and a sixth would also oblige every store provider to implement host-progress logic that has nothing to do with storing a projection. This way no provider changes at all.

The read and the wait are one call on purpose. Exposing a bare "wait" primitive would leave the caller free to read first and wait afterwards, which looks correct and is not.

Methods

ReadAsync<TProjection>(string, SaveResult, JsonTypeInfo<TProjection>, CancellationToken)

Reads a projection through generated-metadata persistence after waiting for the session token.

ValueTask<ProjectionRead<TProjection>> ReadAsync<TProjection>(string projectionId, SaveResult session, JsonTypeInfo<TProjection> typeInfo, CancellationToken cancellationToken) where TProjection : class

Parameters

projectionId string

Projection identifier.

session SaveResult

The write to observe.

typeInfo JsonTypeInfo<TProjection>

The same generated metadata instance used by the store.

cancellationToken CancellationToken

Cancellation token.

Returns

ValueTask<ProjectionRead<TProjection>>

The projection and its freshness.

Type Parameters

TProjection

Projection state type.

Remarks

The default implementation refuses this capability. It never calls the reflective overload.

ReadAsync<TProjection>(string, SaveResult, CancellationToken)

Reads a projection, first waiting — up to the configured bound — until it has applied the write the supplied session describes.

[RequiresUnreferencedCode("Projection stores serialize the projection type reflectively.")]
[RequiresDynamicCode("Projection stores serialize the projection type reflectively.")]
ValueTask<ProjectionRead<TProjection>> ReadAsync<TProjection>(string projectionId, SaveResult session, CancellationToken cancellationToken) where TProjection : class

Parameters

projectionId string

The projection identifier.

session SaveResult

The result of the save this read must observe. A session whose token is null requests no consistency and is read immediately.

cancellationToken CancellationToken

Cancellation token.

Returns

ValueTask<ProjectionRead<TProjection>>

The projection, with what can be said about how current it was.

Type Parameters

TProjection

The projection type to read.