Table of Contents

Struct SaveResult

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

What a save produced: the version the aggregate reached, and the token a caller passes to a read that must observe this write.

public readonly record struct SaveResult : IEquatable<SaveResult>
Implements
Inherited Members

Remarks

The token rides the response of the operation that produced it, which is how Azure Cosmos DB's session consistency works: a write returns a session token, the caller carries it, and a subsequent read honours it. The alternatives were considered and rejected — an out-parameter puts transport state on the aggregate, and an ambient value makes "which save produced this" unanswerable the moment two saves interleave.

Async projections are applied by the ordered processor after the append commits. Inline drives that same processor and waits within a bound after commit. Its Attested result records an observation at save time; callers requiring read-your-writes still pass the token to a session reader for revalidation. A bounded wait expiring does not roll back the events or authorize repeating the command.

TransactionalInline projections are written in the event append's database transaction. A successful coordinated append commits both together. This aggregate-local guarantee does not produce a global-prefix attestation: Projections and Attestation continue to describe only the separate Inline processor, if configured.

null is a real answer, not a missing one. It means no global ordering exists to wait on, so a consistent read cannot be requested against this write — not that the save failed.

Constructors

SaveResult(long, long?, ProjectionFreshness)

What a save produced: the version the aggregate reached, and the token a caller passes to a read that must observe this write.

public SaveResult(long CommittedVersion, long? SessionToken, ProjectionFreshness Projections)

Parameters

CommittedVersion long

The aggregate's version after the save.

SessionToken long?

The global position of the LAST event this save wrote, or null when the event store assigns no global ordering or this save wrote nothing.

Projections ProjectionFreshness

Whether this save's Inline projections reached SessionToken before returning. NotRequested when nothing was waited for — no projection is registered Inline, so none was ever going to be. Attested when every required Inline projection was OBSERVED to have folded the committed prefix through the token, against the durable roster as it stood at that moment — a receipt, not a standing promise, because the roster can change before you read. For read-your-own-writes, hand SessionToken to IProjectionSessionReader and require Fresh, which is issued only after re-validating roster identity, binding, position and destination around the data read. BoundExpired when the bounded wait ended first: the events ARE durably committed and only the read model is behind, so the correct response is to answer from the stale read model or wait on IProjectionSessionReader — never to repeat the command, which would append the events a second time.

Remarks

The token rides the response of the operation that produced it, which is how Azure Cosmos DB's session consistency works: a write returns a session token, the caller carries it, and a subsequent read honours it. The alternatives were considered and rejected — an out-parameter puts transport state on the aggregate, and an ambient value makes "which save produced this" unanswerable the moment two saves interleave.

Async projections are applied by the ordered processor after the append commits. Inline drives that same processor and waits within a bound after commit. Its Attested result records an observation at save time; callers requiring read-your-writes still pass the token to a session reader for revalidation. A bounded wait expiring does not roll back the events or authorize repeating the command.

TransactionalInline projections are written in the event append's database transaction. A successful coordinated append commits both together. This aggregate-local guarantee does not produce a global-prefix attestation: Projections and Attestation continue to describe only the separate Inline processor, if configured.

null is a real answer, not a missing one. It means no global ordering exists to wait on, so a consistent read cannot be requested against this write — not that the save failed.

Properties

Attestation

Gets the roster receipt for the inline freshness observation.

public ProjectionAttestation? Attestation { get; init; }

Property Value

ProjectionAttestation

The receipt, or null when no roster was attested.

CommittedVersion

The aggregate's version after the save.

public long CommittedVersion { get; init; }

Property Value

long

Projections

Whether this save's Inline projections reached SessionToken before returning. NotRequested when nothing was waited for — no projection is registered Inline, so none was ever going to be. Attested when every required Inline projection was OBSERVED to have folded the committed prefix through the token, against the durable roster as it stood at that moment — a receipt, not a standing promise, because the roster can change before you read. For read-your-own-writes, hand SessionToken to IProjectionSessionReader and require Fresh, which is issued only after re-validating roster identity, binding, position and destination around the data read. BoundExpired when the bounded wait ended first: the events ARE durably committed and only the read model is behind, so the correct response is to answer from the stale read model or wait on IProjectionSessionReader — never to repeat the command, which would append the events a second time.

public ProjectionFreshness Projections { get; init; }

Property Value

ProjectionFreshness

SessionToken

The global position of the LAST event this save wrote, or null when the event store assigns no global ordering or this save wrote nothing.

public long? SessionToken { get; init; }

Property Value

long?