fix(emqx_retainer): fix the bug that re-enable does't work
This commit is contained in:
parent
4f0684e887
commit
7ff26003e5
|
@ -187,8 +187,9 @@ init([]) ->
|
||||||
end}.
|
end}.
|
||||||
|
|
||||||
handle_call({update_config, Conf}, _, State) ->
|
handle_call({update_config, Conf}, _, State) ->
|
||||||
{ok, Config} = emqx:update_config([?APP], Conf),
|
OldConf = emqx:get_config([?APP]),
|
||||||
State2 = update_config(State, maps:get(config, Config)),
|
{ok, #{config := NewConf}} = emqx:update_config([?APP], Conf),
|
||||||
|
State2 = update_config(State, NewConf, OldConf),
|
||||||
{reply, ok, State2};
|
{reply, ok, State2};
|
||||||
|
|
||||||
handle_call({wait_semaphore, Id}, From, #{wait_quotas := Waits} = State) ->
|
handle_call({wait_semaphore, Id}, From, #{wait_quotas := Waits} = State) ->
|
||||||
|
@ -343,20 +344,32 @@ insert_shared_context(Key, Term) ->
|
||||||
get_msg_deliver_quota() ->
|
get_msg_deliver_quota() ->
|
||||||
emqx:get_config([?APP, flow_control, msg_deliver_quota]).
|
emqx:get_config([?APP, flow_control, msg_deliver_quota]).
|
||||||
|
|
||||||
-spec update_config(state(), hocons:config()) -> state().
|
-spec update_config(state(), hocons:config(), hocons:config()) -> state().
|
||||||
update_config(#{clear_timer := ClearTimer,
|
update_config(State, Conf, OldConf) ->
|
||||||
release_quota_timer := QuotaTimer} = State, Conf) ->
|
update_config(maps:get(enable, Conf),
|
||||||
#{enable := Enable,
|
maps:get(enable, OldConf),
|
||||||
config := Config,
|
State,
|
||||||
|
Conf,
|
||||||
|
OldConf).
|
||||||
|
|
||||||
|
-spec update_config(boolean(), boolean(), state(), hocons:config(), hocons:config()) -> state().
|
||||||
|
update_config(false, _, State, _, _) ->
|
||||||
|
disable_retainer(State);
|
||||||
|
|
||||||
|
update_config(true, false, State, NewConf, _) ->
|
||||||
|
enable_retainer(State, NewConf);
|
||||||
|
|
||||||
|
update_config(true, true,
|
||||||
|
#{clear_timer := ClearTimer,
|
||||||
|
release_quota_timer := QuotaTimer} = State, NewConf, OldConf) ->
|
||||||
|
#{config := Cfg,
|
||||||
flow_control := #{quota_release_interval := QuotaInterval},
|
flow_control := #{quota_release_interval := QuotaInterval},
|
||||||
msg_clear_interval := ClearInterval} = Conf,
|
msg_clear_interval := ClearInterval} = NewConf,
|
||||||
|
|
||||||
#{config := OldConfig} = emqx:get_config([?APP]),
|
#{config := OldCfg} = OldConf,
|
||||||
|
|
||||||
case Enable of
|
StorageType = maps:get(type, Cfg),
|
||||||
true ->
|
OldStrorageType = maps:get(type, OldCfg),
|
||||||
StorageType = maps:get(type, Config),
|
|
||||||
OldStrorageType = maps:get(type, OldConfig),
|
|
||||||
case OldStrorageType of
|
case OldStrorageType of
|
||||||
StorageType ->
|
StorageType ->
|
||||||
State#{clear_timer := check_timer(ClearTimer,
|
State#{clear_timer := check_timer(ClearTimer,
|
||||||
|
@ -367,10 +380,7 @@ update_config(#{clear_timer := ClearTimer,
|
||||||
release_deliver_quota)};
|
release_deliver_quota)};
|
||||||
_ ->
|
_ ->
|
||||||
State2 = disable_retainer(State),
|
State2 = disable_retainer(State),
|
||||||
enable_retainer(State2, Conf)
|
enable_retainer(State2, NewConf)
|
||||||
end;
|
|
||||||
_ ->
|
|
||||||
disable_retainer(State)
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec enable_retainer(state(), hocon:config()) -> state().
|
-spec enable_retainer(state(), hocon:config()) -> state().
|
||||||
|
|
Loading…
Reference in New Issue