✓
Passing This code compiles and runs correctly.
Code
// `{ restart: N, within: N unit }` — the block shorthand composes with
// the spacing declaration: `restart: 3` generates the bounded retry loop,
// `within: 1 s` throttles it. The first re-entry is always allowed; the
// second lands inside the one-second window, is declined, and the last
// failure proceeds upward in kind — two "try" lines total.
import std/io
import std/supervisor
pub tor worker { n: i64 }
| ok i64
| ?!boom i64
worker = std/io:print.ln("try {{ n:d }}")
|> if (n < 0)
| then => boom n
| else => ok n
pub tor sup { n: i64 }
| ok i64
| ?!boom i64
sup = worker(n)
| ok v => ok v
| boom f |> std/supervisor:supervised { restart: 3, within: 1 s }
sup(n: -10)
| ok r |> std/io:print.ln("got {{ r:d }}")
| boom f |> std/io:print.ln("gave up {{ f:d }}")
Actual
try -10
try -10
gave up -10
Expected output
try -10
try -10
gave up -10
Flows
subflow ~worker click a branch to expand · @labels scroll to their anchor
print.ln (expr: "try {{ n:d }}")
subflow ~sup click a branch to expand · @labels scroll to their anchor
worker (n)
flow ~sup click a branch to expand · @labels scroll to their anchor
sup (n: -10)
Test Configuration
MUST_RUN