EventStore

Interface for storing and retrieving domain event streams. Provides methods to append events and load event streams by aggregate ID and version/time ranges.

Author

ahoo wang

Inheritors

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
abstract fun append(eventStream: DomainEventStream): Mono<Void>

Appends a domain event stream to the event store. Ensures transaction consistency and handles version conflicts.

Link copied to clipboard
open override fun close()

Closes this event store and releases owned resources.

Link copied to clipboard
open override fun existsRequestId(aggregateId: AggregateId, requestId: String): Mono<Boolean>

Checks whether the request ID already exists for the specified aggregate.

Link copied to clipboard
abstract fun last(aggregateId: AggregateId): Mono<DomainEventStream>

Loads the last domain event stream for the specified aggregate.

Link copied to clipboard
abstract fun load(aggregateId: AggregateId, headVersion: Int = DEFAULT_HEAD_VERSION, tailVersion: Int = DEFAULT_TAIL_VERSION): Flux<DomainEventStream>

Loads domain event streams for the specified aggregate within the given version range. The range is inclusive: headVersion, tailVersion.

abstract fun load(aggregateId: AggregateId, headEventTime: Long, tailEventTime: Long): Flux<DomainEventStream>

Loads domain event streams for the specified aggregate within the given event time range. The range is inclusive: headEventTime, tailEventTime.

Link copied to clipboard

Wraps an EventStore with metrics collection capabilities. Returns a MetricEventStore that collects metrics on event storage operations. RoutingEventStore remains transparent because the selected leaf store owns storage metrics.

Link copied to clipboard
open fun scanAggregateId(namedAggregate: NamedAggregate, afterId: String = FIRST_ID, limit: Int = 10): Flux<AggregateId>

Scans for aggregate IDs within the specified named aggregate, starting after the given ID. Returns a limited number of aggregate IDs in lexicographical order.

Link copied to clipboard
open fun single(aggregateId: AggregateId, version: Int): Mono<DomainEventStream>

Loads a single domain event stream for the specified aggregate at the given version.