AccessWalks

The walks of a log's history (AccessStamps it also is): a walk of an aggregate type stamps each of its aggregates' streams with the attributes of its current state, for the streams no commit stamped with the type's current access schema (written before the log kept attributes, imported, or before the model declared what it declares now).

The log pages the type's aggregates (aggregates) and keeps each type's walk beside the type in its registry (walk): the access schema it is of, the log's heads when it was claimed, how far it is. Claims are compare-and-set by schema (claim), so concurrent claims leave one walk.

None of these creates the store of a type's history (its collection, its table): a type the log holds none of (holds) has nothing to walk, and its first append creates its store as it would without walks.

Functions

Link copied to clipboard
abstract suspend fun advance(type: AggregateType, schema: String, cursor: String?, walked: Long, completed: Boolean): Boolean

Records how far the walk of type of schema is: the page it is past (cursor), the aggregates walked, and whether it is completed; returns false, recording nothing, when the recorded walk is of another schema.

Link copied to clipboard
abstract suspend fun aggregates(type: AggregateType, after: String?, limit: Int): AggregatePage

At most limit aggregates of type, in the log's own key order, after the page whose AggregatePage.next is after (null: from the first); none of a type the log holds no store of.

Link copied to clipboard
abstract suspend fun claim(type: AggregateType, walk: AccessWalk, expected: String?): Boolean

Records walk, a new walk of type, in place of the recorded one when that is of the schema expected, or when none is recorded and expected is null; returns whether it did. It records none of a type the log holds no store of: the walk is kept beside the type's store.

Link copied to clipboard
abstract suspend fun holds(type: AggregateType): Boolean

Whether the log holds a store of type's history: one its first append created, or one created up front. A type it holds none of has no walk, and claims none.

Link copied to clipboard
abstract suspend fun walk(type: AggregateType): AccessWalk?

The walk of type as the log records it; null before any claim.