feat(conf): sys、mon、alarm、plugins、broker、mqtt conf to hocon
This commit is contained in:
parent
c7cbe819ed
commit
4b87594839
File diff suppressed because it is too large
Load Diff
|
@ -54,7 +54,7 @@
|
|||
-export([includes/0]).
|
||||
|
||||
structs() -> ["cluster", "node", "rpc", "log", "lager",
|
||||
"acl", "mqtt", "zone", "listener", "module", "broker",
|
||||
"acl", "mqtt", "zone", "listener", "broker",
|
||||
"plugins", "sysmon", "os_mon", "vm_mon", "alarm"]
|
||||
++ includes().
|
||||
|
||||
|
@ -65,6 +65,12 @@ includes() ->
|
|||
[ "emqx_data_bridge"
|
||||
, "emqx_telemetry"
|
||||
, "emqx_retainer"
|
||||
, "emqx_statsd"
|
||||
, "emqx_authn"
|
||||
, "emqx_authz"
|
||||
, "emqx_bridge_mqtt"
|
||||
, "emqx_modules"
|
||||
, "emqx_management"
|
||||
].
|
||||
-endif.
|
||||
|
||||
|
@ -424,12 +430,6 @@ fields("deflate_opts") ->
|
|||
, {"client_max_window_bits", t(integer())}
|
||||
];
|
||||
|
||||
fields("module") ->
|
||||
[ {"loaded_file", t(string(), "emqx.modules_loaded_file", undefined)}
|
||||
, {"presence", ref("presence")}
|
||||
, {"subscription", ref("subscription")}
|
||||
, {"rewrite", ref("rewrite")}
|
||||
];
|
||||
|
||||
fields("presence") ->
|
||||
[ {"qos", t(range(0, 2), undefined, 1)}];
|
||||
|
@ -533,7 +533,6 @@ translation("emqx") ->
|
|||
[ {"flapping_detect_policy", fun tr_flapping_detect_policy/1}
|
||||
, {"zones", fun tr_zones/1}
|
||||
, {"listeners", fun tr_listeners/1}
|
||||
, {"modules", fun tr_modules/1}
|
||||
, {"sysmon", fun tr_sysmon/1}
|
||||
, {"os_mon", fun tr_os_mon/1}
|
||||
, {"vm_mon", fun tr_vm_mon/1}
|
||||
|
@ -827,38 +826,6 @@ tr_listeners(Conf) ->
|
|||
++ [SslListeners("quic", Name) || Name <- keys("listener.quic", Conf)]
|
||||
).
|
||||
|
||||
tr_modules(Conf) ->
|
||||
Subscriptions = fun() ->
|
||||
List = keys("module.subscription", Conf),
|
||||
TopicList = [{N, conf_get(["module", "subscription", N, "topic"], Conf)}|| N <- List],
|
||||
[{list_to_binary(T), #{ qos => conf_get("module.subscription." ++ N ++ ".qos", Conf, 0),
|
||||
nl => conf_get("module.subscription." ++ N ++ ".nl", Conf, 0),
|
||||
rap => conf_get("module.subscription." ++ N ++ ".rap", Conf, 0),
|
||||
rh => conf_get("module.subscription." ++ N ++ ".rh", Conf, 0)
|
||||
}} || {N, T} <- TopicList]
|
||||
end,
|
||||
Rewrites = fun() ->
|
||||
Rules = keys("module.rewrite.rule", Conf),
|
||||
PubRules = keys("module.rewrite.pub_rule", Conf),
|
||||
SubRules = keys("module.rewrite.sub_rule", Conf),
|
||||
TotalRules =
|
||||
[ {["module", "rewrite", "pub", "rule", R], conf_get(["module.rewrite.rule", R], Conf)} || R <- Rules] ++
|
||||
[ {["module", "rewrite", "pub", "rule", R], conf_get(["module.rewrite.pub_rule", R], Conf)} || R <- PubRules] ++
|
||||
[ {["module", "rewrite", "sub", "rule", R], conf_get(["module.rewrite.rule", R], Conf)} || R <- Rules] ++
|
||||
[ {["module", "rewrite", "sub", "rule", R], conf_get(["module.rewrite.sub_rule", R], Conf)} || R <- SubRules],
|
||||
lists:map(fun({[_, "rewrite", PubOrSub, "rule", _], Rule}) ->
|
||||
[Topic, Re, Dest] = string:tokens(Rule, " "),
|
||||
{rewrite, list_to_atom(PubOrSub), list_to_binary(Topic), list_to_binary(Re), list_to_binary(Dest)}
|
||||
end, TotalRules)
|
||||
end,
|
||||
lists:append([
|
||||
[{emqx_mod_presence, [{qos, conf_get("module.presence.qos", Conf, 1)}]}],
|
||||
[{emqx_mod_subscription, Subscriptions()}],
|
||||
[{emqx_mod_rewrite, Rewrites()}],
|
||||
[{emqx_mod_topic_metrics, []}],
|
||||
[{emqx_mod_delayed, []}]
|
||||
]).
|
||||
|
||||
tr_sysmon(Conf) ->
|
||||
Keys = maps:to_list(conf_get("sysmon", Conf, #{})),
|
||||
[{binary_to_atom(K, utf8), maps:get(value, V)} || {K, V} <- Keys].
|
||||
|
|
Loading…
Reference in New Issue