fix: dialyzer warning

This commit is contained in:
zhongwencool 2022-02-16 16:50:28 +08:00
parent 34fe5082c4
commit 98b2cd683b
2 changed files with 9 additions and 8 deletions

View File

@ -71,14 +71,14 @@ purge() ->
init([LicenseFetcher, CheckInterval]) -> init([LicenseFetcher, CheckInterval]) ->
case LicenseFetcher() of case LicenseFetcher() of
{ok, License} -> {ok, License} ->
?LICENSE_TAB = ets:new(?LICENSE_TAB, [set, protected, named_table, read_concurrency]), ?LICENSE_TAB = ets:new(?LICENSE_TAB, [set, protected, named_table, {read_concurrency, true}]),
#{} = check_license(License), #{} = check_license(License),
State0 = ensure_check_license_timer(#{check_license_interval => CheckInterval, State0 = ensure_check_license_timer(#{check_license_interval => CheckInterval,
license => License}), license => License}),
State = ensure_check_expiry_timer(State0), State = ensure_check_expiry_timer(State0),
{ok, State}; {ok, State};
{error, _} = Error -> {error, Reason} ->
Error {stop, Reason}
end. end.
handle_call({update, License}, _From, State) -> handle_call({update, License}, _From, State) ->
@ -124,10 +124,11 @@ ensure_check_expiry_timer(State) ->
cancel_timer(State, Key) -> cancel_timer(State, Key) ->
Ref = maps:get(Key, State), Ref = maps:get(Key, State),
case is_reference(Ref) of _ = case is_reference(Ref) of
true -> erlang:cancel_timer(Ref); true -> erlang:cancel_timer(Ref);
false -> ok false -> ok
end. end,
ok.
check_license(License) -> check_license(License) ->
DaysLeft = days_left(License), DaysLeft = days_left(License),

View File

@ -76,7 +76,7 @@ code_change(_OldVsn, State, _Extra) ->
connection_quota_early_alarm() -> connection_quota_early_alarm() ->
connection_quota_early_alarm(emqx_license_checker:limits()). connection_quota_early_alarm(emqx_license_checker:limits()).
connection_quota_early_alarm(#{max_connections := Max}) when is_integer(Max) -> connection_quota_early_alarm({ok, #{max_connections := Max}}) when is_integer(Max) ->
Count = connection_count(), Count = connection_count(),
Low = emqx_conf:get([license, connection_low_watermark], 0.75), Low = emqx_conf:get([license, connection_low_watermark], 0.75),
High = emqx_conf:get([license, connection_high_watermark], 0.80), High = emqx_conf:get([license, connection_high_watermark], 0.80),