| 1 |
-- main.mcl -- |
| 2 |
# state machine that previously experienced unusable slow type unification |
| 3 |
import "world" |
| 4 |
|
| 5 |
$ns = "estate" |
| 6 |
$exchanged = world.kvlookup($ns) |
| 7 |
$state = $exchanged[$hostname] || "default" |
| 8 |
|
| 9 |
if $state == "one" or $state == "default" { |
| 10 |
|
| 11 |
file "/tmp/mgmt/state" { |
| 12 |
content => "state: one\n", |
| 13 |
} |
| 14 |
|
| 15 |
exec "timer" { |
| 16 |
cmd => "/usr/bin/sleep 1s", |
| 17 |
} |
| 18 |
kv "${ns}" { |
| 19 |
key => $ns, |
| 20 |
value => "two", |
| 21 |
} |
| 22 |
Exec["timer"] -> Kv["${ns}"] |
| 23 |
} |
| 24 |
if $state == "two" { |
| 25 |
|
| 26 |
file "/tmp/mgmt/state" { |
| 27 |
content => "state: two\n", |
| 28 |
} |
| 29 |
|
| 30 |
exec "timer" { |
| 31 |
cmd => "/usr/bin/sleep 1s", |
| 32 |
} |
| 33 |
kv "${ns}" { |
| 34 |
key => $ns, |
| 35 |
value => "three", |
| 36 |
} |
| 37 |
Exec["timer"] -> Kv["${ns}"] |
| 38 |
} |
| 39 |
if $state == "three" { |
| 40 |
|
| 41 |
file "/tmp/mgmt/state" { |
| 42 |
content => "state: three\n", |
| 43 |
} |
| 44 |
|
| 45 |
exec "timer" { |
| 46 |
cmd => "/usr/bin/sleep 1s", |
| 47 |
} |
| 48 |
kv "${ns}" { |
| 49 |
key => $ns, |
| 50 |
value => "one", |
| 51 |
} |
| 52 |
Exec["timer"] -> Kv["${ns}"] |
| 53 |
} |
| 54 |
-- OUTPUT -- |
| 55 |
Edge: FuncValue -> call # fn |
| 56 |
Edge: FuncValue -> call # fn |
| 57 |
Edge: FuncValue -> call # fn |
| 58 |
Edge: FuncValue -> call # fn |
| 59 |
Edge: FuncValue -> call # fn |
| 60 |
Edge: FuncValue -> call # fn |
| 61 |
Edge: FuncValue -> call # fn |
| 62 |
Vertex: FuncValue |
| 63 |
Vertex: FuncValue |
| 64 |
Vertex: FuncValue |
| 65 |
Vertex: FuncValue |
| 66 |
Vertex: FuncValue |
| 67 |
Vertex: FuncValue |
| 68 |
Vertex: FuncValue |
| 69 |
Vertex: call |
| 70 |
Vertex: call |
| 71 |
Vertex: call |
| 72 |
Vertex: call |
| 73 |
Vertex: call |
| 74 |
Vertex: call |
| 75 |
Vertex: call |
| 76 |
Vertex: const |
| 77 |
Vertex: const |
| 78 |
Vertex: const |
| 79 |
Vertex: const |
| 80 |
Vertex: const |
| 81 |
Vertex: const |
| 82 |
Vertex: const |
| 83 |
Vertex: const |
| 84 |
Vertex: const |
| 85 |
Vertex: const |
| 86 |
Vertex: const |
| 87 |
Vertex: const |
| 88 |
Vertex: const |
| 89 |
Vertex: const |
| 90 |
Vertex: const |
| 91 |
Vertex: const |
| 92 |
Vertex: const |
| 93 |
Vertex: const |
| 94 |
Vertex: const |
| 95 |
Vertex: const |
| 96 |
Vertex: const |
| 97 |
Vertex: const |
| 98 |
Vertex: const |
| 99 |
Vertex: const |
| 100 |
Vertex: const |
| 101 |
Vertex: const |
| 102 |
Vertex: const |
| 103 |
Vertex: const |
| 104 |
Vertex: const |
| 105 |
Vertex: const |