DomainEventStream

Domain Event Stream interface representing a sequence of domain events.

A domain event stream contains a collection of domain events that were generated as a result of a single command execution. The relationship is 1:1 between event streams and command IDs.

Key requirements:

  • Events must be sorted in ascending order by version number

  • Version numbers must be monotonically increasing

  • All events in a stream belong to the same aggregate

  • Events are immutable once created

See also

Inheritors

Properties

Link copied to clipboard
abstract override val aggregateId: AggregateId

The aggregate ID this event stream belongs to

Link copied to clipboard
abstract val aggregateName: String
Link copied to clipboard
abstract val body: List<DomainEvent<*>>
Link copied to clipboard
abstract val commandId: String
Link copied to clipboard
abstract val contextName: String
Link copied to clipboard
abstract override val createTime: Long
Link copied to clipboard
abstract val header: Header
Link copied to clipboard
abstract val id: String
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
abstract val ownerId: String
Link copied to clipboard
abstract val requestId: String
Link copied to clipboard
abstract val size: Int

The number of events in this stream

Link copied to clipboard
abstract val version: Int

Functions

Link copied to clipboard
fun NamedAggregate.aggregateId(id: String = generateId(), tenantId: String = TenantId.DEFAULT_TENANT_ID): DefaultAggregateId

Creates an AggregateId for this NamedAggregate with the specified parameters.

Link copied to clipboard

Finds the aggregate type class associated with this named aggregate.

Link copied to clipboard

Converts this NamedAggregate to its corresponding AggregateMetadata.

Link copied to clipboard
abstract fun copy(): DomainEventStream
Link copied to clipboard

Generates a unique ID string for this NamedAggregate.

Link copied to clipboard
fun NamedBoundedContext.getContextAlias(boundedContext: BoundedContext? = MetadataSearcher.metadata.contexts[contextName]): String
Link copied to clipboard

Gets the context alias prefix for this bounded context.

Link copied to clipboard

Determines if this event stream should be ignored during event sourcing.

Link copied to clipboard

Checks if the named aggregate is available locally at runtime.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
abstract operator fun iterator(): Iterator<DomainEvent<*>>
Link copied to clipboard
fun Message<*, *>.match(function: FunctionInfo): Boolean

Checks if this message matches the given function for compensation purposes.

Link copied to clipboard

Finds the aggregate type class associated with this named aggregate, throwing an exception if not found.

Link copied to clipboard

Sorts an iterable collection based on Order annotations and dependencies.

Link copied to clipboard

Extension function to convert a NamedAggregate to an EventNamedAggregate.

Link copied to clipboard
fun AggregateIdCapable.toGroupKey(parallelism: Int = DEFAULT_PARALLELISM): Int

Computes a grouping key for parallel processing based on the aggregate ID.

Link copied to clipboard

Converts this NamedAggregate to its string representation.

Link copied to clipboard

Converts a DomainEventStream to a StateEvent using the state from a ReadOnlyStateAggregate.

fun <S : Any> DomainEventStream.toStateEvent(state: S, firstOperator: String = header.operator.orEmpty(), firstEventTime: Long = createTime, deleted: Boolean = false): StateEvent<S>

Converts a DomainEventStream to a StateEvent with the given state.

Link copied to clipboard

Converts this NamedAggregate to a string representation using the context alias.

Link copied to clipboard
open fun withHeader(additionalSource: Map<String, String>): DomainEventStream
open fun withHeader(key: String, value: String): DomainEventStream
Link copied to clipboard