EventStore

class EventStore(replayCapacity: Int = 0)

Append-only buffer of TracerEvents plus a hot SharedFlow for live consumers.

Reads return immutable snapshots. The append path uses an internal Mutex so the buffer is safe to share across coroutines.

Mirrors the Python reference EventStore (tracer/event_store.py).

Constructors

Link copied to clipboard
constructor(replayCapacity: Int = 0)

Properties

Link copied to clipboard
val events: SharedFlow<TracerEvent>

Hot stream of every event recorded since this store was created.

Functions

Link copied to clipboard
suspend fun clear()

Drop every event from the buffer.

Link copied to clipboard
suspend fun getEvents(type: KClass<out TracerEvent>? = null, startTime: Instant? = null, endTime: Instant? = null, predicate: (TracerEvent) -> Boolean? = null): List<TracerEvent>

Returns a snapshot of every event matching the supplied filters.

Link copied to clipboard
suspend fun getLastN(n: Int, type: KClass<out TracerEvent>? = null): List<TracerEvent>

Returns the last n events, optionally filtered to type. Order matches insertion order (oldest first).

Link copied to clipboard
suspend fun size(): Int

Current number of buffered events.

Link copied to clipboard
suspend fun store(event: TracerEvent)

Store event in the buffer and emit it to live subscribers.