OxL Reference

fn done

End of step k. The last step (last) commits: in one transaction with the check of the cancel marker, so a cancelled saga never completes forward (answer 9).

Example:

oxl✓ checked in CI
service Ledger {
  @public @idempotent rpc openAcct(id: u64) -> u64
}

impl Ledger {
  rpc openAcct(id) => id + 100
}

saga flow(a: u64) -> u64 {
  Ledger.openAcct(a)
  -> Ledger.openAcct(a)
}

fn main() io, net, time, db {
  match flow(1) {
    u64 v => print("done {v}")
    CompensationFailed _ => print("stuck")
    NetError _ => print("net error")
  }
  print("active: {std.saga.list(.Active).len()}")
}
Output
done 101
active: 0
pub(api) fn done<T>(k: i64, last: bool, v: T) -> T | Timeout  net, db, time

Since. 1.0.0-beta

Parameters

NameType
ki64
lastbool
vT

Returns

T

Errors

  • Timeout @error
  • `Timeout` when the saga was cancelled before it could commit.

Effects

net, db, time

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

See also