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:
@@ -606,7 +606,8 @@ class RouterFacadeTest {
|
||||
appendedEvents.add(event)
|
||||
val stored = StoredEvent(
|
||||
metadata = event.metadata,
|
||||
sequence = nextSequence++,
|
||||
sequence = nextSequence,
|
||||
sessionSequence = nextSequence++,
|
||||
payload = event.payload,
|
||||
)
|
||||
storedEvents[event.metadata.eventId] = stored
|
||||
@@ -635,5 +636,9 @@ class RouterFacadeTest {
|
||||
storedEvents.values.asSequence()
|
||||
|
||||
override fun allSessionIds(): Set<SessionId> = storedEvents.values.map { it.metadata.sessionId }.toSet()
|
||||
|
||||
override fun subscribeAll(): Flow<StoredEvent> = TODO("Not needed in this test context")
|
||||
|
||||
override suspend fun lastGlobalSequence(): Long = TODO("Not needed in this test context")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user