Interface ICommittedPositionReader
- Namespace
- Stratara.Abstractions.CommitOrder
- Assembly
- Stratara.Abstractions.dll
Reads the event store in commit order, one partition at a time. The promise that distinguishes it from a plain "after sequence number" read: no entry whose position is at or below the Position of a returned batch can still commit later. A reader that keeps that promise can be resumed from a stored position without ever skipping an entry.
public interface ICommittedPositionReader
- Extension Methods
Remarks
What a position is depends on the implementation — a sequence number, a per-partition counter, a transaction id — and a stored position is only meaningful to the reader that produced it. A read that orders by sequence number alone does not keep the promise: a transaction can take the lower sequence number and commit after one that took a higher.
Properties
Name
The stable name positions are stored under. It names the ordering the positions belong to and the partition count they were written under, so a checkpoint is refused by a reader of another kind or under another count, and renaming a class changes nothing a checkpoint is keyed on.
string Name { get; }
Property Value
Methods
HeadAsync(int, CancellationToken)
Returns the head of partition: the position after which no entry committed at the time of
the call exists, so that a consumer starting there reads exactly what commits afterwards. 0 on a
partition without entries. The default walks the partition batch by batch from the beginning and returns
the last position; a reader overrides it with one query where its store can answer directly.
Task<long> HeadAsync(int partition, CancellationToken cancellationToken = default)
Parameters
partitionintThe partition, from
0to the configured partition count − 1.cancellationTokenCancellationTokenPropagated to the store.
Returns
Remarks
A reader whose positions come from the store's own transactions — the native reader on PostgreSQL — cannot count what a write transaction still open might yet commit before the entries it already sees, so its head is held back to what no open transaction can precede. Take a head while nothing appends, which is what seeding a deployment does; taken while writers run, it may fall behind what is committed, and a consumer seeded at it applies the entries in between once more.
ReadAfterAsync(int, long, int, CancellationToken)
Returns up to batchSize entries of partition that come
after afterPosition in commit order, together with the position to resume
from.
Task<CommittedBatch> ReadAfterAsync(int partition, long afterPosition, int batchSize, CancellationToken cancellationToken = default)
Parameters
partitionintThe partition to read, from
0to the configured partition count − 1.afterPositionlongThe position returned by the previous batch, or
0to start from the beginning.batchSizeintThe maximum number of entries to return.
cancellationTokenCancellationTokenPropagated to the store.
Returns
- Task<CommittedBatch>
The entries in commit order, and the position to store; an empty batch keeps the position it was asked for.