DecideFunction

sealed interface DecideFunction<S : Any>

A decide function, in the form its signature has. The kernel calls a Sync one directly, with no continuation and no dispatch; only a Suspending one runs as a coroutine call, and a Suspending.blocking one (@Blocking) on the kernel's blocking dispatcher, a virtual thread.

Inheritors

Types

Link copied to clipboard
class Suspending<S : Any>(val creation: Creation, val blocking: Boolean, val onDeleted: Boolean, val decide: suspend DecideScope.(S, Any) -> Decision, val produces: Set<Class<*>>? = null) : DecideFunction<S>

A suspending decide function; a blocking one blocks its thread, so the kernel runs it on a virtual thread.

Link copied to clipboard
class Sync<S : Any>(val creation: Creation, val onDeleted: Boolean, val decide: DecideScope.(S, Any) -> Decision, val produces: Set<Class<*>>? = null) : DecideFunction<S>

Properties

Link copied to clipboard
abstract val creation: Creation

Whether the command may, or must, create the aggregate.

Link copied to clipboard
abstract val onDeleted: Boolean

Whether the command is decided on a deleted aggregate too (@OnCommand(onDeleted = true)), as the kernel decides RestoreAggregate; every other command is refused on one (wow.aggregate.deleted).

Link copied to clipboard
abstract val produces: Set<Class<*>>?

The events it may produce, those its return type yields or its produces lists: the kernel fails a command whose decision holds another (UndeclaredEventException). Null when they are unknown, and then not checked.