Package-level declarations

Types

Link copied to clipboard
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.

Link copied to clipboard
class ExecutionId @InternalWowApi constructor(val context: String, val subscription: String, val ref: AggregateRef, val version: Int)

One execution of a subscription's handler for one commit: the subscription, by its bounded context and its subscription name there (processor.function, unique within the context alone), the aggregate ref and the committed version. It is deterministic: handling the same commit again, after a retry, a replay or a lease handover, gives the same id. It is per stream: the idempotency key of an outside call is SubscriptionContext.invocationKey, which tells apart the calls of a handler for each event.

Link copied to clipboard
class PublishedEvent @InternalWowApi constructor(val name: String, val revision: Int, val body: String)

An event of another context's published stream that the subscriber has no class for: its type name (context.aggregate.Event), the revision of its schema and its body as JSON text.

Link copied to clipboard

The context of every handler of a me.ahoo.wow.api.annotation.Saga: its @OnEvent handlers, its @OnRejected and @OnCommitted handlers of the receipts of the commands it derives (CommandReceipt), and its @OnSchedule jobs' handlers. A handler returns the commands it derives as CommandRequests, one, several (an Iterable, a Sequence, a Flow) or none, and the subscription sends each, deterministic, so handling the same commit, receipt or tick again derives the same requests, which their targets decide once:

Link copied to clipboard

What a subscription handler receives: one committed event stream of an aggregate, its events decoded (and upgraded to their current revision), with the aggregate's state after the commit. The events of another context's published stream are the classes of that context's api module, or a PublishedEvent for one the subscriber has no class of at its revision.

Link copied to clipboard
interface StateTypedEvent<out S, out E : Any> : StateEvent<S>

One event of a committed stream, typed: the stream it belongs to, as a StateEvent, with its eventIndex-th event as event, an E. A handler that takes a StateTypedEvent<S, E> is called once for each event of the stream that is an E, in their order, all with the stream's state after the whole commit; a handler that takes an E itself is its shorthand. It is a view of the stream, not a copy: two are equal when their streams are and they are of the same event.

Link copied to clipboard

What every subscription handler can ask of the runtime besides the StateEvent it handles: the context of a me.ahoo.wow.api.annotation.Projection's or a me.ahoo.wow.api.annotation.Reactor's handler, and what every other context adds to.

Link copied to clipboard

The names of Wow's built-in subscriptions a wait or an operator names, the ones a result's FunctionKind.SYSTEM is of among them. Every built-in subscription's name starts with wow., a prefix the compiler reserves, so no application subscription takes one.

Link copied to clipboard
class UnacceptedRejectionException @InternalWowApi constructor(val rejected: CommandReceipt.Rejected<*>, val accepted: List<String>) : RuntimeException

A saga's @OnRejected handler did not accept rejected: its code is none of the accepted ones (CommandReceipt.Rejected.accept). The handler does not take the rejection, so the runtime answers it as a rejection no handler takes: the saga's aggregate parks at once, without a retry, its reason naming the handler, the command and the code, and a wait at the saga's hop ends REJECTED with the rejection's error.

Link copied to clipboard
open class UnrecoverableHandlingException(message: String, cause: Throwable? = null) : RuntimeException

A handler's failure that no retry changes, which the handler says itself: it throws this (or a subclass of it), and the subscription parks the aggregate at once, without a retry, marked for an operator to look at; a wait at the handler's hop ends FAILED. A reactor that finds the buyer unknown to its notification service, say: asking again will not change that. Thrown as the cause of another failure, it parks too.

Functions

Link copied to clipboard
suspend fun <C : Any> SagaContext.call(command: C, aggregateId: String? = null, block: CommandRequest.Builder<C>.() -> Unit = {}): CommandResult

Calls command on the aggregate aggregateId names (none for a creation), with the fields block sets: SagaContext.call of command's toCommandRequest, context.call(SubmitOrder(items)).

suspend fun <C : Any> SagaContext.call(command: C, to: AggregateRef, block: CommandRequest.Builder<C>.() -> Unit = {}): CommandResult

Calls command on the aggregate the ref to names, with the fields block sets: SagaContext.call of command's toCommandRequest of a ref, context.call(Restock(sku), to = rejected.source).

Link copied to clipboard
fun <C : Any> SagaContext.schedule(key: String, rule: ScheduleRule, command: C, aggregateId: String? = null, block: CommandRequest.Builder<C>.() -> Unit = {})

Schedules command on the aggregate aggregateId names under key as rule says, with the fields block sets: SagaContext.schedule of command's toCommandRequest, context.schedule(DEADLINE, ScheduleRule.after(10.minutes), CancelOrder("No stock in time."), event.ref.id).

fun <C : Any> SagaContext.schedule(key: String, rule: ScheduleRule, command: C, to: AggregateRef, block: CommandRequest.Builder<C>.() -> Unit = {})

Schedules command on the aggregate the ref to names under key as rule says, with the fields block sets: SagaContext.schedule of command's toCommandRequest of a ref.