toDomainEventStream

fun Any.toDomainEventStream(upstream: CommandMessage<*>, aggregateVersion: Int, stateOwnerId: String = OwnerId.DEFAULT_OWNER_ID, header: Header = DefaultHeader.empty(), createTime: Long = System.currentTimeMillis()): DomainEventStream

Converts an object to a domain event stream based on a command message.

This extension function creates a DomainEventStream from any object, using information from the upstream command message. The object is flattened into individual events, each converted to a domain event with proper sequencing and metadata.

Receiver

The object containing event data (can be single event, array, or iterable)

Return

A new DomainEventStream containing the converted events

Parameters

upstream

The command message that triggered these events

aggregateVersion

The current version of the aggregate

stateOwnerId

The owner ID from the current state (default: DEFAULT_OWNER_ID)

header

The header to propagate to the event stream (default: empty header)

createTime

The timestamp for event creation (default: current time)

See also