EventLog

class EventLog(storage: Storage, partitionId: String = "default", expireAfter: Duration = 60.days, clock: Clock = Clock.System)

A persistent logger for recording and retrieving events.

EventLog backs its data with a Storage implementation, serializing events into CBOR format. It also provides an observable flow (eventFlow) that emits whenever the underlying event data is modified, making it easy for UI or other observers to react to changes.

Constructors

Link copied to clipboard
constructor(storage: Storage, partitionId: String = "default", expireAfter: Duration = 60.days, clock: Clock = Clock.System)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
val eventFlow: SharedFlow<Unit>

A SharedFlow that emits a Unit whenever an event is added, deleted, or when all events are cleared. Observers can collect this flow to know when to refresh their data.

Functions

Link copied to clipboard
suspend fun addEvent(event: Event): Event

Adds a new event to the logger.

Link copied to clipboard
suspend fun deleteAllEvents()

Deletes all events within the current partition.

Link copied to clipboard
suspend fun deleteEvent(event: Event): Boolean

Deletes a specific event from the logger.

Link copied to clipboard
suspend fun getEvents(limit: Int = Int.MAX_VALUE, afterEventId: String? = null): List<Event>

Retrieves all events stored in the current partition.