OxL Reference

fn drive

Starts the saga name with the encoded arguments (or joins the one the idempotency key of the call names) and waits for its result. Where it runs is described in the module comment; this function only makes the journal entry, executes locally when this node may, and polls for the end state. When the caller is cancelled or its deadline passes, the cancel marker is written (shielded) before the cancellation goes on.

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)
}

fn main() io, net, time, db {
  match flow(5) {
    u64 v => print("done {v}")
    CompensationFailed _ => print("stuck")
    NetError _ => print("net error")
  }
}
Output
done 105
pub(api) fn drive<T: Serializable, effect F>(name: str, args: bytes, run: fn(bytes) -> T F) -> T | CompensationFailed | NetError  net, db, time

Since. 1.0.0-beta

Parameters

NameType
namestr
argsbytes
runfn(bytes) -> T F

Returns

T

Errors

  • CompensationFailed @error
  • NetError
  • `CompensationFailed`, `NetError` (`Timeout` when the caller's deadline passed: the saga is then cancelled and compensated in the background), and the error types of the steps.

Effects

net, db, time

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

See also