OxL Справочник OxL
РусскийEnglish

enum SagaResolution

How an operator closes a stuck saga by hand: Compensated (the compensations were done outside, the saga counts as failed) or Completed (the work was finished by hand).

Example:

oxl✓ проверяется в CI
@error data Boom { m: str }

service Bank {
  @public @idempotent rpc hold(n: u64) -> u64
  @public @idempotent rpc unhold(n: u64) -> () | Boom
  @public @idempotent rpc refuse(n: u64) -> u64 | Boom
}

impl Bank {
  rpc hold(n) => n
  rpc unhold(n) { fail Boom{ m: "bank is down" } }
  rpc refuse(n) { fail Boom{ m: "no" } }
}

// the second step fails and its compensation never succeeds: the saga becomes stuck
saga pay(n: u64) -> u64 {
  Bank.hold(n)   undo h => Bank.unhold(h)
  -> Bank.refuse(n)
}

fn main() io, net, time, db {
  let _ = pay(9)
  for s in std.saga.list(.Stuck) {
    print("{std.saga.resolve(s.id, .Compensated)}")
  }
  print("{std.saga.list(.Stuck).len()}")
}
Вывод
true
0
pub(api) enum SagaResolution

С версии. 1.0.0-beta

Варианты

Compensated

The compensations were done by hand: the saga counts as failed.

Completed

The work was finished by hand: the saga counts as done.

Определено в: std/saga/saga.oxl:224

См. также