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.
This commit is contained in:
parent
ad74772191
commit
93162c52b6
|
@ -1697,23 +1697,31 @@ end}.
|
||||||
Cfg#{reconnect_delay_ms => Ms};
|
Cfg#{reconnect_delay_ms => Ms};
|
||||||
Tr(max_inflight, Count, Cfg) ->
|
Tr(max_inflight, Count, Cfg) ->
|
||||||
Cfg#{max_inflight_batches => Count};
|
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) ->
|
Tr(Key, Value, Cfg) ->
|
||||||
Cfg#{Key => Value}
|
Cfg#{Key => Value}
|
||||||
end,
|
end,
|
||||||
maps:to_list(
|
C = lists:foldl(
|
||||||
lists:foldl(
|
|
||||||
fun({["bridge", Name, Opt], Val}, Acc) ->
|
fun({["bridge", Name, Opt], Val}, Acc) ->
|
||||||
%% e.g #{aws => [{OptKey, OptVal}]}
|
%% e.g #{aws => [{OptKey, OptVal}]}
|
||||||
Init = [{list_to_atom(Opt), Val},
|
Init = [{list_to_atom(Opt), Val},
|
||||||
{connect_module, ConnMod(Name)},
|
{connect_module, ConnMod(Name)},
|
||||||
{subscriptions, Subscriptions(Name)},
|
{subscriptions, Subscriptions(Name)},
|
||||||
{queue, Queue(Name)}
|
{queue, Queue(Name)}],
|
||||||
],
|
maps:update_with(list_to_atom(Name), fun(Opts) -> Merge(list_to_atom(Opt), Val, Opts) end, Init, Acc);
|
||||||
C = maps:update_with(list_to_atom(Name),
|
|
||||||
fun(Opts) -> Merge(list_to_atom(Opt), Val, Opts) end, Init, Acc),
|
|
||||||
maps:fold(Translate, #{}, C);
|
|
||||||
(_, Acc) -> 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}.
|
end}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
@ -1952,4 +1960,4 @@ end}.
|
||||||
[{check_interval, cuttlefish:conf_get("vm_mon.check_interval", Conf)},
|
[{check_interval, cuttlefish:conf_get("vm_mon.check_interval", Conf)},
|
||||||
{process_high_watermark, cuttlefish:conf_get("vm_mon.process_high_watermark", 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)}]
|
{process_low_watermark, cuttlefish:conf_get("vm_mon.process_low_watermark", Conf)}]
|
||||||
end}.
|
end}.
|
||||||
|
|
|
@ -29,4 +29,3 @@
|
||||||
{plugins, [coveralls]}.
|
{plugins, [coveralls]}.
|
||||||
|
|
||||||
{profiles, [{test, [{deps, [{meck, "0.8.13"}]}]}]}.
|
{profiles, [{test, [{deps, [{meck, "0.8.13"}]}]}]}.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue