Skip to content

EventStore API

Entry point for the library.

interface IChronicleClient {
fun getEventStore(name: String): IEventStore
fun getEventStore(name: String, namespace: String): IEventStore
fun close()
}

Factory functions:

ChronicleClient.development() // localhost:35000
ChronicleClient(options: ChronicleOptions) // custom host/port

interface IEventStore {
val eventLog: IEventLog
val reactors: IReactorsService
val reducers: IReducersService
val projections: IProjectionsService
val constraints: IConstraintsService
val seeding: IEventSeedingService
val readModels: IReadModelsService
val compliance: IComplianceService
val unitOfWork: UnitOfWorkManager
}

interface IEventLog {
suspend fun append(eventSourceId: String, event: Any): AppendResult
suspend fun append(
eventSourceId: String,
event: Any,
options: AppendOptions
): AppendResult
suspend fun appendMany(
eventSourceId: String,
events: List<Any>
): List<AppendResult>
}
PropertyTypeDescription
isSuccessBooleantrue when no constraint violations
sequenceNumberEventSequenceNumberPosition in the event log
constraintViolationsList<ConstraintViolation>On failure

interface IReactorsService {
suspend fun register(reactor: Any): Job
}

interface IReducersService {
suspend fun register(reducer: Any): Job
}

interface IReadModelsService {
suspend fun register(vararg readModelClasses: KClass<*>)
suspend fun <T : Any> getInstanceByKey(
readModelClass: KClass<T>,
key: String
): T?
}

interface IProjectionsService {
suspend fun register(vararg projections: Any)
}

interface IConstraintsService {
suspend fun register(vararg constraints: Any)
}

interface IEventSeedingService {
suspend fun seed(vararg seeders: Any)
}

interface IComplianceService {
suspend fun release(subject: String, schema: String, payload: String): String
}