This commit adds a default timeout of 10 seconds to the rule engine's `jq/2` function, and adds a new function `jq/3` (where the last parameter is a timeout value). The default timeout can be configured with the setting "rule_engine.jq_function_default_timeout". Having a timeout when executing jq code in the rule engine is important as jq code can potentially run forever. Also, the Erlang jq library limits the number of jq programs that can execute concurrently so a jq program that loops forever could potentially also prevent a "non-buggy" jq program from ever starting.
23 lines
710 B
Plaintext
23 lines
710 B
Plaintext
##====================================================================
|
|
## Rule Engine for EMQX R5.0
|
|
##====================================================================
|
|
rule_engine {
|
|
ignore_sys_message = true
|
|
jq_function_default_timeout = 10s
|
|
#rules.my_republish_rule {
|
|
# description = "A simple rule that republishs MQTT messages from topic 't/1' to 't/2'"
|
|
# enable = true
|
|
# sql = "SELECT * FROM \"t/1\""
|
|
# outputs = [
|
|
# {
|
|
# function = republish
|
|
# args = {
|
|
# topic = "t/2"
|
|
# qos = "${qos}"
|
|
# payload = "${payload}"
|
|
# }
|
|
# }
|
|
# ]
|
|
#}
|
|
}
|