fix(emqx_gateway): Apply remarks
This commit is contained in:
parent
925654978e
commit
c4cb9973a6
|
@ -187,8 +187,12 @@ get_chan_info(GwName, ClientId, ChanPid) ->
|
|||
[pid()].
|
||||
lookup_by_clientid(GwName, ClientId) ->
|
||||
Nodes = mria_mnesia:running_nodes(),
|
||||
Pids = emqx_gateway_cm_proto_v1:lookup_by_clientid(Nodes, GwName, ClientId),
|
||||
lists:append([Pid || {ok, Pid} <- Pids]).
|
||||
case emqx_gateway_cm_proto_v1:lookup_by_clientid(Nodes, GwName, ClientId) of
|
||||
{Pids, []} ->
|
||||
lists:append(Pids);
|
||||
{_, _BadNodes} ->
|
||||
error(badrpc)
|
||||
end.
|
||||
|
||||
%% @doc Update infos of the channel.
|
||||
-spec set_chan_info(gateway_name(),
|
||||
|
|
|
@ -244,9 +244,11 @@ lookup_client(GwName, ClientId, {M, F}) ->
|
|||
kickout_client(GwName, ClientId) ->
|
||||
Results = [emqx_gateway_cm:kick_session(GwName, ClientId, Pid)
|
||||
|| Pid <- emqx_gateway_cm:lookup_by_clientid(GwName, ClientId)],
|
||||
case Results =:= [] orelse lists:any(fun(Item) -> Item =:= ok end, Results) of
|
||||
true -> ok;
|
||||
false -> lists:last(Results)
|
||||
IsOk = lists:any(fun(Item) -> Item =:= ok end, Results),
|
||||
case {IsOk, Results} of
|
||||
{true , _ } -> ok;
|
||||
{_ , []} -> {error, not_found};
|
||||
{false, _ } -> lists:last(Results)
|
||||
end.
|
||||
|
||||
-spec list_client_subscriptions(gateway_name(), emqx_types:clientid())
|
||||
|
|
|
@ -38,7 +38,7 @@ introduced_in() ->
|
|||
-spec lookup_by_clientid([node()], emqx_gateway_cm:gateway_name(), emqx_types:clientid()) ->
|
||||
emqx_rpc:multicall_return([pid()]).
|
||||
lookup_by_clientid(Nodes, GwName, ClientId) ->
|
||||
erpc:multicall(Nodes, emqx_gateway_cm, do_lookup_by_clientid, [GwName, ClientId]).
|
||||
rpc:multicall(Nodes, emqx_gateway_cm, do_lookup_by_clientid, [GwName, ClientId]).
|
||||
|
||||
-spec get_chan_info(emqx_gateway_cm:gateway_name(), emqx_types:clientid(), pid())
|
||||
-> emqx_types:infos() | undefined | {badrpc, _}.
|
||||
|
|
|
@ -200,6 +200,7 @@ t_kick_session(_) ->
|
|||
100 ->
|
||||
?assert(false, "waiting kick msg timeout")
|
||||
end,
|
||||
?assertMatch({error, not_found}, emqx_gateway_http:kickout_client(?GWNAME, <<"i-dont-exist">>)),
|
||||
meck:unload(emqx_gateway_cm_registry).
|
||||
|
||||
t_unexpected_handle(Conf) ->
|
||||
|
|
Loading…
Reference in New Issue