Remote / An event-sourced domain behind Remote

When it goes wrong

  • The Aggregate rejects the Command. The prediction is taken back and the stream gains no Event. Data.refusal gives the mutation's Refusal: Conflict, Unmet, or Invalid with the invariant's id, message and path.
  • The write was made at a revision the row has left. Conflict, decided by the expect inside decide, not by the stream's version.
  • The Command committed and its View is behind. The write is applied with the reply's fields as the row. Remote holds the row to the receipt, a read at it names the row behind, and the page keeps what it has until the View answers.
  • A View frame older than the row arrives late. Nothing changes: Remote drops a row of a lower revision.
  • The reply is lost after the commit. The write fails Unreachable and the prediction is taken back, though the Event exists. The retry carries the same operation, so the same commandId, and Domain answers it from its record without deciding again.
  • The same operation is sent again with other input. The adapter gives it another commandId, so Domain decides it. A lowered Aggregate remembers its last 256 operations and rejects this one Reused, which the page sees as a failed write. A visitor, or someone the guard refuses, hears the guard instead.
  • The middleware refuses who asks. RemoteUnauthenticated or RemoteForbidden, as the layer's denied says.
  • A reader may not see the row. It reads as absent, as a guarded SQL read of a hidden row does.
  • The page reloads while a row is held to a receipt. The hold lives in Remote.Model: a reload that restores the store restores it, and one that restores nothing holds nothing.

Two guarantees are narrower than they may look:

  • Idempotency is Domain's, keyed by commandId. The adapter also keeps the replies of the last 1,024 Commands that answered, only to spare a retry its call. Domain itself answers a resent commandId with the first receipt whatever input or caller it comes with; the adapter derives the id from the caller, the operation and the input so that it never resends one for a different request.
  • A View behind is waited for, not forced. The adapter waits confirmWithin (2 seconds unless you set it) for a read at a receipt, then says behind; Remote asks again after 1 second, doubling to at most 30.