feat(server-02): promote EventStore to global-sequence store with subscribeAll
StoredEvent gains sessionSequence: Long (per-session monotonic); existing sequence field becomes the global monotonic cursor across the entire store. SqliteEventStore allocates both counters inside the same BEGIN IMMEDIATE transaction and emits to a global MutableSharedFlow after commit. InMemoryEventStore mirrors this with an AtomicLong global counter and a suspend-on-overflow SharedFlow. EventStore interface gains subscribeAll() and lastGlobalSequence(). Contract tests updated and extended to cover global-sequence and cross-session subscribeAll invariants.
This commit is contained in:
@@ -61,4 +61,8 @@ class LoggingEventStore(private val delegate: EventStore) : EventStore {
|
||||
|
||||
override fun allEvents(): Sequence<StoredEvent> = delegate.allEvents()
|
||||
override fun allSessionIds(): Set<SessionId> = delegate.allSessionIds().also { log.debug("got session ids from store: {}", it) }
|
||||
|
||||
override fun subscribeAll(): Flow<StoredEvent> = delegate.subscribeAll()
|
||||
|
||||
override suspend fun lastGlobalSequence(): Long = delegate.lastGlobalSequence()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user