lang: funcs: core: Move world API functions
Some of the core functions interact with the remote "world" API. Move them all into the same package.
This commit is contained in:
@@ -6,9 +6,10 @@
|
||||
# time ./mgmt run --hostname h4 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2385 --server-urls http://127.0.0.1:2386 --tmp-prefix --no-pgp lang --lang examples/lang/exchange0.mcl
|
||||
|
||||
import "sys"
|
||||
import "world"
|
||||
|
||||
$rand = random1(8)
|
||||
$exchanged = exchange("keyns", $rand)
|
||||
$exchanged = world.exchange("keyns", $rand)
|
||||
|
||||
file "/tmp/mgmt/exchange-${sys.hostname()}" {
|
||||
content => template("Found: {{ . }}\n", $exchanged),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import "sys"
|
||||
import "world"
|
||||
|
||||
# here are all the possible options:
|
||||
#$opts = struct{strategy => "rr", max => 3, reuse => false, ttl => 10,}
|
||||
@@ -10,10 +11,10 @@ import "sys"
|
||||
$opts = struct{strategy => "rr", max => 2, ttl => 10,}
|
||||
|
||||
# schedule in a particular namespace with options:
|
||||
$set = schedule("xsched", $opts)
|
||||
$set = world.schedule("xsched", $opts)
|
||||
|
||||
# and if you want, you can omit the options entirely:
|
||||
#$set = schedule("xsched")
|
||||
#$set = world.schedule("xsched")
|
||||
|
||||
file "/tmp/mgmt/scheduled-${sys.hostname()}" {
|
||||
content => template("set: {{ . }}\n", $set),
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import "fmt"
|
||||
import "world"
|
||||
|
||||
$ns = "estate"
|
||||
$exchanged = kvlookup($ns)
|
||||
$exchanged = world.kvlookup($ns)
|
||||
$state = maplookup($exchanged, $hostname, "default")
|
||||
|
||||
exec "exec0" {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import "world"
|
||||
|
||||
$ns = "estate"
|
||||
$exchanged = kvlookup($ns)
|
||||
$exchanged = world.kvlookup($ns)
|
||||
|
||||
$state = maplookup($exchanged, $hostname, "default")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user