Files
core/test/rust/native/spawn.dever
T
2026-11-27 06:03:56 +00:00

150 lines
4.0 KiB
Plaintext

identity(value: Text) (out: Text) { out = value }
size(value: Text) (out: Int) { out = length(value) }
pair(value: Int) (left: Int, right: Int) {
left = value
right = value + 1
}
flow work(value: Int) (out: Int)
| step | kind | do |
| - | flow | dever.time.sleep(0) |
| out | calc | value |
flow child(value: Int) (out: Int)
| step | kind | do |
| task | calc | run(work(value)) |
| out | calc | wait(task) |
flow main() (out: Int)
| step | kind | do |
| task | calc | run(child(42)) |
| out | calc | wait(task) |
flow text(value: Text) (out: Int)
| step | kind | do |
| task | calc | run(identity(value)) |
| kept | calc | length(value) |
| received | calc | wait(task) |
| out | calc | kept + length(received) |
flow borrowed(value: Text) (out: Int)
| step | kind | do |
| task | calc | run(size(value)) |
| out | calc | wait(task) |
flow multiple(value: Int) (out: Int)
| step | kind | do |
| task | calc | run(pair(value)) |
| received | calc | wait(task) |
| out | calc | received.left + received.right |
flow cancel() ()
| step | kind | do |
| task | calc | run(dever.time.sleep(60000)) |
| - | calc | stop(task) |
type Attempt { Done(value: Int), error Failed(value: dever.time.SleepResult) }
rule resolve(value: Attempt) (out: Int) recover("report rejected delay as -1")
| value | out |
| Done(number) | number |
| Failed(error) | -1 |
flow failing(millis: Int) (out: Int)
| step | kind | do |
| - | flow | dever.time.sleep(millis) |
| out | calc | 10 |
flow captured(millis: Int) (out: Int)
| step | kind | do |
| task | calc | run(failing(millis)) |
| attempt: Attempt | calc | result(wait(task)) |
| out | rule | resolve(attempt) |
flow unfinished(millis: Int) (out: Int)
| step | kind | do |
| task | calc | run(work(9)) |
| - | flow | dever.time.sleep(millis) |
| out | calc | wait(task) |
flow recovered(millis: Int) (out: Int)
| step | kind | do |
| attempt: Attempt | flow | result(unfinished(millis)) |
| out | rule | resolve(attempt) |
flow together() (out: Int)
| step | kind | parallel | do |
| a | calc | start | run(work(11)) |
| b | calc | start | run(work(31)) |
| left | calc | join | wait(a) |
| right | calc | join | wait(b) |
| out | calc | - | left + right |
flow failStop(millis: Int) ()
| step | kind | do |
| task | calc | run(dever.time.sleep(millis)) |
| - | flow | dever.time.sleep(1) |
| - | calc | stop(task) |
flow overflow(value: Int) (out: Int)
| step | kind | do |
| task | calc | run(pair(value)) |
| received | calc | wait(task) |
| out | calc | received.right |
cmd main = main
cmd captured = captured
cmd cancel = cancel
cmd overflow = overflow
flow spawnedRecovery() (out: Int)
| step | kind | do |
| task | calc | run(recovered(-1)) |
| out | calc | wait(task) |
flow apply(value: Int, action: handler(value: Int) (out: Int)) (out: Int)
| step | kind | do |
| task | calc | run(action(value)) |
| out | calc | wait(task) |
flow handled() (out: Int)
| step | kind | do |
| out | flow | apply(42, child) |
type Problem { error Invalid }
guard(value: Int) (out: Int) {
check value > 0 else Problem.Invalid
out = value
}
alwaysFail() (out: Int) { out = fail(Problem.Invalid) }
flow neverReturns() (out: Int)
| step | kind | do |
| task | calc | run(alwaysFail()) |
| out | calc | wait(task) |
flow argumentFailure(value: Int) (out: Int)
| step | kind | do |
| attempt: Attempt | flow | result(unfinished(guard(value))) |
| out | rule | resolve(attempt) |
flow slow() (out: Int)
| step | kind | do |
| task | calc | run(failing(60000)) |
| out | calc | wait(task) |
flow failedGroup(millis: Int) (out: Int)
| step | kind | parallel | do |
| left | flow | tasks | slow() |
| right | flow | tasks | failing(millis) |
| out | calc | - | left + right |
flow recoveredGroup(millis: Int) (out: Int)
| step | kind | do |
| attempt: Attempt | flow | result(failedGroup(millis)) |
| out | rule | resolve(attempt) |
flow abandonedFault(value: Int) (out: Int)
| step | kind | do |
| task | calc | run(pair(value)) |
| - | flow | dever.time.sleep(1) |
| out | calc | fail(Problem.Invalid) |