OxL Reference

fn list

Sagas by state: .Stuck (needing manual work), .Active (not finished) or .All known to the index of unfinished ones.

Example:

oxl✓ checked in 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 {
  print("before: {std.saga.list(.All).len()}")
  let _ = pay(9)
  for s in std.saga.list(.Stuck) {
    print("{s.name}: {s.status}")
  }
}
Output
before: 0
main.pay: stuck
pub(api) fn list(filter: SagaFilter) -> List<SagaStatus>  net, db, time

Complexity. O(n) in the number of unfinished sagas of the cluster.

Since. 1.0.0-beta

Parameters

NameType
filterSagaFilter

Returns

List<SagaStatus>

Effects

net, db, time

Defined in: std/saga/saga.oxl:1094

See also