CommandReceipt

sealed interface CommandReceipt<C : Any>

The receipt of a command of type C a saga derived: Rejected (an @OnRejected handler takes it) or Committed (an @OnCommitted handler takes it). The command commandId of the full type name commandType was sent to ref. Its causation links it to the commit the saga handled and to the root of the chain, and executionId is the saga's execution that derived it, so what a handler derives in turn is deterministic too. operator is the command's, the root command's, which the handler's commands keep; so is scope, its owner and space, and so are headers, the request facts the command inherited from the commit the saga handled (me.ahoo.wow.api.decide.RequestFacts.PROPAGATED), such as the calling application. version is the version of ref the receipt answers; a rejection may have none.

A receipt carries the outcome only: neither the command's body nor the target's state. C says which commands' receipts a handler takes; * takes every command the saga sends. The runtime hands each receipt over once per commandId.

A handler of both receipts of a command takes a CommandReceipt<C> and carries both @OnRejected and @OnCommitted: each annotation declares its own path. A rejection is a business outcome, never retried as such. A receipt of the saga's own context is handled inside the handling of the @OnEvent handler that derived the command: under that handler's (or its processor's) @Retry budget, parked under that handler's subscription, and a retry runs that handler again, whose deterministic ids make it harmless. A receipt from another context is handled in the context's receipts subscription, wow.receipts.<context>, under the host's retry for that name. Neither handler takes @Retry.

Fields may be added: the runtime builds a receipt, and a test hands one to a saga with the test DSL's whenRejected or whenCommitted; the constructors are internal to Wow.

Inheritors

Types

Link copied to clipboard
class Committed<C : Any> @InternalWowApi constructor(val commandId: String, val commandType: String, val ref: AggregateRef, val version: Int, val result: CommandResult, val causation: Causation, val executionId: ExecutionId, val operator: Operator? = null, val scope: Scope = Scope.NONE, val headers: Map<String, String> = emptyMap()) : CommandReceipt<C>

The command was committed on ref (its id the one the target gave it when the command named none) at version, with result, the command's outcome at its committed hop. A request the target had already committed is answered with its original aggregate and version, CommandResult.duplicate set.

Link copied to clipboard
class Rejected<C : Any> @InternalWowApi constructor(val commandId: String, val commandType: String, val ref: AggregateRef, val error: ErrorInfo, val causation: Causation, val executionId: ExecutionId, val operator: Operator? = null, val scope: Scope = Scope.NONE, val headers: Map<String, String> = emptyMap(), val version: Int? = null) : CommandReceipt<C>

The command was refused with error. version is the version of ref the rejection answered: the version its events reached when it was committed with events, else the one the decision saw; null when the command was refused before any decision, a creation's. A rejection is a business outcome: the runtime hands it to the saga instead of parking the aggregate, whether the command was rejected in the saga's own context or in another, whose receipt comes back, and whether the saga derived it or called it (SagaContext.call) and let the rejection through.

Properties

Link copied to clipboard
abstract val causation: Causation
Link copied to clipboard
abstract val commandId: String
Link copied to clipboard
abstract val commandType: String
Link copied to clipboard
abstract val executionId: ExecutionId
Link copied to clipboard
abstract val headers: Map<String, String>
Link copied to clipboard
abstract val operator: Operator?
Link copied to clipboard
abstract val ref: AggregateRef
Link copied to clipboard
abstract val scope: Scope
Link copied to clipboard

The aggregate whose commit derived the command (ExecutionId.ref of the execution that derived it): the order a saga compensates or follows up, say; ref is the aggregate the command was sent to.

Link copied to clipboard
abstract val version: Int?