Remote / An event-sourced domain behind Remote
The loop
- Page:
Data.mutate(model, ReserveStock, input). Remote predicts the result from the declaration and marks the write pending. - Adapter: sends
client.ReserveStock(id, input, { commandId }). ThecommandIdis derived from who asks, the operation and the input. - Domain:
decideappends[StockReserved]and answers{ reply, stream, version }, the receipt. A refusal is a Rejection. - Adapter: asks
ProductRow.snapshot(id, { atLeast }), the View at the receipt, for a bounded time. - Domain: the View folds
StockReservedwhen the Event reaches it. - Adapter: answers the write with the View's row, or with the reply's
fields and the receipt. A Rejection becomes the mutation's
Refusal. - Page: the answer replaces the prediction. Remote holds the row to the receipt, and a later read carries it until a read at the receipt answers.
The page never reads the Aggregate, and never folds an Event itself. It reads rows from a View and learns of its own write from the Command's reply.