Merge pull request #8917 from kjellwinblad/kjell/rule_engine_jq_func_implementation_module_config
Add rule engine configuration option for changing the implementation of the jq function
This commit is contained in:
commit
a71aa4ca9c
|
@ -261,6 +261,17 @@ of the rule, then the string "undefined" is used.
|
|||
}
|
||||
}
|
||||
|
||||
rule_engine_jq_implementation_module {
|
||||
desc {
|
||||
en: "The implementation module for the jq rule engine function. The two options are jq_nif and jq_port. With the jq_nif option an Erlang NIF library is used while with the jq_port option an implementation based on Erlang port programs is used. The jq_nif option (the default option) is the fastest implementation of the two but jq_port is safer as the jq programs will not execute in the same process as the Erlang VM."
|
||||
zh: "jq 规则引擎功能的实现模块。可用的两个选项是 jq_nif 和 jq_port。jq_nif 使用 Erlang NIF 库访问 jq 库,而 jq_port 使用基于 Erlang Port 的实现。jq_nif 方式(默认选项)是这两个选项中最快的实现,但 jq_port 方式更安全,因为这种情况下 jq 程序不会在 Erlang VM 进程中执行。"
|
||||
}
|
||||
label: {
|
||||
en: "JQ Implementation Module"
|
||||
zh: "JQ 实现模块"
|
||||
}
|
||||
}
|
||||
|
||||
desc_rule_engine {
|
||||
desc {
|
||||
en: """Configuration for the EMQX Rule Engine."""
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
{application, emqx_rule_engine, [
|
||||
{description, "EMQX Rule Engine"},
|
||||
% strict semver, bump manually!
|
||||
{vsn, "5.0.1"},
|
||||
{vsn, "5.0.2"},
|
||||
{modules, []},
|
||||
{registered, [emqx_rule_engine_sup, emqx_rule_engine]},
|
||||
{applications, [kernel, stdlib, rulesql, getopt]},
|
||||
|
|
|
@ -320,6 +320,10 @@ init([]) ->
|
|||
{write_concurrency, true},
|
||||
{read_concurrency, true}
|
||||
]),
|
||||
ok = emqx_config_handler:add_handler(
|
||||
[rule_engine, jq_implementation_module],
|
||||
emqx_rule_engine_schema
|
||||
),
|
||||
{ok, #{}}.
|
||||
|
||||
handle_call({insert_rule, Rule}, _From, State) ->
|
||||
|
|
|
@ -25,7 +25,8 @@
|
|||
namespace/0,
|
||||
roots/0,
|
||||
fields/1,
|
||||
desc/1
|
||||
desc/1,
|
||||
post_config_update/5
|
||||
]).
|
||||
|
||||
-export([validate_sql/1]).
|
||||
|
@ -49,6 +50,15 @@ fields("rule_engine") ->
|
|||
default => "10s",
|
||||
desc => ?DESC("rule_engine_jq_function_default_timeout")
|
||||
}
|
||||
)},
|
||||
{jq_implementation_module,
|
||||
?HOCON(
|
||||
hoconsc:enum([jq_nif, jq_port]),
|
||||
#{
|
||||
default => jq_nif,
|
||||
mapping => "jq.jq_implementation_module",
|
||||
desc => ?DESC("rule_engine_jq_implementation_module")
|
||||
}
|
||||
)}
|
||||
];
|
||||
fields("rules") ->
|
||||
|
@ -209,3 +219,13 @@ validate_sql(Sql) ->
|
|||
{ok, _Result} -> ok;
|
||||
{error, Reason} -> {error, Reason}
|
||||
end.
|
||||
|
||||
post_config_update(
|
||||
[rule_engine, jq_implementation_module],
|
||||
_Req,
|
||||
NewSysConf,
|
||||
_OldSysConf,
|
||||
_AppEnvs
|
||||
) ->
|
||||
jq:set_implementation_module(NewSysConf),
|
||||
ok.
|
||||
|
|
2
mix.exs
2
mix.exs
|
@ -616,7 +616,7 @@ defmodule EMQXUmbrella.MixProject do
|
|||
|
||||
defp jq_dep() do
|
||||
if enable_jq?(),
|
||||
do: [{:jq, github: "emqx/jq", tag: "v0.3.5", override: true}],
|
||||
do: [{:jq, github: "emqx/jq", tag: "v0.3.6", override: true}],
|
||||
else: []
|
||||
end
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ quicer() ->
|
|||
{quicer, {git, "https://github.com/emqx/quic.git", {tag, "0.0.16"}}}.
|
||||
|
||||
jq() ->
|
||||
{jq, {git, "https://github.com/emqx/jq", {tag, "v0.3.5"}}}.
|
||||
{jq, {git, "https://github.com/emqx/jq", {tag, "v0.3.6"}}}.
|
||||
|
||||
deps(Config) ->
|
||||
{deps, OldDeps} = lists:keyfind(deps, 1, Config),
|
||||
|
|
|
@ -263,3 +263,5 @@ hstreamdb
|
|||
SASL
|
||||
GSSAPI
|
||||
keytab
|
||||
jq
|
||||
nif
|
||||
|
|
Loading…
Reference in New Issue