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:
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")
}
}Вывод
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С версии. 1.0.0-beta
Параметры
| Имя | Тип |
|---|---|
name | str |
args | bytes |
run | fn(bytes) -> T F |
Возвращает
T
Ошибки
CompensationFailed@errorNetError- `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.
Эффекты
net, db, time
Определено в: std/saga/saga.oxl:908