Merge pull request #7491 from HJianBo/fix-cm-call

fix(exproto): keep conn_mod attribute in ConnInfo
This commit is contained in:
JianBo He 2022-04-07 09:19:25 +08:00 committed by GitHub
commit e63f288ea7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 6 deletions

View File

@ -177,6 +177,8 @@ subscriptions(get, #{
ClientId = emqx_mgmt_util:urldecode(ClientId0), ClientId = emqx_mgmt_util:urldecode(ClientId0),
with_gateway(Name0, fun(GwName, _) -> with_gateway(Name0, fun(GwName, _) ->
case emqx_gateway_http:list_client_subscriptions(GwName, ClientId) of case emqx_gateway_http:list_client_subscriptions(GwName, ClientId) of
{error, not_found} ->
return_http_error(404, "client process not found");
{error, Reason} -> {error, Reason} ->
return_http_error(500, Reason); return_http_error(500, Reason);
{ok, Subs} -> {ok, Subs} ->
@ -202,8 +204,10 @@ subscriptions(post, #{
GwName, ClientId, Topic, SubOpts GwName, ClientId, Topic, SubOpts
) )
of of
{error, not_found} ->
return_http_error(404, "client process not found");
{error, Reason} -> {error, Reason} ->
return_http_error(404, Reason); return_http_error(500, Reason);
{ok, {NTopic, NSubOpts}} -> {ok, {NTopic, NSubOpts}} ->
{201, maps:merge(NSubOpts, #{topic => NTopic})} {201, maps:merge(NSubOpts, #{topic => NTopic})}
end end

View File

@ -694,17 +694,17 @@ call(GwName, ClientId, Req, Timeout) ->
do_call(GwName, ClientId, ChanPid, Req) -> do_call(GwName, ClientId, ChanPid, Req) ->
case do_get_chann_conn_mod(GwName, ClientId, ChanPid) of case do_get_chann_conn_mod(GwName, ClientId, ChanPid) of
undefined -> throw(noproc); undefined -> undefined;
ConnMod -> ConnMod:call(ChanPid, Req) ConnMod -> ConnMod:call(ChanPid, Req)
end. end.
do_call(GwName, ClientId, ChanPid, Req, Timeout) -> do_call(GwName, ClientId, ChanPid, Req, Timeout) ->
case do_get_chann_conn_mod(GwName, ClientId, ChanPid) of case do_get_chann_conn_mod(GwName, ClientId, ChanPid) of
undefined -> throw(noproc); undefined -> undefined;
ConnMod -> ConnMod:call(ChanPid, Req, Timeout) ConnMod -> ConnMod:call(ChanPid, Req, Timeout)
end. end.
-spec cast(gateway_name(), emqx_types:clientid(), term()) -> ok. -spec cast(gateway_name(), emqx_types:clientid(), term()) -> undefined | ok.
cast(GwName, ClientId, Req) -> cast(GwName, ClientId, Req) ->
with_channel( with_channel(
GwName, GwName,
@ -719,7 +719,7 @@ cast(GwName, ClientId, Req) ->
do_cast(GwName, ClientId, ChanPid, Req) -> do_cast(GwName, ClientId, ChanPid, Req) ->
case do_get_chann_conn_mod(GwName, ClientId, ChanPid) of case do_get_chann_conn_mod(GwName, ClientId, ChanPid) of
undefined -> throw(noproc); undefined -> undefined;
ConnMod -> ConnMod:cast(ChanPid, Req) ConnMod -> ConnMod:cast(ChanPid, Req)
end. end.

View File

@ -722,7 +722,6 @@ default_conninfo(ConnInfo) ->
clean_start => true, clean_start => true,
clientid => undefined, clientid => undefined,
username => undefined, username => undefined,
conn_mod => undefined,
conn_props => #{}, conn_props => #{},
connected => true, connected => true,
proto_name => <<"exproto">>, proto_name => <<"exproto">>,