def drain

bend-kit-runner@0.13.0.1 · runner.bend:1705

import bend-kit-runner@0.13.0.1/runner.bend as Runner
import Base
import bend-kit-bytes@0.3.3.0/bytes.bend as Bytes
import bend-kit-retry@0.3.0.0/retry.bend as Retry

1705# Ticks until no ticket is pending or running and no attempt runs. After a round that did nothing, it waits up to idle ms
1706# for a message, and handles one that arrives at once.
1707# Fails when fuel rounds leave work.
1708def drain(~A: Data, ~penc: A -> Bytes.Bytes, ~target: A -> String, ~work: A -> IO(Retry.Outcome), fuel: Nat, r: Runner<A>) -> IO(Ran(A)):
1709  match fuel:
1710    case 0n:
1711      IO.pure(Ran(A), drain.end(A, finished(A, r)))
1712    case 1n+n:
1713      drain.at(~A, ~penc, ~target, ~work, finished(A, r), (r2 => drain(~A, ~penc, ~target, ~work, n, r2)))

Uses (11)

Used by (0)

No other definition uses this definition.