Ver código fonte

chore(chan): rename `Name` → `TimerName` for better readability

Andrew Mayorov 2 anos atrás
pai
commit
8670efbfa0

+ 17 - 17
apps/emqx/src/emqx_channel.erl

@@ -1316,48 +1316,48 @@ handle_timeout(
     end;
     end;
 handle_timeout(
 handle_timeout(
     _TRef,
     _TRef,
-    Name,
+    TimerName,
     Channel = #channel{conn_state = disconnected}
     Channel = #channel{conn_state = disconnected}
-) when ?IS_COMMON_SESSION_TIMER(Name) ->
+) when ?IS_COMMON_SESSION_TIMER(TimerName) ->
     {ok, Channel};
     {ok, Channel};
 handle_timeout(
 handle_timeout(
     _TRef,
     _TRef,
-    Name,
+    TimerName,
     Channel = #channel{session = Session, clientinfo = ClientInfo}
     Channel = #channel{session = Session, clientinfo = ClientInfo}
-) when ?IS_COMMON_SESSION_TIMER(Name) ->
-    % NOTE
-    % Responsibility for these timers is smeared across both this module and the
-    % `emqx_session` module: the latter holds configured timer intervals, and is
-    % responsible for the actual timeout logic. Yet they are managed here, since
-    % they are kind of common to all session implementations.
-    case emqx_session:handle_timeout(ClientInfo, Name, Session) of
+) when ?IS_COMMON_SESSION_TIMER(TimerName) ->
+    %% NOTE
+    %% Responsibility for these timers is smeared across both this module and the
+    %% `emqx_session` module: the latter holds configured timer intervals, and is
+    %% responsible for the actual timeout logic. Yet they are managed here, since
+    %% they are kind of common to all session implementations.
+    case emqx_session:handle_timeout(ClientInfo, TimerName, Session) of
         {ok, Publishes, NSession} ->
         {ok, Publishes, NSession} ->
             NChannel = Channel#channel{session = NSession},
             NChannel = Channel#channel{session = NSession},
-            handle_out(publish, Publishes, clean_timer(Name, NChannel));
+            handle_out(publish, Publishes, clean_timer(TimerName, NChannel));
         {ok, Publishes, Timeout, NSession} ->
         {ok, Publishes, Timeout, NSession} ->
             NChannel = Channel#channel{session = NSession},
             NChannel = Channel#channel{session = NSession},
-            handle_out(publish, Publishes, reset_timer(Name, Timeout, NChannel))
+            handle_out(publish, Publishes, reset_timer(TimerName, Timeout, NChannel))
     end;
     end;
 handle_timeout(_TRef, expire_session, Channel) ->
 handle_timeout(_TRef, expire_session, Channel) ->
     shutdown(expired, Channel);
     shutdown(expired, Channel);
 handle_timeout(
 handle_timeout(
     _TRef,
     _TRef,
-    Name = will_message,
+    will_message = TimerName,
     Channel = #channel{clientinfo = ClientInfo, will_msg = WillMsg}
     Channel = #channel{clientinfo = ClientInfo, will_msg = WillMsg}
 ) ->
 ) ->
     (WillMsg =/= undefined) andalso publish_will_msg(ClientInfo, WillMsg),
     (WillMsg =/= undefined) andalso publish_will_msg(ClientInfo, WillMsg),
-    {ok, clean_timer(Name, Channel#channel{will_msg = undefined})};
+    {ok, clean_timer(TimerName, Channel#channel{will_msg = undefined})};
 handle_timeout(
 handle_timeout(
     _TRef,
     _TRef,
-    expire_quota_limit = Name,
+    expire_quota_limit = TimerName,
     #channel{quota = Quota} = Channel
     #channel{quota = Quota} = Channel
 ) ->
 ) ->
     case emqx_limiter_container:retry(?LIMITER_ROUTING, Quota) of
     case emqx_limiter_container:retry(?LIMITER_ROUTING, Quota) of
         {_, Intv, Quota2} ->
         {_, Intv, Quota2} ->
-            Channel2 = ensure_timer(Name, Intv, Channel#channel{quota = Quota2}),
+            Channel2 = ensure_timer(TimerName, Intv, Channel#channel{quota = Quota2}),
             {ok, Channel2};
             {ok, Channel2};
         {_, Quota2} ->
         {_, Quota2} ->
-            {ok, clean_timer(Name, Channel#channel{quota = Quota2})}
+            {ok, clean_timer(TimerName, Channel#channel{quota = Quota2})}
     end;
     end;
 handle_timeout(TRef, Msg, Channel) ->
 handle_timeout(TRef, Msg, Channel) ->
     case emqx_hooks:run_fold('client.timeout', [TRef, Msg], []) of
     case emqx_hooks:run_fold('client.timeout', [TRef, Msg], []) of

+ 10 - 10
apps/emqx_gateway_mqttsn/src/emqx_mqttsn_channel.erl

@@ -2060,35 +2060,35 @@ handle_timeout(
     {ok, Channel};
     {ok, Channel};
 handle_timeout(
 handle_timeout(
     _TRef,
     _TRef,
-    retry_delivery,
+    retry_delivery = TimerName,
     Channel = #channel{conn_state = asleep}
     Channel = #channel{conn_state = asleep}
 ) ->
 ) ->
-    {ok, reset_timer(retry_delivery, Channel)};
+    {ok, reset_timer(TimerName, Channel)};
 handle_timeout(
 handle_timeout(
     _TRef,
     _TRef,
-    _Name = expire_awaiting_rel,
+    expire_awaiting_rel,
     Channel = #channel{conn_state = disconnected}
     Channel = #channel{conn_state = disconnected}
 ) ->
 ) ->
     {ok, Channel};
     {ok, Channel};
 handle_timeout(
 handle_timeout(
     _TRef,
     _TRef,
-    Name = expire_awaiting_rel,
+    expire_awaiting_rel = TimerName,
     Channel = #channel{conn_state = asleep}
     Channel = #channel{conn_state = asleep}
 ) ->
 ) ->
-    {ok, reset_timer(Name, Channel)};
+    {ok, reset_timer(TimerName, Channel)};
 handle_timeout(
 handle_timeout(
     _TRef,
     _TRef,
-    Name,
+    TimerName,
     Channel = #channel{session = Session, clientinfo = ClientInfo}
     Channel = #channel{session = Session, clientinfo = ClientInfo}
-) when Name == retry_delivery; Name == expire_awaiting_rel ->
-    case emqx_mqttsn_session:handle_timeout(ClientInfo, Name, Session) of
+) when TimerName == retry_delivery; TimerName == expire_awaiting_rel ->
+    case emqx_mqttsn_session:handle_timeout(ClientInfo, TimerName, Session) of
         {ok, Publishes, NSession} ->
         {ok, Publishes, NSession} ->
             NChannel = Channel#channel{session = NSession},
             NChannel = Channel#channel{session = NSession},
-            handle_out(publish, Publishes, clean_timer(Name, NChannel));
+            handle_out(publish, Publishes, clean_timer(TimerName, NChannel));
         {ok, Publishes, Timeout, NSession} ->
         {ok, Publishes, Timeout, NSession} ->
             NChannel = Channel#channel{session = NSession},
             NChannel = Channel#channel{session = NSession},
             %% XXX: These replay messages should awaiting register acked?
             %% XXX: These replay messages should awaiting register acked?
-            handle_out(publish, Publishes, reset_timer(Name, Timeout, NChannel))
+            handle_out(publish, Publishes, reset_timer(TimerName, Timeout, NChannel))
     end;
     end;
 handle_timeout(
 handle_timeout(
     _TRef,
     _TRef,