fix(elvis): improve some code format
This commit is contained in:
parent
37aeb28a79
commit
a0e81226d7
|
@ -292,7 +292,7 @@ subscribers(Group, Topic) ->
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
init([]) ->
|
init([]) ->
|
||||||
mria:wait_for_tables([?TAB]),
|
ok = mria:wait_for_tables([?TAB]),
|
||||||
{ok, _} = mnesia:subscribe({table, ?TAB, simple}),
|
{ok, _} = mnesia:subscribe({table, ?TAB, simple}),
|
||||||
{atomic, PMon} = mria:transaction(?SHARED_SUB_SHARD, fun init_monitors/0),
|
{atomic, PMon} = mria:transaction(?SHARED_SUB_SHARD, fun init_monitors/0),
|
||||||
ok = emqx_tables:new(?SHARED_SUBS, [protected, bag]),
|
ok = emqx_tables:new(?SHARED_SUBS, [protected, bag]),
|
||||||
|
|
|
@ -114,11 +114,15 @@ on_client_disconnected(ClientInfo, Reason, ConnInfo, Env) ->
|
||||||
|
|
||||||
on_session_subscribed(ClientInfo, Topic, SubOpts, Env) ->
|
on_session_subscribed(ClientInfo, Topic, SubOpts, Env) ->
|
||||||
apply_event('session.subscribed',
|
apply_event('session.subscribed',
|
||||||
fun() -> eventmsg_sub_or_unsub('session.subscribed', ClientInfo, Topic, SubOpts) end, Env).
|
fun() ->
|
||||||
|
eventmsg_sub_or_unsub('session.subscribed', ClientInfo, Topic, SubOpts)
|
||||||
|
end, Env).
|
||||||
|
|
||||||
on_session_unsubscribed(ClientInfo, Topic, SubOpts, Env) ->
|
on_session_unsubscribed(ClientInfo, Topic, SubOpts, Env) ->
|
||||||
apply_event('session.unsubscribed',
|
apply_event('session.unsubscribed',
|
||||||
fun() -> eventmsg_sub_or_unsub('session.unsubscribed', ClientInfo, Topic, SubOpts) end, Env).
|
fun() ->
|
||||||
|
eventmsg_sub_or_unsub('session.unsubscribed', ClientInfo, Topic, SubOpts)
|
||||||
|
end, Env).
|
||||||
|
|
||||||
on_message_dropped(Message, _, Reason, Env) ->
|
on_message_dropped(Message, _, Reason, Env) ->
|
||||||
case ignore_sys_message(Message) of
|
case ignore_sys_message(Message) of
|
||||||
|
@ -151,7 +155,8 @@ on_message_acked(ClientInfo, Message, Env) ->
|
||||||
%% Event Messages
|
%% Event Messages
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
eventmsg_publish(Message = #message{id = Id, from = ClientId, qos = QoS, flags = Flags, topic = Topic, headers = Headers, payload = Payload, timestamp = Timestamp}) ->
|
eventmsg_publish(Message = #message{id = Id, from = ClientId, qos = QoS, flags = Flags,
|
||||||
|
topic = Topic, headers = Headers, payload = Payload, timestamp = Timestamp}) ->
|
||||||
with_basic_columns('message.publish',
|
with_basic_columns('message.publish',
|
||||||
#{id => emqx_guid:to_hexstr(Id),
|
#{id => emqx_guid:to_hexstr(Id),
|
||||||
clientid => ClientId,
|
clientid => ClientId,
|
||||||
|
@ -236,7 +241,8 @@ eventmsg_sub_or_unsub(Event, _ClientInfo = #{
|
||||||
qos => QoS
|
qos => QoS
|
||||||
}).
|
}).
|
||||||
|
|
||||||
eventmsg_dropped(Message = #message{id = Id, from = ClientId, qos = QoS, flags = Flags, topic = Topic, headers = Headers, payload = Payload, timestamp = Timestamp}, Reason) ->
|
eventmsg_dropped(Message = #message{id = Id, from = ClientId, qos = QoS, flags = Flags,
|
||||||
|
topic = Topic, headers = Headers, payload = Payload, timestamp = Timestamp}, Reason) ->
|
||||||
with_basic_columns('message.dropped',
|
with_basic_columns('message.dropped',
|
||||||
#{id => emqx_guid:to_hexstr(Id),
|
#{id => emqx_guid:to_hexstr(Id),
|
||||||
reason => Reason,
|
reason => Reason,
|
||||||
|
@ -257,7 +263,9 @@ eventmsg_delivered(_ClientInfo = #{
|
||||||
peerhost := PeerHost,
|
peerhost := PeerHost,
|
||||||
clientid := ReceiverCId,
|
clientid := ReceiverCId,
|
||||||
username := ReceiverUsername
|
username := ReceiverUsername
|
||||||
}, Message = #message{id = Id, from = ClientId, qos = QoS, flags = Flags, topic = Topic, headers = Headers, payload = Payload, timestamp = Timestamp}) ->
|
}, Message = #message{id = Id, from = ClientId, qos = QoS, flags = Flags,
|
||||||
|
topic = Topic, headers = Headers, payload = Payload,
|
||||||
|
timestamp = Timestamp}) ->
|
||||||
with_basic_columns('message.delivered',
|
with_basic_columns('message.delivered',
|
||||||
#{id => emqx_guid:to_hexstr(Id),
|
#{id => emqx_guid:to_hexstr(Id),
|
||||||
from_clientid => ClientId,
|
from_clientid => ClientId,
|
||||||
|
@ -279,7 +287,10 @@ eventmsg_acked(_ClientInfo = #{
|
||||||
peerhost := PeerHost,
|
peerhost := PeerHost,
|
||||||
clientid := ReceiverCId,
|
clientid := ReceiverCId,
|
||||||
username := ReceiverUsername
|
username := ReceiverUsername
|
||||||
}, Message = #message{id = Id, from = ClientId, qos = QoS, flags = Flags, topic = Topic, headers = Headers, payload = Payload, timestamp = Timestamp}) ->
|
},
|
||||||
|
Message = #message{id = Id, from = ClientId, qos = QoS, flags = Flags,
|
||||||
|
topic = Topic, headers = Headers, payload = Payload,
|
||||||
|
timestamp = Timestamp}) ->
|
||||||
with_basic_columns('message.acked',
|
with_basic_columns('message.acked',
|
||||||
#{id => emqx_guid:to_hexstr(Id),
|
#{id => emqx_guid:to_hexstr(Id),
|
||||||
from_clientid => ClientId,
|
from_clientid => ClientId,
|
||||||
|
@ -455,37 +466,9 @@ columns_with_exam('message.publish') ->
|
||||||
, {<<"node">>, node()}
|
, {<<"node">>, node()}
|
||||||
];
|
];
|
||||||
columns_with_exam('message.delivered') ->
|
columns_with_exam('message.delivered') ->
|
||||||
[ {<<"event">>, 'message.delivered'}
|
columns_message_ack_delivered('message.delivered');
|
||||||
, {<<"id">>, emqx_guid:to_hexstr(emqx_guid:gen())}
|
|
||||||
, {<<"from_clientid">>, <<"c_emqx_1">>}
|
|
||||||
, {<<"from_username">>, <<"u_emqx_1">>}
|
|
||||||
, {<<"clientid">>, <<"c_emqx_2">>}
|
|
||||||
, {<<"username">>, <<"u_emqx_2">>}
|
|
||||||
, {<<"payload">>, <<"{\"msg\": \"hello\"}">>}
|
|
||||||
, {<<"peerhost">>, <<"192.168.0.10">>}
|
|
||||||
, {<<"topic">>, <<"t/a">>}
|
|
||||||
, {<<"qos">>, 1}
|
|
||||||
, {<<"flags">>, #{}}
|
|
||||||
, {<<"publish_received_at">>, erlang:system_time(millisecond)}
|
|
||||||
, {<<"timestamp">>, erlang:system_time(millisecond)}
|
|
||||||
, {<<"node">>, node()}
|
|
||||||
];
|
|
||||||
columns_with_exam('message.acked') ->
|
columns_with_exam('message.acked') ->
|
||||||
[ {<<"event">>, 'message.acked'}
|
columns_message_ack_delivered('message.acked');
|
||||||
, {<<"id">>, emqx_guid:to_hexstr(emqx_guid:gen())}
|
|
||||||
, {<<"from_clientid">>, <<"c_emqx_1">>}
|
|
||||||
, {<<"from_username">>, <<"u_emqx_1">>}
|
|
||||||
, {<<"clientid">>, <<"c_emqx_2">>}
|
|
||||||
, {<<"username">>, <<"u_emqx_2">>}
|
|
||||||
, {<<"payload">>, <<"{\"msg\": \"hello\"}">>}
|
|
||||||
, {<<"peerhost">>, <<"192.168.0.10">>}
|
|
||||||
, {<<"topic">>, <<"t/a">>}
|
|
||||||
, {<<"qos">>, 1}
|
|
||||||
, {<<"flags">>, #{}}
|
|
||||||
, {<<"publish_received_at">>, erlang:system_time(millisecond)}
|
|
||||||
, {<<"timestamp">>, erlang:system_time(millisecond)}
|
|
||||||
, {<<"node">>, node()}
|
|
||||||
];
|
|
||||||
columns_with_exam('message.dropped') ->
|
columns_with_exam('message.dropped') ->
|
||||||
[ {<<"event">>, 'message.dropped'}
|
[ {<<"event">>, 'message.dropped'}
|
||||||
, {<<"id">>, emqx_guid:to_hexstr(emqx_guid:gen())}
|
, {<<"id">>, emqx_guid:to_hexstr(emqx_guid:gen())}
|
||||||
|
@ -530,7 +513,12 @@ columns_with_exam('client.disconnected') ->
|
||||||
, {<<"node">>, node()}
|
, {<<"node">>, node()}
|
||||||
];
|
];
|
||||||
columns_with_exam('session.subscribed') ->
|
columns_with_exam('session.subscribed') ->
|
||||||
[ {<<"event">>, 'session.subscribed'}
|
columns_message_sub_unsub('session.subscribed');
|
||||||
|
columns_with_exam('session.unsubscribed') ->
|
||||||
|
columns_message_sub_unsub('session.unsubscribed').
|
||||||
|
|
||||||
|
columns_message_sub_unsub(EventName) ->
|
||||||
|
[ {<<"event">>, EventName}
|
||||||
, {<<"clientid">>, <<"c_emqx">>}
|
, {<<"clientid">>, <<"c_emqx">>}
|
||||||
, {<<"username">>, <<"u_emqx">>}
|
, {<<"username">>, <<"u_emqx">>}
|
||||||
, {<<"peerhost">>, <<"192.168.0.10">>}
|
, {<<"peerhost">>, <<"192.168.0.10">>}
|
||||||
|
@ -538,14 +526,21 @@ columns_with_exam('session.subscribed') ->
|
||||||
, {<<"qos">>, 1}
|
, {<<"qos">>, 1}
|
||||||
, {<<"timestamp">>, erlang:system_time(millisecond)}
|
, {<<"timestamp">>, erlang:system_time(millisecond)}
|
||||||
, {<<"node">>, node()}
|
, {<<"node">>, node()}
|
||||||
];
|
].
|
||||||
columns_with_exam('session.unsubscribed') ->
|
|
||||||
[ {<<"event">>, 'session.unsubscribed'}
|
columns_message_ack_delivered(EventName) ->
|
||||||
, {<<"clientid">>, <<"c_emqx">>}
|
[ {<<"event">>, EventName}
|
||||||
, {<<"username">>, <<"u_emqx">>}
|
, {<<"id">>, emqx_guid:to_hexstr(emqx_guid:gen())}
|
||||||
|
, {<<"from_clientid">>, <<"c_emqx_1">>}
|
||||||
|
, {<<"from_username">>, <<"u_emqx_1">>}
|
||||||
|
, {<<"clientid">>, <<"c_emqx_2">>}
|
||||||
|
, {<<"username">>, <<"u_emqx_2">>}
|
||||||
|
, {<<"payload">>, <<"{\"msg\": \"hello\"}">>}
|
||||||
, {<<"peerhost">>, <<"192.168.0.10">>}
|
, {<<"peerhost">>, <<"192.168.0.10">>}
|
||||||
, {<<"topic">>, <<"t/a">>}
|
, {<<"topic">>, <<"t/a">>}
|
||||||
, {<<"qos">>, 1}
|
, {<<"qos">>, 1}
|
||||||
|
, {<<"flags">>, #{}}
|
||||||
|
, {<<"publish_received_at">>, erlang:system_time(millisecond)}
|
||||||
, {<<"timestamp">>, erlang:system_time(millisecond)}
|
, {<<"timestamp">>, erlang:system_time(millisecond)}
|
||||||
, {<<"node">>, node()}
|
, {<<"node">>, node()}
|
||||||
].
|
].
|
||||||
|
|
Loading…
Reference in New Issue