pico-engine-core
Advanced tools
Changelog
0.12.0 - May 25, 2017
setting(..)
)<name> = defaction(<params...>){
<declaration 0>
<declaration 1>
...
<action block (i.e. anything you would put in a rule action)>
returns <expr 0>, <expr 1>, ...
}
NOTE: returns
is optional
For example
global {
foo = defaction(){
send_directive("foobar")
returns 1, 2, 3
}
}
rule bar {
select when ...
foo() setting(a, b, c)
fired {
//a = 1, b = 2, c = 3
}
}
Another example
global {
foo = defaction(){
every {
http:get(...) setting(resp)
}
return resp["content"].decode()["msg"]
}
}
rule bar {
select when ...
foo() setting(message)
}
sample
This will randomly select an action to run.rule bar {
select when ...
//randomly pick one of these 3 actions to run
sample {
send_directive("foo")
send_directive("bar")
send_directive("baz")
}
}
ActionBlock ->
<action> ;
| if <expr> then <action> ;
| if <expr> then every { <action 0> ; <action 1> ; ... }
| if <expr> then sample { <action 0> ; <action 1> ; ... }
| every { <action 0> ; <action 1> ; ... }
| sample { <action 0> ; <action 1> ; ... }
| choose <expr> { <action 0> ; <action 1> ; ... }
with
is no longer used for named arguments. Both for functions and actions.//OLD WAY
foo(1, 2) with a = 3 and b = 4
//NEW WAY
foo(1, 2, a = 3, b = 4)
with
is no longer used on raise
/schedule
//OLD WAY
raise domain event "type" with foo = 1 and bar = 2
//NEW WAY
raise domain event "type" attributes {"foo": 1, "bar": 2}
send_directive
no longer uses with
it's now send_directive(name, options = {})
//OLD WAY
send_directive("name") with foo = x and bar = y
//NEW WAY
send_directive("name", {"foo": x, "bar": y})
select when ...
//OLD WAY
select when foo bar;
//NEW WAY
select when foo bar
with