chore(coap): update the subscriptions_cnt stats in time

This commit is contained in:
JianBo He 2023-07-06 14:54:48 +08:00
parent 800b154582
commit 6d2222318d
3 changed files with 11 additions and 8 deletions

View File

@ -118,8 +118,8 @@ info(ctx, #channel{ctx = Ctx}) ->
Ctx.
-spec stats(channel()) -> emqx_types:stats().
stats(_) ->
[].
stats(#channel{session = Session}) ->
emqx_coap_session:stats(Session).
-spec init(map(), map()) -> channel().
init(
@ -273,7 +273,7 @@ handle_call(
SubReq, TempMsg, #{}, Session
),
NSession = maps:get(session, Result),
{reply, {ok, {MountedTopic, NSubOpts}}, Channel#channel{session = NSession}};
{reply, {ok, {MountedTopic, NSubOpts}}, [{event, updated}], Channel#channel{session = NSession}};
handle_call(
{unsubscribe, Topic},
_From,
@ -300,7 +300,7 @@ handle_call(
UnSubReq, TempMsg, #{}, Session
),
NSession = maps:get(session, Result),
{reply, ok, Channel#channel{session = NSession}};
{reply, ok, [{event, updated}], Channel#channel{session = NSession}};
handle_call(subscriptions, _From, Channel = #channel{session = Session}) ->
Subs = emqx_coap_session:info(subscriptions, Session),
{reply, {ok, maps:to_list(Subs)}, Channel};

View File

@ -117,15 +117,15 @@ info(inflight, _) ->
info(inflight_cnt, _) ->
0;
info(inflight_max, _) ->
0;
infinity;
info(retry_interval, _) ->
infinity;
info(mqueue, _) ->
emqx_mqueue:init(#{max_len => 0, store_qos0 => false});
info(mqueue_len, #session{transport_manager = TM}) ->
maps:size(TM);
info(mqueue_max, _) ->
info(mqueue_len, _) ->
0;
info(mqueue_max, _) ->
infinity;
info(mqueue_dropped, _) ->
0;
info(next_pkt_id, _) ->

View File

@ -363,6 +363,9 @@ t_clients_subscription_api(_) ->
maps:get(topic, SubsResp2)
),
%% check subscription_cnt
{200, #{subscriptions_cnt := 1}} = request(get, "/gateways/coap/clients/client1"),
{204, _} = request(delete, Path ++ "/tx"),
{200, []} = request(get, Path)