bank-saga
A transfer between accounts (§11.3): Bank.debit withdraws, Bank.credit deposits; if the deposit fails, the withdrawal
is undone by the undo compensation. The accounts are sharded Account actors, the methods of Bank are @idempotent because
every saga step gets an idempotency key.
oxl run examples/bank-saga
oxl test examples/bank-sagaOutput of oxl run:
1 -> 2, 30: ok, target balance 30
1 -> 99, 50: account 99 is blocked, debit compensated
1 -> 2, 500: insufficient funds (70)
balance of 1: 70What to look at: the result type of the saga i64 | Insufficient | Blocked | CompensationFailed | NetError is taken apart by one
match; cluster bank { role all { serves Bank; hosts Account; journal; runs sagas } }: a saga needs a role with a journal and
runs sagas; three tests check success, compensation and a refusal before the deposit. The continuation is the checkout in
shop (the warehouse and payments there are external services replaced by mock).