InMemoryEventLog

class InMemoryEventLog(val partitions: Int = DEFAULT_PARTITIONS) : EventLog, AccessWalks

An EventLog in memory, for tests and samples. Appends are serialized by one lock, so the sequence within a partition is trivially the order commits became visible. As the durable backends, it keeps the request key per aggregate type. Each partition keeps its PartitionLineage, PartitionLineage.ROOT as created. It keeps each stream's stamp, stamps the access attributes over a history and records each type's walk (AccessWalks) as the durable logs do; its aggregates are ordered by id, then tenant.

Constructors

Link copied to clipboard
constructor(partitions: Int = DEFAULT_PARTITIONS)

Properties

Link copied to clipboard
open override val appendsAcrossPartitions: Boolean

Its appendAll appends one stream at a time under the one lock, whichever partitions.

Link copied to clipboard
open override val partitions: Int

Functions

Link copied to clipboard
open suspend override fun advance(type: AggregateType, schema: String, cursor: String?, walked: Long, completed: Boolean): Boolean
Link copied to clipboard
open suspend override fun aggregates(type: AggregateType, after: String?, limit: Int): AggregatePage
Link copied to clipboard
open suspend override fun append(stream: EventStreamRecord, transport: ByteArray?): AppendOutcome
Link copied to clipboard
open suspend override fun claim(type: AggregateType, walk: AccessWalk, expected: String?): Boolean
Link copied to clipboard
open suspend override fun findByRequestId(type: AggregateType, tenantId: String, requestId: String): EventStreamRecord?
Link copied to clipboard
open suspend override fun head(partition: Int): Long?
Link copied to clipboard
open suspend override fun holds(type: AggregateType): Boolean

Whether a stream of type was appended: the store of a type's history is its streams.

Link copied to clipboard
open suspend override fun lineage(partition: Int): PartitionLineage
Link copied to clipboard
open suspend override fun positionOf(ref: AggregateRef, version: Int): LogPosition?
Link copied to clipboard
open override fun read(ref: AggregateRef, fromVersion: Int, toVersion: Int): Flow<EventStreamRecord>
Link copied to clipboard
open override fun readEntries(ref: AggregateRef, fromVersion: Int, toVersion: Int): Flow<LogEntry>
Link copied to clipboard
open suspend override fun readTail(ref: AggregateRef, fromVersion: Int, earlier: Int): AggregateTail

One read under the lock: the tail and the earlier request keys of the same moment.

Link copied to clipboard
open suspend override fun stamp(ref: AggregateRef, access: Map<String, Any?>, asOf: Int, from: Int, until: Int): Int

Replaces each stream it stamps wherever the log keeps it: by aggregate, by request and in its partition.

Link copied to clipboard
open override fun tail(partition: Int, after: Long?): Flow<LogEntry>
Link copied to clipboard
open suspend override fun walk(type: AggregateType): AccessWalk?