OxL Reference

data SagaStatus

The state of a saga as std.saga.status shows it.

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 {
  let _ = pay(9)
  for s in std.saga.list(.Stuck) {
    print("{s.name} is {s.status} after {s.completed} completed step(s)")
  }
}
Output
main.pay is stuck after 1 completed step(s)
pub(api) data SagaStatus

Since. 1.0.0-beta

Fields

pub(api) id: str

The id of the saga.

pub(api) name: str

The qualified name of the saga.

pub(api) status: str

"running", "compensating", "done", "failed" (compensated), "cancelled" (deadline; compensated), "stuck".

pub(api) cursor: i64

Steps entered / completed so far.

pub(api) completed: i64

Number of steps completed.

pub(api) cause: str

Why the saga failed or is stuck; empty otherwise.

pub(api) node: str

The node that executes the saga.

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

See also