From 93162c52b68c61ff684deda3ad32c25b3d6d1078 Mon Sep 17 00:00:00 2001 From: Gilbert Date: Mon, 11 Mar 2019 16:31:21 +0800 Subject: [PATCH] Fix conf parse bug (#2296) Prior to this change, there are some config entry which is not parsed correctly. So if user modify config such as reconnect_interval for bridge, the new config can not be taken into effect. --- priv/emqx.schema | 26 +++++++++++++++++--------- rebar.config | 1 - 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/priv/emqx.schema b/priv/emqx.schema index 708c2ed13..5161d5e94 100644 --- a/priv/emqx.schema +++ b/priv/emqx.schema @@ -1697,23 +1697,31 @@ end}. Cfg#{reconnect_delay_ms => Ms}; Tr(max_inflight, Count, Cfg) -> Cfg#{max_inflight_batches => Count}; + Tr(proto_ver, Ver, Cfg) -> + Cfg#{proto_ver => + case Ver of + mqttv3 -> v3; + mqttv4 -> v4; + mqttv5 -> v5; + _ -> v4 + end}; Tr(Key, Value, Cfg) -> Cfg#{Key => Value} end, - maps:to_list( - lists:foldl( + C = lists:foldl( fun({["bridge", Name, Opt], Val}, Acc) -> %% e.g #{aws => [{OptKey, OptVal}]} Init = [{list_to_atom(Opt), Val}, {connect_module, ConnMod(Name)}, {subscriptions, Subscriptions(Name)}, - {queue, Queue(Name)} - ], - C = maps:update_with(list_to_atom(Name), - fun(Opts) -> Merge(list_to_atom(Opt), Val, Opts) end, Init, Acc), - maps:fold(Translate, #{}, C); + {queue, Queue(Name)}], + maps:update_with(list_to_atom(Name), fun(Opts) -> Merge(list_to_atom(Opt), Val, Opts) end, Init, Acc); (_, Acc) -> Acc - end, #{}, lists:usort(cuttlefish_variable:filter_by_prefix("bridge.", Conf)))) + end, #{}, lists:usort(cuttlefish_variable:filter_by_prefix("bridge.", Conf))), + C1 = maps:map(fun(Bn, Bc) -> + maps:to_list(maps:fold(Translate, #{}, maps:from_list(Bc))) + end, C), + maps:to_list(C1) end}. %%-------------------------------------------------------------------- @@ -1952,4 +1960,4 @@ end}. [{check_interval, cuttlefish:conf_get("vm_mon.check_interval", Conf)}, {process_high_watermark, cuttlefish:conf_get("vm_mon.process_high_watermark", Conf)}, {process_low_watermark, cuttlefish:conf_get("vm_mon.process_low_watermark", Conf)}] -end}. \ No newline at end of file +end}. diff --git a/rebar.config b/rebar.config index b6c68208b..745c22f68 100644 --- a/rebar.config +++ b/rebar.config @@ -29,4 +29,3 @@ {plugins, [coveralls]}. {profiles, [{test, [{deps, [{meck, "0.8.13"}]}]}]}. -