style(elvis): fix elvis style complaints
This commit is contained in:
parent
8fe342a02d
commit
60d5017eea
|
@ -328,10 +328,16 @@ handle_in(Packet = ?AUTH_PACKET(ReasonCode, _Properties),
|
||||||
connecting ->
|
connecting ->
|
||||||
process_connect(NProperties, ensure_connected(NChannel));
|
process_connect(NProperties, ensure_connected(NChannel));
|
||||||
_ ->
|
_ ->
|
||||||
handle_out(auth, {?RC_SUCCESS, NProperties}, NChannel#channel{conn_state = connected})
|
handle_out( auth
|
||||||
|
, {?RC_SUCCESS, NProperties}
|
||||||
|
, NChannel#channel{conn_state = connected}
|
||||||
|
)
|
||||||
end;
|
end;
|
||||||
{continue, NProperties, NChannel} ->
|
{continue, NProperties, NChannel} ->
|
||||||
handle_out(auth, {?RC_CONTINUE_AUTHENTICATION, NProperties}, NChannel#channel{conn_state = reauthenticating});
|
handle_out( auth
|
||||||
|
, {?RC_CONTINUE_AUTHENTICATION, NProperties}
|
||||||
|
, NChannel#channel{conn_state = reauthenticating}
|
||||||
|
);
|
||||||
{error, NReasonCode} ->
|
{error, NReasonCode} ->
|
||||||
case ConnState of
|
case ConnState of
|
||||||
connecting ->
|
connecting ->
|
||||||
|
@ -632,7 +638,7 @@ do_publish(PacketId, Msg = #message{qos = ?QOS_2},
|
||||||
?SLOG(warning, #{
|
?SLOG(warning, #{
|
||||||
msg => "dropped_qos2_packet",
|
msg => "dropped_qos2_packet",
|
||||||
reason => emqx_reason_codes:name(RC),
|
reason => emqx_reason_codes:name(RC),
|
||||||
packetId => PacketId
|
packet_id => PacketId
|
||||||
}),
|
}),
|
||||||
ok = emqx_metrics:inc('packets.publish.dropped'),
|
ok = emqx_metrics:inc('packets.publish.dropped'),
|
||||||
handle_out(pubrec, {PacketId, RC}, Channel)
|
handle_out(pubrec, {PacketId, RC}, Channel)
|
||||||
|
@ -790,7 +796,9 @@ handle_deliver(Delivers, Channel = #channel{takeover = true,
|
||||||
pendings = Pendings,
|
pendings = Pendings,
|
||||||
session = Session,
|
session = Session,
|
||||||
clientinfo = #{clientid := ClientId}}) ->
|
clientinfo = #{clientid := ClientId}}) ->
|
||||||
NPendings = lists:append(Pendings, emqx_session:ignore_local(maybe_nack(Delivers), ClientId, Session)),
|
NPendings = lists:append(
|
||||||
|
Pendings,
|
||||||
|
emqx_session:ignore_local(maybe_nack(Delivers), ClientId, Session)),
|
||||||
{ok, Channel#channel{pendings = NPendings}};
|
{ok, Channel#channel{pendings = NPendings}};
|
||||||
|
|
||||||
handle_deliver(Delivers, Channel = #channel{session = Session,
|
handle_deliver(Delivers, Channel = #channel{session = Session,
|
||||||
|
@ -1365,16 +1373,19 @@ authenticate(?AUTH_PACKET(_, #{'Authentication-Method' := AuthMethod} = Properti
|
||||||
{error, ?RC_BAD_AUTHENTICATION_METHOD}
|
{error, ?RC_BAD_AUTHENTICATION_METHOD}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
do_authenticate(#{auth_method := AuthMethod} = Credential, #channel{clientinfo = ClientInfo} = Channel) ->
|
do_authenticate(#{auth_method := AuthMethod} = Credential,
|
||||||
|
#channel{clientinfo = ClientInfo} = Channel) ->
|
||||||
Properties = #{'Authentication-Method' => AuthMethod},
|
Properties = #{'Authentication-Method' => AuthMethod},
|
||||||
case emqx_access_control:authenticate(Credential) of
|
case emqx_access_control:authenticate(Credential) of
|
||||||
{ok, Result} ->
|
{ok, Result} ->
|
||||||
{ok, Properties,
|
{ok, Properties,
|
||||||
Channel#channel{clientinfo = ClientInfo#{is_superuser => maps:get(is_superuser, Result, false)},
|
Channel#channel{
|
||||||
|
clientinfo = ClientInfo#{is_superuser => maps:get(is_superuser, Result, false)},
|
||||||
auth_cache = #{}}};
|
auth_cache = #{}}};
|
||||||
{ok, Result, AuthData} ->
|
{ok, Result, AuthData} ->
|
||||||
{ok, Properties#{'Authentication-Data' => AuthData},
|
{ok, Properties#{'Authentication-Data' => AuthData},
|
||||||
Channel#channel{clientinfo = ClientInfo#{is_superuser => maps:get(is_superuser, Result, false)},
|
Channel#channel{
|
||||||
|
clientinfo = ClientInfo#{is_superuser => maps:get(is_superuser, Result, false)},
|
||||||
auth_cache = #{}}};
|
auth_cache = #{}}};
|
||||||
{continue, AuthCache} ->
|
{continue, AuthCache} ->
|
||||||
{continue, Properties, Channel#channel{auth_cache = AuthCache}};
|
{continue, Properties, Channel#channel{auth_cache = AuthCache}};
|
||||||
|
|
|
@ -102,6 +102,11 @@
|
||||||
|
|
||||||
-define(T_TAKEOVER, 15000).
|
-define(T_TAKEOVER, 15000).
|
||||||
|
|
||||||
|
%% linting overrides
|
||||||
|
-elvis([ {elvis_style, invalid_dynamic_call, #{ignore => [emqx_cm]}}
|
||||||
|
, {elvis_style, god_modules, #{ignore => [emqx_cm]}}
|
||||||
|
]).
|
||||||
|
|
||||||
%% @doc Start the channel manager.
|
%% @doc Start the channel manager.
|
||||||
-spec(start_link() -> startlink_ret()).
|
-spec(start_link() -> startlink_ret()).
|
||||||
start_link() ->
|
start_link() ->
|
||||||
|
@ -245,7 +250,10 @@ open_session(false, ClientInfo = #{clientid := ClientId}, ConnInfo) ->
|
||||||
pendings => Pendings}};
|
pendings => Pendings}};
|
||||||
{living, ConnMod, ChanPid, Session} ->
|
{living, ConnMod, ChanPid, Session} ->
|
||||||
ok = emqx_session:resume(ClientInfo, Session),
|
ok = emqx_session:resume(ClientInfo, Session),
|
||||||
Session1 = emqx_persistent_session:persist(ClientInfo, ConnInfo, Session),
|
Session1 = emqx_persistent_session:persist( ClientInfo
|
||||||
|
, ConnInfo
|
||||||
|
, Session
|
||||||
|
),
|
||||||
Pendings = ConnMod:call(ChanPid, {takeover, 'end'}, ?T_TAKEOVER),
|
Pendings = ConnMod:call(ChanPid, {takeover, 'end'}, ?T_TAKEOVER),
|
||||||
register_channel(ClientId, Self, ConnInfo),
|
register_channel(ClientId, Self, ConnInfo),
|
||||||
{ok, #{session => Session1,
|
{ok, #{session => Session1,
|
||||||
|
@ -254,12 +262,18 @@ open_session(false, ClientInfo = #{clientid := ClientId}, ConnInfo) ->
|
||||||
{expired, OldSession} ->
|
{expired, OldSession} ->
|
||||||
_ = emqx_persistent_session:discard(ClientId, OldSession),
|
_ = emqx_persistent_session:discard(ClientId, OldSession),
|
||||||
Session = create_session(ClientInfo, ConnInfo),
|
Session = create_session(ClientInfo, ConnInfo),
|
||||||
Session1 = emqx_persistent_session:persist(ClientInfo, ConnInfo, Session),
|
Session1 = emqx_persistent_session:persist( ClientInfo
|
||||||
|
, ConnInfo
|
||||||
|
, Session
|
||||||
|
),
|
||||||
register_channel(ClientId, Self, ConnInfo),
|
register_channel(ClientId, Self, ConnInfo),
|
||||||
{ok, #{session => Session1, present => false}};
|
{ok, #{session => Session1, present => false}};
|
||||||
none ->
|
none ->
|
||||||
Session = create_session(ClientInfo, ConnInfo),
|
Session = create_session(ClientInfo, ConnInfo),
|
||||||
Session1 = emqx_persistent_session:persist(ClientInfo, ConnInfo, Session),
|
Session1 = emqx_persistent_session:persist( ClientInfo
|
||||||
|
, ConnInfo
|
||||||
|
, Session
|
||||||
|
),
|
||||||
register_channel(ClientId, Self, ConnInfo),
|
register_channel(ClientId, Self, ConnInfo),
|
||||||
{ok, #{session => Session1, present => false}}
|
{ok, #{session => Session1, present => false}}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue