chore(exhook): fix diaylzer warnings

This commit is contained in:
JianBo He 2021-08-12 16:16:10 +08:00
parent 4921c00a19
commit a4d29ec8de
3 changed files with 8 additions and 10 deletions

View File

@ -195,8 +195,10 @@ handle_info(_Info, State) ->
terminate(_Reason, State = #state{running = Running}) ->
_ = maps:fold(fun(Name, _, AccIn) ->
{ok, NAccIn} = do_unload_server(Name, AccIn),
NAccIn
case do_unload_server(Name, AccIn) of
{ok, NAccIn} -> NAccIn;
_ -> AccIn
end
end, State, Running),
_ = unload_exhooks(),
ok.

View File

@ -73,17 +73,13 @@
-export_type([server/0]).
-type options() :: #{ url := uri_string:uri_string()
, ssl => map()
}.
-dialyzer({nowarn_function, [inc_metrics/2]}).
%%--------------------------------------------------------------------
%% Load/Unload APIs
%%--------------------------------------------------------------------
-spec load(binary(), options(), map()) -> {ok, server()} | {error, term()} .
-spec load(binary(), map(), map()) -> {ok, server()} | {error, term()} .
load(Name, Opts0, ReqOpts) ->
{SvrAddr, ClientOpts} = channel_opts(Opts0),
case emqx_exhook_sup:start_grpc_client_channel(
@ -268,7 +264,7 @@ match_topic_filter(_, []) ->
match_topic_filter(TopicName, TopicFilter) ->
lists:any(fun(F) -> emqx_topic:match(TopicName, F) end, TopicFilter).
-spec do_call(string(), atom(), map(), map()) -> {ok, map()} | {error, term()}.
-spec do_call(binary(), atom(), map(), map()) -> {ok, map()} | {error, term()}.
do_call(ChannName, Fun, Req, ReqOpts) ->
Options = ReqOpts#{channel => ChannName},
?LOG(debug, "Call ~0p:~0p(~0p, ~0p)", [?PB_CLIENT_MOD, Fun, Req, Options]),

View File

@ -65,13 +65,13 @@ env(Key, Def) ->
%%--------------------------------------------------------------------
-spec start_grpc_client_channel(
string(),
binary(),
uri_string:uri_string(),
grpc_client:options()) -> {ok, pid()} | {error, term()}.
start_grpc_client_channel(Name, SvrAddr, Options) ->
grpc_client_sup:create_channel_pool(Name, SvrAddr, Options).
-spec stop_grpc_client_channel(string()) -> ok.
-spec stop_grpc_client_channel(binary()) -> ok.
stop_grpc_client_channel(Name) ->
%% Avoid crash due to hot-upgrade had unloaded
%% grpc application