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