feat: upgrade erlfmt to support maybe syntax
This commit is contained in:
parent
5bc67cb288
commit
e9c8446d57
|
@ -14,7 +14,7 @@
|
||||||
%% limitations under the License.
|
%% limitations under the License.
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
-type maybe(T) :: undefined | T.
|
-type option(T) :: undefined | T.
|
||||||
|
|
||||||
-type startlink_ret() :: {ok, pid()} | ignore | {error, term()}.
|
-type startlink_ret() :: {ok, pid()} | ignore | {error, term()}.
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@
|
||||||
{statistics, true}
|
{statistics, true}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
{project_plugins, [erlfmt]}.
|
{project_plugins, [{erlfmt, "1.3.0"}]}.
|
||||||
|
|
||||||
{erlfmt, [
|
{erlfmt, [
|
||||||
{files, [
|
{files, [
|
||||||
|
|
|
@ -440,7 +440,7 @@ subscribed(SubId, Topic) when ?IS_SUBID(SubId) ->
|
||||||
SubPid = emqx_broker_helper:lookup_subpid(SubId),
|
SubPid = emqx_broker_helper:lookup_subpid(SubId),
|
||||||
ets:member(?SUBOPTION, {Topic, SubPid}).
|
ets:member(?SUBOPTION, {Topic, SubPid}).
|
||||||
|
|
||||||
-spec get_subopts(pid(), emqx_types:topic() | emqx_types:share()) -> maybe(emqx_types:subopts()).
|
-spec get_subopts(pid(), emqx_types:topic() | emqx_types:share()) -> option(emqx_types:subopts()).
|
||||||
get_subopts(SubPid, Topic) when is_pid(SubPid), ?IS_TOPIC(Topic) ->
|
get_subopts(SubPid, Topic) when is_pid(SubPid), ?IS_TOPIC(Topic) ->
|
||||||
lookup_value(?SUBOPTION, {Topic, SubPid});
|
lookup_value(?SUBOPTION, {Topic, SubPid});
|
||||||
get_subopts(SubId, Topic) when ?IS_SUBID(SubId) ->
|
get_subopts(SubId, Topic) when ?IS_SUBID(SubId) ->
|
||||||
|
|
|
@ -71,11 +71,11 @@ register_sub(SubPid, SubId) when is_pid(SubPid) ->
|
||||||
error(subid_conflict)
|
error(subid_conflict)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec lookup_subid(pid()) -> maybe(emqx_types:subid()).
|
-spec lookup_subid(pid()) -> option(emqx_types:subid()).
|
||||||
lookup_subid(SubPid) when is_pid(SubPid) ->
|
lookup_subid(SubPid) when is_pid(SubPid) ->
|
||||||
emqx_utils_ets:lookup_value(?SUBMON, SubPid).
|
emqx_utils_ets:lookup_value(?SUBMON, SubPid).
|
||||||
|
|
||||||
-spec lookup_subpid(emqx_types:subid()) -> maybe(pid()).
|
-spec lookup_subpid(emqx_types:subid()) -> option(pid()).
|
||||||
lookup_subpid(SubId) ->
|
lookup_subpid(SubId) ->
|
||||||
emqx_utils_ets:lookup_value(?SUBID, SubId).
|
emqx_utils_ets:lookup_value(?SUBID, SubId).
|
||||||
|
|
||||||
|
|
|
@ -84,21 +84,21 @@
|
||||||
%% MQTT ClientInfo
|
%% MQTT ClientInfo
|
||||||
clientinfo :: emqx_types:clientinfo(),
|
clientinfo :: emqx_types:clientinfo(),
|
||||||
%% MQTT Session
|
%% MQTT Session
|
||||||
session :: maybe(emqx_session:t()),
|
session :: option(emqx_session:t()),
|
||||||
%% Keepalive
|
%% Keepalive
|
||||||
keepalive :: maybe(emqx_keepalive:keepalive()),
|
keepalive :: option(emqx_keepalive:keepalive()),
|
||||||
%% MQTT Will Msg
|
%% MQTT Will Msg
|
||||||
will_msg :: maybe(emqx_types:message()),
|
will_msg :: option(emqx_types:message()),
|
||||||
%% MQTT Topic Aliases
|
%% MQTT Topic Aliases
|
||||||
topic_aliases :: emqx_types:topic_aliases(),
|
topic_aliases :: emqx_types:topic_aliases(),
|
||||||
%% MQTT Topic Alias Maximum
|
%% MQTT Topic Alias Maximum
|
||||||
alias_maximum :: maybe(map()),
|
alias_maximum :: option(map()),
|
||||||
%% Authentication Data Cache
|
%% Authentication Data Cache
|
||||||
auth_cache :: maybe(map()),
|
auth_cache :: option(map()),
|
||||||
%% Quota checkers
|
%% Quota checkers
|
||||||
quota :: emqx_limiter_container:container(),
|
quota :: emqx_limiter_container:container(),
|
||||||
%% Timers
|
%% Timers
|
||||||
timers :: #{atom() => disabled | maybe(reference())},
|
timers :: #{atom() => disabled | option(reference())},
|
||||||
%% Conn State
|
%% Conn State
|
||||||
conn_state :: conn_state(),
|
conn_state :: conn_state(),
|
||||||
%% Takeover
|
%% Takeover
|
||||||
|
|
|
@ -200,12 +200,12 @@ do_unregister_channel({_ClientId, ChanPid} = Chan) ->
|
||||||
true.
|
true.
|
||||||
|
|
||||||
%% @doc Get info of a channel.
|
%% @doc Get info of a channel.
|
||||||
-spec get_chan_info(emqx_types:clientid()) -> maybe(emqx_types:infos()).
|
-spec get_chan_info(emqx_types:clientid()) -> option(emqx_types:infos()).
|
||||||
get_chan_info(ClientId) ->
|
get_chan_info(ClientId) ->
|
||||||
with_channel(ClientId, fun(ChanPid) -> get_chan_info(ClientId, ChanPid) end).
|
with_channel(ClientId, fun(ChanPid) -> get_chan_info(ClientId, ChanPid) end).
|
||||||
|
|
||||||
-spec do_get_chan_info(emqx_types:clientid(), chan_pid()) ->
|
-spec do_get_chan_info(emqx_types:clientid(), chan_pid()) ->
|
||||||
maybe(emqx_types:infos()).
|
option(emqx_types:infos()).
|
||||||
do_get_chan_info(ClientId, ChanPid) ->
|
do_get_chan_info(ClientId, ChanPid) ->
|
||||||
Chan = {ClientId, ChanPid},
|
Chan = {ClientId, ChanPid},
|
||||||
try
|
try
|
||||||
|
@ -215,7 +215,7 @@ do_get_chan_info(ClientId, ChanPid) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec get_chan_info(emqx_types:clientid(), chan_pid()) ->
|
-spec get_chan_info(emqx_types:clientid(), chan_pid()) ->
|
||||||
maybe(emqx_types:infos()).
|
option(emqx_types:infos()).
|
||||||
get_chan_info(ClientId, ChanPid) ->
|
get_chan_info(ClientId, ChanPid) ->
|
||||||
wrap_rpc(emqx_cm_proto_v2:get_chan_info(ClientId, ChanPid)).
|
wrap_rpc(emqx_cm_proto_v2:get_chan_info(ClientId, ChanPid)).
|
||||||
|
|
||||||
|
@ -230,12 +230,12 @@ set_chan_info(ClientId, Info) when ?IS_CLIENTID(ClientId) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% @doc Get channel's stats.
|
%% @doc Get channel's stats.
|
||||||
-spec get_chan_stats(emqx_types:clientid()) -> maybe(emqx_types:stats()).
|
-spec get_chan_stats(emqx_types:clientid()) -> option(emqx_types:stats()).
|
||||||
get_chan_stats(ClientId) ->
|
get_chan_stats(ClientId) ->
|
||||||
with_channel(ClientId, fun(ChanPid) -> get_chan_stats(ClientId, ChanPid) end).
|
with_channel(ClientId, fun(ChanPid) -> get_chan_stats(ClientId, ChanPid) end).
|
||||||
|
|
||||||
-spec do_get_chan_stats(emqx_types:clientid(), chan_pid()) ->
|
-spec do_get_chan_stats(emqx_types:clientid(), chan_pid()) ->
|
||||||
maybe(emqx_types:stats()).
|
option(emqx_types:stats()).
|
||||||
do_get_chan_stats(ClientId, ChanPid) ->
|
do_get_chan_stats(ClientId, ChanPid) ->
|
||||||
Chan = {ClientId, ChanPid},
|
Chan = {ClientId, ChanPid},
|
||||||
try
|
try
|
||||||
|
@ -245,7 +245,7 @@ do_get_chan_stats(ClientId, ChanPid) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec get_chan_stats(emqx_types:clientid(), chan_pid()) ->
|
-spec get_chan_stats(emqx_types:clientid(), chan_pid()) ->
|
||||||
maybe(emqx_types:stats()).
|
option(emqx_types:stats()).
|
||||||
get_chan_stats(ClientId, ChanPid) ->
|
get_chan_stats(ClientId, ChanPid) ->
|
||||||
wrap_rpc(emqx_cm_proto_v2:get_chan_stats(ClientId, ChanPid)).
|
wrap_rpc(emqx_cm_proto_v2:get_chan_stats(ClientId, ChanPid)).
|
||||||
|
|
||||||
|
@ -325,7 +325,7 @@ takeover_session_end({ConnMod, ChanPid}) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec pick_channel(emqx_types:clientid()) ->
|
-spec pick_channel(emqx_types:clientid()) ->
|
||||||
maybe(pid()).
|
option(pid()).
|
||||||
pick_channel(ClientId) ->
|
pick_channel(ClientId) ->
|
||||||
case lookup_channels(ClientId) of
|
case lookup_channels(ClientId) of
|
||||||
[] ->
|
[] ->
|
||||||
|
|
|
@ -32,7 +32,7 @@ start_link() ->
|
||||||
ekka_locker:start_link(?MODULE).
|
ekka_locker:start_link(?MODULE).
|
||||||
|
|
||||||
-spec trans(
|
-spec trans(
|
||||||
maybe(emqx_types:clientid()),
|
option(emqx_types:clientid()),
|
||||||
fun(([node()]) -> any())
|
fun(([node()]) -> any())
|
||||||
) -> any().
|
) -> any().
|
||||||
trans(undefined, Fun) ->
|
trans(undefined, Fun) ->
|
||||||
|
|
|
@ -99,13 +99,13 @@
|
||||||
%% Channel State
|
%% Channel State
|
||||||
channel :: emqx_channel:channel(),
|
channel :: emqx_channel:channel(),
|
||||||
%% GC State
|
%% GC State
|
||||||
gc_state :: maybe(emqx_gc:gc_state()),
|
gc_state :: option(emqx_gc:gc_state()),
|
||||||
%% Stats Timer
|
%% Stats Timer
|
||||||
stats_timer :: disabled | maybe(reference()),
|
stats_timer :: disabled | option(reference()),
|
||||||
%% Idle Timeout
|
%% Idle Timeout
|
||||||
idle_timeout :: integer() | infinity,
|
idle_timeout :: integer() | infinity,
|
||||||
%% Idle Timer
|
%% Idle Timer
|
||||||
idle_timer :: maybe(reference()),
|
idle_timer :: option(reference()),
|
||||||
%% Zone name
|
%% Zone name
|
||||||
zone :: atom(),
|
zone :: atom(),
|
||||||
%% Listener Type and Name
|
%% Listener Type and Name
|
||||||
|
@ -121,7 +121,7 @@
|
||||||
limiter_timer :: undefined | reference(),
|
limiter_timer :: undefined | reference(),
|
||||||
|
|
||||||
%% QUIC conn owner pid if in use.
|
%% QUIC conn owner pid if in use.
|
||||||
quic_conn_pid :: maybe(pid())
|
quic_conn_pid :: option(pid())
|
||||||
}).
|
}).
|
||||||
|
|
||||||
-record(retry, {
|
-record(retry, {
|
||||||
|
|
|
@ -86,11 +86,11 @@ do_run([{K, N} | T], St) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% @doc Info of GC state.
|
%% @doc Info of GC state.
|
||||||
-spec info(maybe(gc_state())) -> maybe(map()).
|
-spec info(option(gc_state())) -> option(map()).
|
||||||
info(?GCS(St)) -> St.
|
info(?GCS(St)) -> St.
|
||||||
|
|
||||||
%% @doc Reset counters to zero.
|
%% @doc Reset counters to zero.
|
||||||
-spec reset(maybe(gc_state())) -> gc_state().
|
-spec reset(option(gc_state())) -> gc_state().
|
||||||
reset(?GCS(St)) ->
|
reset(?GCS(St)) ->
|
||||||
?GCS(do_reset(St)).
|
?GCS(do_reset(St)).
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@
|
||||||
|
|
||||||
-record(callback, {
|
-record(callback, {
|
||||||
action :: action(),
|
action :: action(),
|
||||||
filter :: maybe(filter()),
|
filter :: option(filter()),
|
||||||
priority :: integer()
|
priority :: integer()
|
||||||
}).
|
}).
|
||||||
|
|
||||||
|
|
|
@ -23,30 +23,30 @@
|
||||||
-export([define/2]).
|
-export([define/2]).
|
||||||
-export([apply/2]).
|
-export([apply/2]).
|
||||||
|
|
||||||
-type t(T) :: maybe(T).
|
-type t(T) :: option(T).
|
||||||
-export_type([t/1]).
|
-export_type([t/1]).
|
||||||
|
|
||||||
-spec to_list(maybe(A)) -> [A].
|
-spec to_list(option(A)) -> [A].
|
||||||
to_list(undefined) ->
|
to_list(undefined) ->
|
||||||
[];
|
[];
|
||||||
to_list(Term) ->
|
to_list(Term) ->
|
||||||
[Term].
|
[Term].
|
||||||
|
|
||||||
-spec from_list([A]) -> maybe(A).
|
-spec from_list([A]) -> option(A).
|
||||||
from_list([]) ->
|
from_list([]) ->
|
||||||
undefined;
|
undefined;
|
||||||
from_list([Term]) ->
|
from_list([Term]) ->
|
||||||
Term.
|
Term.
|
||||||
|
|
||||||
-spec define(maybe(A), B) -> A | B.
|
-spec define(option(A), B) -> A | B.
|
||||||
define(undefined, Term) ->
|
define(undefined, Term) ->
|
||||||
Term;
|
Term;
|
||||||
define(Term, _) ->
|
define(Term, _) ->
|
||||||
Term.
|
Term.
|
||||||
|
|
||||||
%% @doc Apply a function to a maybe argument.
|
%% @doc Apply a function to a maybe argument.
|
||||||
-spec apply(fun((A) -> B), maybe(A)) ->
|
-spec apply(fun((A) -> B), option(A)) ->
|
||||||
maybe(B).
|
option(B).
|
||||||
apply(_Fun, undefined) ->
|
apply(_Fun, undefined) ->
|
||||||
undefined;
|
undefined;
|
||||||
apply(Fun, Term) when is_function(Fun) ->
|
apply(Fun, Term) when is_function(Fun) ->
|
||||||
|
|
|
@ -186,7 +186,7 @@ estimate_size(#message{topic = Topic, payload = Payload}) ->
|
||||||
TopicLengthSize = 2,
|
TopicLengthSize = 2,
|
||||||
FixedHeaderSize + VarLenSize + TopicLengthSize + TopicSize + PacketIdSize + PayloadSize.
|
FixedHeaderSize + VarLenSize + TopicLengthSize + TopicSize + PacketIdSize + PayloadSize.
|
||||||
|
|
||||||
-spec id(emqx_types:message()) -> maybe(binary()).
|
-spec id(emqx_types:message()) -> option(binary()).
|
||||||
id(#message{id = Id}) -> Id.
|
id(#message{id = Id}) -> Id.
|
||||||
|
|
||||||
-spec qos(emqx_types:message()) -> emqx_types:qos().
|
-spec qos(emqx_types:message()) -> emqx_types:qos().
|
||||||
|
@ -229,7 +229,7 @@ get_flag(Flag, Msg) ->
|
||||||
get_flag(Flag, #message{flags = Flags}, Default) ->
|
get_flag(Flag, #message{flags = Flags}, Default) ->
|
||||||
maps:get(Flag, Flags, Default).
|
maps:get(Flag, Flags, Default).
|
||||||
|
|
||||||
-spec get_flags(emqx_types:message()) -> maybe(map()).
|
-spec get_flags(emqx_types:message()) -> option(map()).
|
||||||
get_flags(#message{flags = Flags}) -> Flags.
|
get_flags(#message{flags = Flags}) -> Flags.
|
||||||
|
|
||||||
-spec set_flag(emqx_types:flag(), emqx_types:message()) -> emqx_types:message().
|
-spec set_flag(emqx_types:flag(), emqx_types:message()) -> emqx_types:message().
|
||||||
|
@ -252,7 +252,7 @@ unset_flag(Flag, Msg = #message{flags = Flags}) ->
|
||||||
set_headers(New, Msg = #message{headers = Old}) when is_map(New) ->
|
set_headers(New, Msg = #message{headers = Old}) when is_map(New) ->
|
||||||
Msg#message{headers = maps:merge(Old, New)}.
|
Msg#message{headers = maps:merge(Old, New)}.
|
||||||
|
|
||||||
-spec get_headers(emqx_types:message()) -> maybe(map()).
|
-spec get_headers(emqx_types:message()) -> option(map()).
|
||||||
get_headers(Msg) -> Msg#message.headers.
|
get_headers(Msg) -> Msg#message.headers.
|
||||||
|
|
||||||
-spec get_header(term(), emqx_types:message()) -> term().
|
-spec get_header(term(), emqx_types:message()) -> term().
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
-type mountpoint() :: binary().
|
-type mountpoint() :: binary().
|
||||||
|
|
||||||
-spec mount(maybe(mountpoint()), Any) -> Any when
|
-spec mount(option(mountpoint()), Any) -> Any when
|
||||||
Any ::
|
Any ::
|
||||||
emqx_types:topic()
|
emqx_types:topic()
|
||||||
| emqx_types:share()
|
| emqx_types:share()
|
||||||
|
@ -47,7 +47,7 @@ mount(MountPoint, Msg = #message{topic = Topic}) when is_binary(Topic) ->
|
||||||
mount(MountPoint, TopicFilters) when is_list(TopicFilters) ->
|
mount(MountPoint, TopicFilters) when is_list(TopicFilters) ->
|
||||||
[{prefix_maybe_share(MountPoint, Topic), SubOpts} || {Topic, SubOpts} <- TopicFilters].
|
[{prefix_maybe_share(MountPoint, Topic), SubOpts} || {Topic, SubOpts} <- TopicFilters].
|
||||||
|
|
||||||
-spec prefix_maybe_share(maybe(mountpoint()), Any) -> Any when
|
-spec prefix_maybe_share(option(mountpoint()), Any) -> Any when
|
||||||
Any ::
|
Any ::
|
||||||
emqx_types:topic()
|
emqx_types:topic()
|
||||||
| emqx_types:share().
|
| emqx_types:share().
|
||||||
|
@ -60,7 +60,7 @@ prefix_maybe_share(MountPoint, #share{group = Group, topic = Topic}) when
|
||||||
->
|
->
|
||||||
#share{group = Group, topic = prefix_maybe_share(MountPoint, Topic)}.
|
#share{group = Group, topic = prefix_maybe_share(MountPoint, Topic)}.
|
||||||
|
|
||||||
-spec unmount(maybe(mountpoint()), Any) -> Any when
|
-spec unmount(option(mountpoint()), Any) -> Any when
|
||||||
Any ::
|
Any ::
|
||||||
emqx_types:topic()
|
emqx_types:topic()
|
||||||
| emqx_types:share()
|
| emqx_types:share()
|
||||||
|
@ -84,7 +84,7 @@ unmount_maybe_share(MountPoint, TopicFilter = #share{topic = Topic}) when
|
||||||
->
|
->
|
||||||
TopicFilter#share{topic = unmount_maybe_share(MountPoint, Topic)}.
|
TopicFilter#share{topic = unmount_maybe_share(MountPoint, Topic)}.
|
||||||
|
|
||||||
-spec replvar(maybe(mountpoint()), map()) -> maybe(mountpoint()).
|
-spec replvar(option(mountpoint()), map()) -> option(mountpoint()).
|
||||||
replvar(undefined, _Vars) ->
|
replvar(undefined, _Vars) ->
|
||||||
undefined;
|
undefined;
|
||||||
replvar(MountPoint, Vars) ->
|
replvar(MountPoint, Vars) ->
|
||||||
|
|
|
@ -189,7 +189,7 @@ stats(#mqueue{max_len = MaxLen, dropped = Dropped} = MQ) ->
|
||||||
[{len, len(MQ)}, {max_len, MaxLen}, {dropped, Dropped}].
|
[{len, len(MQ)}, {max_len, MaxLen}, {dropped, Dropped}].
|
||||||
|
|
||||||
%% @doc Enqueue a message.
|
%% @doc Enqueue a message.
|
||||||
-spec in(message(), mqueue()) -> {maybe(message()), mqueue()}.
|
-spec in(message(), mqueue()) -> {option(message()), mqueue()}.
|
||||||
in(Msg = #message{qos = ?QOS_0}, MQ = #mqueue{store_qos0 = false}) ->
|
in(Msg = #message{qos = ?QOS_0}, MQ = #mqueue{store_qos0 = false}) ->
|
||||||
{_Dropped = Msg, MQ};
|
{_Dropped = Msg, MQ};
|
||||||
in(
|
in(
|
||||||
|
|
|
@ -48,7 +48,7 @@ get_counter(Key) ->
|
||||||
Cnt -> Cnt
|
Cnt -> Cnt
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec inc_counter(key(), number()) -> maybe(number()).
|
-spec inc_counter(key(), number()) -> option(number()).
|
||||||
inc_counter(Key, Inc) ->
|
inc_counter(Key, Inc) ->
|
||||||
put(Key, get_counter(Key) + Inc).
|
put(Key, get_counter(Key) + Inc).
|
||||||
|
|
||||||
|
|
|
@ -135,7 +135,7 @@
|
||||||
-type custom_timer_name() :: atom().
|
-type custom_timer_name() :: atom().
|
||||||
|
|
||||||
-type message() :: emqx_types:message().
|
-type message() :: emqx_types:message().
|
||||||
-type publish() :: {maybe(emqx_types:packet_id()), emqx_types:message()}.
|
-type publish() :: {option(emqx_types:packet_id()), emqx_types:message()}.
|
||||||
-type pubrel() :: {pubrel, emqx_types:packet_id()}.
|
-type pubrel() :: {pubrel, emqx_types:packet_id()}.
|
||||||
-type reply() :: publish() | pubrel().
|
-type reply() :: publish() | pubrel().
|
||||||
-type replies() :: [reply()] | reply().
|
-type replies() :: [reply()] | reply().
|
||||||
|
|
|
@ -62,7 +62,7 @@
|
||||||
-record(update, {name, countdown, interval, func}).
|
-record(update, {name, countdown, interval, func}).
|
||||||
|
|
||||||
-record(state, {
|
-record(state, {
|
||||||
timer :: maybe(reference()),
|
timer :: option(reference()),
|
||||||
updates :: [#update{}],
|
updates :: [#update{}],
|
||||||
tick_ms :: timeout()
|
tick_ms :: timeout()
|
||||||
}).
|
}).
|
||||||
|
|
|
@ -65,8 +65,8 @@
|
||||||
-import(emqx_utils, [start_timer/2]).
|
-import(emqx_utils, [start_timer/2]).
|
||||||
|
|
||||||
-record(state, {
|
-record(state, {
|
||||||
heartbeat :: maybe(reference()),
|
heartbeat :: option(reference()),
|
||||||
ticker :: maybe(reference()),
|
ticker :: option(reference()),
|
||||||
sysdescr :: binary()
|
sysdescr :: binary()
|
||||||
}).
|
}).
|
||||||
|
|
||||||
|
|
|
@ -173,7 +173,7 @@
|
||||||
atom() => term()
|
atom() => term()
|
||||||
}.
|
}.
|
||||||
-type clientinfo() :: #{
|
-type clientinfo() :: #{
|
||||||
zone := maybe(zone()),
|
zone := option(zone()),
|
||||||
protocol := protocol(),
|
protocol := protocol(),
|
||||||
peerhost := peerhost(),
|
peerhost := peerhost(),
|
||||||
sockport := non_neg_integer(),
|
sockport := non_neg_integer(),
|
||||||
|
@ -181,9 +181,9 @@
|
||||||
username := username(),
|
username := username(),
|
||||||
is_bridge := boolean(),
|
is_bridge := boolean(),
|
||||||
is_superuser := boolean(),
|
is_superuser := boolean(),
|
||||||
mountpoint := maybe(binary()),
|
mountpoint := option(binary()),
|
||||||
ws_cookie => maybe(list()),
|
ws_cookie => option(list()),
|
||||||
password => maybe(binary()),
|
password => option(binary()),
|
||||||
auth_result => auth_result(),
|
auth_result => auth_result(),
|
||||||
anonymous => boolean(),
|
anonymous => boolean(),
|
||||||
cn => binary(),
|
cn => binary(),
|
||||||
|
@ -191,8 +191,8 @@
|
||||||
atom() => term()
|
atom() => term()
|
||||||
}.
|
}.
|
||||||
-type clientid() :: binary() | atom().
|
-type clientid() :: binary() | atom().
|
||||||
-type username() :: maybe(binary()).
|
-type username() :: option(binary()).
|
||||||
-type password() :: maybe(binary()).
|
-type password() :: option(binary()).
|
||||||
-type peerhost() :: inet:ip_address().
|
-type peerhost() :: inet:ip_address().
|
||||||
-type peername() ::
|
-type peername() ::
|
||||||
{inet:ip_address(), inet:port_number()}
|
{inet:ip_address(), inet:port_number()}
|
||||||
|
@ -222,8 +222,8 @@
|
||||||
-type packet_id() :: 1..16#FFFF.
|
-type packet_id() :: 1..16#FFFF.
|
||||||
-type alias_id() :: 0..16#FFFF.
|
-type alias_id() :: 0..16#FFFF.
|
||||||
-type topic_aliases() :: #{
|
-type topic_aliases() :: #{
|
||||||
inbound => maybe(map()),
|
inbound => option(map()),
|
||||||
outbound => maybe(map())
|
outbound => option(map())
|
||||||
}.
|
}.
|
||||||
-type properties() :: #{atom() => term()}.
|
-type properties() :: #{atom() => term()}.
|
||||||
-type topic_filters() :: list({topic(), subopts()}).
|
-type topic_filters() :: list({topic(), subopts()}).
|
||||||
|
|
|
@ -76,15 +76,15 @@
|
||||||
%% Channel
|
%% Channel
|
||||||
channel :: emqx_channel:channel(),
|
channel :: emqx_channel:channel(),
|
||||||
%% GC State
|
%% GC State
|
||||||
gc_state :: maybe(emqx_gc:gc_state()),
|
gc_state :: option(emqx_gc:gc_state()),
|
||||||
%% Postponed Packets|Cmds|Events
|
%% Postponed Packets|Cmds|Events
|
||||||
postponed :: list(emqx_types:packet() | ws_cmd() | tuple()),
|
postponed :: list(emqx_types:packet() | ws_cmd() | tuple()),
|
||||||
%% Stats Timer
|
%% Stats Timer
|
||||||
stats_timer :: disabled | maybe(reference()),
|
stats_timer :: disabled | option(reference()),
|
||||||
%% Idle Timeout
|
%% Idle Timeout
|
||||||
idle_timeout :: timeout(),
|
idle_timeout :: timeout(),
|
||||||
%% Idle Timer
|
%% Idle Timer
|
||||||
idle_timer :: maybe(reference()),
|
idle_timer :: option(reference()),
|
||||||
%% Zone name
|
%% Zone name
|
||||||
zone :: atom(),
|
zone :: atom(),
|
||||||
%% Listener Type and Name
|
%% Listener Type and Name
|
||||||
|
|
|
@ -405,9 +405,9 @@ t_quic_update_opts(Config) ->
|
||||||
%% Unable to connect with old SSL options, server's cert is signed by another CA.
|
%% Unable to connect with old SSL options, server's cert is signed by another CA.
|
||||||
?assertError(
|
?assertError(
|
||||||
{transport_down, #{error := _, status := Status}} when
|
{transport_down, #{error := _, status := Status}} when
|
||||||
(Status =:= bad_certificate orelse
|
((Status =:= bad_certificate orelse
|
||||||
Status =:= cert_untrusted_root orelse
|
Status =:= cert_untrusted_root orelse
|
||||||
Status =:= handshake_failure),
|
Status =:= handshake_failure)),
|
||||||
ConnectFun(Host, Port, [
|
ConnectFun(Host, Port, [
|
||||||
{cacertfile, filename:join(PrivDir, "ca.pem")} | ClientSSLOpts
|
{cacertfile, filename:join(PrivDir, "ca.pem")} | ClientSSLOpts
|
||||||
])
|
])
|
||||||
|
@ -553,9 +553,9 @@ t_quic_update_opts_fail(Config) ->
|
||||||
%% Unable to connect with old SSL options, server's cert is signed by another CA.
|
%% Unable to connect with old SSL options, server's cert is signed by another CA.
|
||||||
?assertError(
|
?assertError(
|
||||||
{transport_down, #{error := _, status := Status}} when
|
{transport_down, #{error := _, status := Status}} when
|
||||||
(Status =:= bad_certificate orelse
|
((Status =:= bad_certificate orelse
|
||||||
Status =:= cert_untrusted_root orelse
|
Status =:= cert_untrusted_root orelse
|
||||||
Status =:= handshake_failure),
|
Status =:= handshake_failure)),
|
||||||
ConnectFun(Host, Port, [
|
ConnectFun(Host, Port, [
|
||||||
{cacertfile, filename:join(PrivDir, "ca.pem")} | ClientSSLOpts
|
{cacertfile, filename:join(PrivDir, "ca.pem")} | ClientSSLOpts
|
||||||
])
|
])
|
||||||
|
|
|
@ -114,8 +114,8 @@ clientinfo() ->
|
||||||
{username, username()},
|
{username, username()},
|
||||||
{is_bridge, boolean()},
|
{is_bridge, boolean()},
|
||||||
{is_supuser, boolean()},
|
{is_supuser, boolean()},
|
||||||
{mountpoint, maybe(utf8())},
|
{mountpoint, option(utf8())},
|
||||||
{ws_cookie, maybe(list())}
|
{ws_cookie, option(list())}
|
||||||
% password,
|
% password,
|
||||||
% auth_result,
|
% auth_result,
|
||||||
% anonymous,
|
% anonymous,
|
||||||
|
@ -496,7 +496,7 @@ pubsub() ->
|
||||||
%% Basic Types
|
%% Basic Types
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
maybe(T) ->
|
option(T) ->
|
||||||
oneof([undefined, T]).
|
oneof([undefined, T]).
|
||||||
|
|
||||||
socktype() ->
|
socktype() ->
|
||||||
|
@ -522,7 +522,7 @@ clientid() ->
|
||||||
utf8().
|
utf8().
|
||||||
|
|
||||||
username() ->
|
username() ->
|
||||||
maybe(utf8()).
|
option(utf8()).
|
||||||
|
|
||||||
properties() ->
|
properties() ->
|
||||||
map(limited_latin_atom(), binary()).
|
map(limited_latin_atom(), binary()).
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
%% -*- mode: erlang -*-
|
%% -*- mode: erlang -*-
|
||||||
{application, emqx_exhook, [
|
{application, emqx_exhook, [
|
||||||
{description, "EMQX Extension for Hook"},
|
{description, "EMQX Extension for Hook"},
|
||||||
{vsn, "5.0.15"},
|
{vsn, "5.0.16"},
|
||||||
{modules, []},
|
{modules, []},
|
||||||
{registered, []},
|
{registered, []},
|
||||||
{mod, {emqx_exhook_app, []}},
|
{mod, {emqx_exhook_app, []}},
|
||||||
|
|
|
@ -306,7 +306,7 @@ conninfo(
|
||||||
#{
|
#{
|
||||||
node => stringfy(node()),
|
node => stringfy(node()),
|
||||||
clientid => ClientId,
|
clientid => ClientId,
|
||||||
username => maybe(Username),
|
username => option(Username),
|
||||||
peerhost => ntoa(Peerhost),
|
peerhost => ntoa(Peerhost),
|
||||||
peerport => PeerPort,
|
peerport => PeerPort,
|
||||||
sockport => SockPort,
|
sockport => SockPort,
|
||||||
|
@ -330,17 +330,17 @@ clientinfo(
|
||||||
#{
|
#{
|
||||||
node => stringfy(node()),
|
node => stringfy(node()),
|
||||||
clientid => ClientId,
|
clientid => ClientId,
|
||||||
username => maybe(Username),
|
username => option(Username),
|
||||||
password => maybe(maps:get(password, ClientInfo, undefined)),
|
password => option(maps:get(password, ClientInfo, undefined)),
|
||||||
peerhost => ntoa(PeerHost),
|
peerhost => ntoa(PeerHost),
|
||||||
peerport => PeerPort,
|
peerport => PeerPort,
|
||||||
sockport => SockPort,
|
sockport => SockPort,
|
||||||
protocol => stringfy(Protocol),
|
protocol => stringfy(Protocol),
|
||||||
mountpoint => maybe(Mountpoiont),
|
mountpoint => option(Mountpoiont),
|
||||||
is_superuser => maps:get(is_superuser, ClientInfo, false),
|
is_superuser => maps:get(is_superuser, ClientInfo, false),
|
||||||
anonymous => maps:get(anonymous, ClientInfo, true),
|
anonymous => maps:get(anonymous, ClientInfo, true),
|
||||||
cn => maybe(maps:get(cn, ClientInfo, undefined)),
|
cn => option(maps:get(cn, ClientInfo, undefined)),
|
||||||
dn => maybe(maps:get(dn, ClientInfo, undefined))
|
dn => option(maps:get(dn, ClientInfo, undefined))
|
||||||
}.
|
}.
|
||||||
|
|
||||||
message(#message{
|
message(#message{
|
||||||
|
@ -435,8 +435,8 @@ ntoa({0, 0, 0, 0, 0, 16#ffff, AB, CD}) ->
|
||||||
ntoa(IP) ->
|
ntoa(IP) ->
|
||||||
list_to_binary(inet_parse:ntoa(IP)).
|
list_to_binary(inet_parse:ntoa(IP)).
|
||||||
|
|
||||||
maybe(undefined) -> <<>>;
|
option(undefined) -> <<>>;
|
||||||
maybe(B) -> B.
|
option(B) -> B.
|
||||||
|
|
||||||
%% @private
|
%% @private
|
||||||
stringfy(Term) when is_binary(Term) ->
|
stringfy(Term) when is_binary(Term) ->
|
||||||
|
|
|
@ -509,8 +509,8 @@ ntoa({0, 0, 0, 0, 0, 16#ffff, AB, CD}) ->
|
||||||
ntoa(IP) ->
|
ntoa(IP) ->
|
||||||
list_to_binary(inet_parse:ntoa(IP)).
|
list_to_binary(inet_parse:ntoa(IP)).
|
||||||
|
|
||||||
maybe(undefined) -> <<>>;
|
option(undefined) -> <<>>;
|
||||||
maybe(B) -> B.
|
option(B) -> B.
|
||||||
|
|
||||||
properties(undefined) ->
|
properties(undefined) ->
|
||||||
[];
|
[];
|
||||||
|
@ -568,7 +568,7 @@ from_conninfo(ConnInfo) ->
|
||||||
#{
|
#{
|
||||||
node => nodestr(),
|
node => nodestr(),
|
||||||
clientid => maps:get(clientid, ConnInfo),
|
clientid => maps:get(clientid, ConnInfo),
|
||||||
username => maybe(maps:get(username, ConnInfo, <<>>)),
|
username => option(maps:get(username, ConnInfo, <<>>)),
|
||||||
peerhost => peerhost(ConnInfo),
|
peerhost => peerhost(ConnInfo),
|
||||||
peerport => peerport(ConnInfo),
|
peerport => peerport(ConnInfo),
|
||||||
sockport => sockport(ConnInfo),
|
sockport => sockport(ConnInfo),
|
||||||
|
@ -581,17 +581,17 @@ from_clientinfo(ClientInfo) ->
|
||||||
#{
|
#{
|
||||||
node => nodestr(),
|
node => nodestr(),
|
||||||
clientid => maps:get(clientid, ClientInfo),
|
clientid => maps:get(clientid, ClientInfo),
|
||||||
username => maybe(maps:get(username, ClientInfo, <<>>)),
|
username => option(maps:get(username, ClientInfo, <<>>)),
|
||||||
password => maybe(maps:get(password, ClientInfo, <<>>)),
|
password => option(maps:get(password, ClientInfo, <<>>)),
|
||||||
peerhost => ntoa(maps:get(peerhost, ClientInfo)),
|
peerhost => ntoa(maps:get(peerhost, ClientInfo)),
|
||||||
peerport => maps:get(peerport, ClientInfo),
|
peerport => maps:get(peerport, ClientInfo),
|
||||||
sockport => maps:get(sockport, ClientInfo),
|
sockport => maps:get(sockport, ClientInfo),
|
||||||
protocol => stringfy(maps:get(protocol, ClientInfo)),
|
protocol => stringfy(maps:get(protocol, ClientInfo)),
|
||||||
mountpoint => maybe(maps:get(mountpoint, ClientInfo, <<>>)),
|
mountpoint => option(maps:get(mountpoint, ClientInfo, <<>>)),
|
||||||
is_superuser => maps:get(is_superuser, ClientInfo, false),
|
is_superuser => maps:get(is_superuser, ClientInfo, false),
|
||||||
anonymous => maps:get(anonymous, ClientInfo, true),
|
anonymous => maps:get(anonymous, ClientInfo, true),
|
||||||
cn => maybe(maps:get(cn, ClientInfo, <<>>)),
|
cn => option(maps:get(cn, ClientInfo, <<>>)),
|
||||||
dn => maybe(maps:get(dn, ClientInfo, <<>>))
|
dn => option(maps:get(dn, ClientInfo, <<>>))
|
||||||
}.
|
}.
|
||||||
|
|
||||||
from_message(Msg) ->
|
from_message(Msg) ->
|
||||||
|
|
|
@ -218,7 +218,7 @@ do_on_file_command(TopicReplyData, FileId, Msg, FileCommand) ->
|
||||||
[<<"fin">>, FinalSizeBin | MaybeChecksum] when length(MaybeChecksum) =< 1 ->
|
[<<"fin">>, FinalSizeBin | MaybeChecksum] when length(MaybeChecksum) =< 1 ->
|
||||||
ChecksumBin = emqx_maybe:from_list(MaybeChecksum),
|
ChecksumBin = emqx_maybe:from_list(MaybeChecksum),
|
||||||
validate(
|
validate(
|
||||||
[{size, FinalSizeBin}, {{maybe, checksum}, ChecksumBin}],
|
[{size, FinalSizeBin}, {{option, checksum}, ChecksumBin}],
|
||||||
fun([FinalSize, FinalChecksum]) ->
|
fun([FinalSize, FinalChecksum]) ->
|
||||||
on_fin(TopicReplyData, Msg, Transfer, FinalSize, FinalChecksum)
|
on_fin(TopicReplyData, Msg, Transfer, FinalSize, FinalChecksum)
|
||||||
end
|
end
|
||||||
|
@ -464,9 +464,9 @@ do_validate([{integrity, Payload, {Algo, Checksum}} | Rest], Parsed) ->
|
||||||
Mismatch ->
|
Mismatch ->
|
||||||
{error, {checksum_mismatch, binary:encode_hex(Mismatch)}}
|
{error, {checksum_mismatch, binary:encode_hex(Mismatch)}}
|
||||||
end;
|
end;
|
||||||
do_validate([{{maybe, _}, undefined} | Rest], Parsed) ->
|
do_validate([{{option, _}, undefined} | Rest], Parsed) ->
|
||||||
do_validate(Rest, [undefined | Parsed]);
|
do_validate(Rest, [undefined | Parsed]);
|
||||||
do_validate([{{maybe, T}, Value} | Rest], Parsed) ->
|
do_validate([{{option, T}, Value} | Rest], Parsed) ->
|
||||||
do_validate([{T, Value} | Rest], Parsed).
|
do_validate([{T, Value} | Rest], Parsed).
|
||||||
|
|
||||||
parse_checksum(Checksum) when is_binary(Checksum) andalso byte_size(Checksum) =:= 64 ->
|
parse_checksum(Checksum) when is_binary(Checksum) andalso byte_size(Checksum) =:= 64 ->
|
||||||
|
|
|
@ -100,7 +100,7 @@
|
||||||
-callback start(storage()) -> any().
|
-callback start(storage()) -> any().
|
||||||
-callback stop(storage()) -> any().
|
-callback stop(storage()) -> any().
|
||||||
|
|
||||||
-callback update_config(_OldConfig :: maybe(storage()), _NewConfig :: maybe(storage())) ->
|
-callback update_config(_OldConfig :: option(storage()), _NewConfig :: option(storage())) ->
|
||||||
any().
|
any().
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
|
@ -41,8 +41,8 @@
|
||||||
-export([handle_info/2]).
|
-export([handle_info/2]).
|
||||||
|
|
||||||
-record(st, {
|
-record(st, {
|
||||||
next_gc_timer :: maybe(reference()),
|
next_gc_timer :: option(reference()),
|
||||||
last_gc :: maybe(gcstats())
|
last_gc :: option(gcstats())
|
||||||
}).
|
}).
|
||||||
|
|
||||||
-type gcstats() :: #gcstats{}.
|
-type gcstats() :: #gcstats{}.
|
||||||
|
|
|
@ -67,9 +67,9 @@
|
||||||
%% The {active, N} option
|
%% The {active, N} option
|
||||||
active_n :: pos_integer(),
|
active_n :: pos_integer(),
|
||||||
%% Limiter
|
%% Limiter
|
||||||
limiter :: maybe(emqx_htb_limiter:limiter()),
|
limiter :: option(emqx_htb_limiter:limiter()),
|
||||||
%% Limit Timer
|
%% Limit Timer
|
||||||
limit_timer :: maybe(reference()),
|
limit_timer :: option(reference()),
|
||||||
%% Parse State
|
%% Parse State
|
||||||
parse_state :: emqx_gateway_frame:parse_state(),
|
parse_state :: emqx_gateway_frame:parse_state(),
|
||||||
%% Serialize options
|
%% Serialize options
|
||||||
|
@ -77,15 +77,15 @@
|
||||||
%% Channel State
|
%% Channel State
|
||||||
channel :: emqx_gateway_channel:channel(),
|
channel :: emqx_gateway_channel:channel(),
|
||||||
%% GC State
|
%% GC State
|
||||||
gc_state :: maybe(emqx_gc:gc_state()),
|
gc_state :: option(emqx_gc:gc_state()),
|
||||||
%% Stats Timer
|
%% Stats Timer
|
||||||
stats_timer :: disabled | maybe(reference()),
|
stats_timer :: disabled | option(reference()),
|
||||||
%% Idle Timeout
|
%% Idle Timeout
|
||||||
idle_timeout :: integer(),
|
idle_timeout :: integer(),
|
||||||
%% Idle Timer
|
%% Idle Timer
|
||||||
idle_timer :: maybe(reference()),
|
idle_timer :: option(reference()),
|
||||||
%% OOM Policy
|
%% OOM Policy
|
||||||
oom_policy :: maybe(emqx_types:oom_policy()),
|
oom_policy :: option(emqx_types:oom_policy()),
|
||||||
%% Frame Module
|
%% Frame Module
|
||||||
frame_mod :: atom(),
|
frame_mod :: atom(),
|
||||||
%% Channel Module
|
%% Channel Module
|
||||||
|
|
|
@ -50,15 +50,15 @@
|
||||||
%% Conn info
|
%% Conn info
|
||||||
conninfo :: emqx_types:conninfo(),
|
conninfo :: emqx_types:conninfo(),
|
||||||
%% Client info from `register` function
|
%% Client info from `register` function
|
||||||
clientinfo :: maybe(map()),
|
clientinfo :: option(map()),
|
||||||
%% Connection state
|
%% Connection state
|
||||||
conn_state :: conn_state(),
|
conn_state :: conn_state(),
|
||||||
%% Subscription
|
%% Subscription
|
||||||
subscriptions = #{},
|
subscriptions = #{},
|
||||||
%% Keepalive
|
%% Keepalive
|
||||||
keepalive :: maybe(emqx_keepalive:keepalive()),
|
keepalive :: option(emqx_keepalive:keepalive()),
|
||||||
%% Timers
|
%% Timers
|
||||||
timers :: #{atom() => disabled | maybe(reference())},
|
timers :: #{atom() => disabled | option(reference())},
|
||||||
%% Closed reason
|
%% Closed reason
|
||||||
closed_reason = undefined
|
closed_reason = undefined
|
||||||
}).
|
}).
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
%% -*- mode: erlang -*-
|
%% -*- mode: erlang -*-
|
||||||
{application, emqx_gateway_gbt32960, [
|
{application, emqx_gateway_gbt32960, [
|
||||||
{description, "GBT32960 Gateway"},
|
{description, "GBT32960 Gateway"},
|
||||||
{vsn, "0.1.0"},
|
{vsn, "0.1.1"},
|
||||||
{registered, []},
|
{registered, []},
|
||||||
{applications, [kernel, stdlib, emqx, emqx_gateway]},
|
{applications, [kernel, stdlib, emqx, emqx_gateway]},
|
||||||
{env, []},
|
{env, []},
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
%% Session
|
%% Session
|
||||||
session :: undefined | map(),
|
session :: undefined | map(),
|
||||||
%% Keepalive
|
%% Keepalive
|
||||||
keepalive :: maybe(emqx_keepalive:keepalive()),
|
keepalive :: option(emqx_keepalive:keepalive()),
|
||||||
%% Conn State
|
%% Conn State
|
||||||
conn_state :: conn_state(),
|
conn_state :: conn_state(),
|
||||||
%% Timers
|
%% Timers
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
%% -*- mode: erlang -*-
|
%% -*- mode: erlang -*-
|
||||||
{application, emqx_gateway_jt808, [
|
{application, emqx_gateway_jt808, [
|
||||||
{description, "JT/T 808 Gateway"},
|
{description, "JT/T 808 Gateway"},
|
||||||
{vsn, "0.0.1"},
|
{vsn, "0.0.2"},
|
||||||
{registered, []},
|
{registered, []},
|
||||||
{applications, [kernel, stdlib, emqx, emqx_gateway]},
|
{applications, [kernel, stdlib, emqx, emqx_gateway]},
|
||||||
{env, []},
|
{env, []},
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
%% AuthCode
|
%% AuthCode
|
||||||
authcode :: undefined | anonymous | binary(),
|
authcode :: undefined | anonymous | binary(),
|
||||||
%% Keepalive
|
%% Keepalive
|
||||||
keepalive :: maybe(emqx_keepalive:keepalive()),
|
keepalive :: option(emqx_keepalive:keepalive()),
|
||||||
%% Msg SN
|
%% Msg SN
|
||||||
msg_sn,
|
msg_sn,
|
||||||
%% Down Topic
|
%% Down Topic
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
%% -*- mode: erlang -*-
|
%% -*- mode: erlang -*-
|
||||||
{application, emqx_gateway_mqttsn, [
|
{application, emqx_gateway_mqttsn, [
|
||||||
{description, "MQTT-SN Gateway"},
|
{description, "MQTT-SN Gateway"},
|
||||||
{vsn, "0.1.7"},
|
{vsn, "0.1.8"},
|
||||||
{registered, []},
|
{registered, []},
|
||||||
{applications, [kernel, stdlib, emqx, emqx_gateway]},
|
{applications, [kernel, stdlib, emqx, emqx_gateway]},
|
||||||
{env, []},
|
{env, []},
|
||||||
|
|
|
@ -71,7 +71,7 @@
|
||||||
%% Connection State
|
%% Connection State
|
||||||
conn_state :: conn_state(),
|
conn_state :: conn_state(),
|
||||||
%% Inflight register message queue
|
%% Inflight register message queue
|
||||||
register_inflight :: maybe(term()),
|
register_inflight :: option(term()),
|
||||||
%% Topics list for awaiting to register to client
|
%% Topics list for awaiting to register to client
|
||||||
register_awaiting_queue :: list(),
|
register_awaiting_queue :: list(),
|
||||||
%% Duration for asleep
|
%% Duration for asleep
|
||||||
|
|
|
@ -63,15 +63,15 @@
|
||||||
%% ClientInfo
|
%% ClientInfo
|
||||||
clientinfo :: emqx_types:clientinfo(),
|
clientinfo :: emqx_types:clientinfo(),
|
||||||
%% Session
|
%% Session
|
||||||
session :: maybe(map()),
|
session :: option(map()),
|
||||||
%% ClientInfo override specs
|
%% ClientInfo override specs
|
||||||
clientinfo_override :: map(),
|
clientinfo_override :: map(),
|
||||||
%% Keepalive
|
%% Keepalive
|
||||||
keepalive :: maybe(emqx_ocpp_keepalive:keepalive()),
|
keepalive :: option(emqx_ocpp_keepalive:keepalive()),
|
||||||
%% Stores all unsent messages.
|
%% Stores all unsent messages.
|
||||||
mqueue :: queue:queue(),
|
mqueue :: queue:queue(),
|
||||||
%% Timers
|
%% Timers
|
||||||
timers :: #{atom() => disabled | maybe(reference())},
|
timers :: #{atom() => disabled | option(reference())},
|
||||||
%% Conn State
|
%% Conn State
|
||||||
conn_state :: conn_state()
|
conn_state :: conn_state()
|
||||||
}).
|
}).
|
||||||
|
|
|
@ -72,9 +72,9 @@
|
||||||
%% Piggyback
|
%% Piggyback
|
||||||
piggyback :: single | multiple,
|
piggyback :: single | multiple,
|
||||||
%% Limiter
|
%% Limiter
|
||||||
limiter :: maybe(emqx_htb_limiter:limiter()),
|
limiter :: option(emqx_htb_limiter:limiter()),
|
||||||
%% Limit Timer
|
%% Limit Timer
|
||||||
limit_timer :: maybe(reference()),
|
limit_timer :: option(reference()),
|
||||||
%% Parse State
|
%% Parse State
|
||||||
parse_state :: emqx_ocpp_frame:parse_state(),
|
parse_state :: emqx_ocpp_frame:parse_state(),
|
||||||
%% Serialize options
|
%% Serialize options
|
||||||
|
@ -82,17 +82,17 @@
|
||||||
%% Channel
|
%% Channel
|
||||||
channel :: emqx_ocpp_channel:channel(),
|
channel :: emqx_ocpp_channel:channel(),
|
||||||
%% GC State
|
%% GC State
|
||||||
gc_state :: maybe(emqx_gc:gc_state()),
|
gc_state :: option(emqx_gc:gc_state()),
|
||||||
%% Postponed Packets|Cmds|Events
|
%% Postponed Packets|Cmds|Events
|
||||||
postponed :: list(emqx_types:packet() | ws_cmd() | tuple()),
|
postponed :: list(emqx_types:packet() | ws_cmd() | tuple()),
|
||||||
%% Stats Timer
|
%% Stats Timer
|
||||||
stats_timer :: disabled | maybe(reference()),
|
stats_timer :: disabled | option(reference()),
|
||||||
%% Idle Timeout
|
%% Idle Timeout
|
||||||
idle_timeout :: timeout(),
|
idle_timeout :: timeout(),
|
||||||
%%% Idle Timer
|
%%% Idle Timer
|
||||||
idle_timer :: maybe(reference()),
|
idle_timer :: option(reference()),
|
||||||
%% OOM Policy
|
%% OOM Policy
|
||||||
oom_policy :: maybe(emqx_types:oom_policy()),
|
oom_policy :: option(emqx_types:oom_policy()),
|
||||||
%% Frame Module
|
%% Frame Module
|
||||||
frame_mod :: atom(),
|
frame_mod :: atom(),
|
||||||
%% Channel Module
|
%% Channel Module
|
||||||
|
|
|
@ -92,10 +92,10 @@
|
||||||
-export_type([with_id_return/0, with_id_return/1]).
|
-export_type([with_id_return/0, with_id_return/1]).
|
||||||
|
|
||||||
-type state() :: #{
|
-type state() :: #{
|
||||||
publish_timer := maybe(reference()),
|
publish_timer := option(reference()),
|
||||||
publish_at := non_neg_integer(),
|
publish_at := non_neg_integer(),
|
||||||
stats_timer := maybe(reference()),
|
stats_timer := option(reference()),
|
||||||
stats_fun := maybe(fun((pos_integer()) -> ok))
|
stats_fun := option(fun((pos_integer()) -> ok))
|
||||||
}.
|
}.
|
||||||
|
|
||||||
%% sync ms with record change
|
%% sync ms with record change
|
||||||
|
|
|
@ -825,7 +825,7 @@ handle_remove_channel_exists(From, ChannelId, Data) ->
|
||||||
handle_not_connected_and_not_connecting_remove_channel(From, ChannelId, Data) ->
|
handle_not_connected_and_not_connecting_remove_channel(From, ChannelId, Data) ->
|
||||||
%% When state is not connected and not connecting the channel will be removed
|
%% When state is not connected and not connecting the channel will be removed
|
||||||
%% from the channels map but nothing else will happen since the channel
|
%% from the channels map but nothing else will happen since the channel
|
||||||
%% is not addded/installed in the resource state.
|
%% is not added/installed in the resource state.
|
||||||
Channels = Data#data.added_channels,
|
Channels = Data#data.added_channels,
|
||||||
NewChannels = maps:remove(ChannelId, Channels),
|
NewChannels = maps:remove(ChannelId, Channels),
|
||||||
NewData = Data#data{added_channels = NewChannels},
|
NewData = Data#data{added_channels = NewChannels},
|
||||||
|
@ -915,7 +915,7 @@ with_health_check(#data{error = PrevError} = Data, Func) ->
|
||||||
-spec channels_health_check(resource_status(), data()) -> data().
|
-spec channels_health_check(resource_status(), data()) -> data().
|
||||||
channels_health_check(?status_connected = _ConnectorStatus, Data0) ->
|
channels_health_check(?status_connected = _ConnectorStatus, Data0) ->
|
||||||
Channels = maps:to_list(Data0#data.added_channels),
|
Channels = maps:to_list(Data0#data.added_channels),
|
||||||
%% All channels with a stutus different from connected or connecting are
|
%% All channels with a status different from connected or connecting are
|
||||||
%% not added
|
%% not added
|
||||||
ChannelsNotAdded = [
|
ChannelsNotAdded = [
|
||||||
ChannelId
|
ChannelId
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
-define(KV_TAB, '@rule_engine_db').
|
-define(KV_TAB, '@rule_engine_db').
|
||||||
|
|
||||||
-type maybe(T) :: T | undefined.
|
-type option(T) :: T | undefined.
|
||||||
|
|
||||||
-type rule_id() :: binary().
|
-type rule_id() :: binary().
|
||||||
-type rule_name() :: binary().
|
-type rule_name() :: binary().
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{application, emqx_s3, [
|
{application, emqx_s3, [
|
||||||
{description, "EMQX S3"},
|
{description, "EMQX S3"},
|
||||||
{vsn, "5.0.13"},
|
{vsn, "5.0.14"},
|
||||||
{modules, []},
|
{modules, []},
|
||||||
{registered, [emqx_s3_sup]},
|
{registered, [emqx_s3_sup]},
|
||||||
{applications, [
|
{applications, [
|
||||||
|
|
|
@ -103,9 +103,9 @@ with_client(ProfileId, Fun) when is_function(Fun, 1) andalso ?IS_PROFILE_ID(Prof
|
||||||
%%
|
%%
|
||||||
|
|
||||||
-spec pre_config_update(
|
-spec pre_config_update(
|
||||||
profile_id(), maybe(emqx_config:raw_config()), maybe(emqx_config:raw_config())
|
profile_id(), option(emqx_config:raw_config()), option(emqx_config:raw_config())
|
||||||
) ->
|
) ->
|
||||||
{ok, maybe(profile_config())} | {error, term()}.
|
{ok, option(profile_config())} | {error, term()}.
|
||||||
pre_config_update(ProfileId, NewConfig = #{<<"transport_options">> := TransportOpts}, _OldConfig) ->
|
pre_config_update(ProfileId, NewConfig = #{<<"transport_options">> := TransportOpts}, _OldConfig) ->
|
||||||
case emqx_connector_ssl:convert_certs(mk_certs_dir(ProfileId), TransportOpts) of
|
case emqx_connector_ssl:convert_certs(mk_certs_dir(ProfileId), TransportOpts) of
|
||||||
{ok, TransportOptsConv} ->
|
{ok, TransportOptsConv} ->
|
||||||
|
@ -118,8 +118,8 @@ pre_config_update(_ProfileId, NewConfig, _OldConfig) ->
|
||||||
|
|
||||||
-spec post_config_update(
|
-spec post_config_update(
|
||||||
profile_id(),
|
profile_id(),
|
||||||
maybe(emqx_config:config()),
|
option(emqx_config:config()),
|
||||||
maybe(emqx_config:config())
|
option(emqx_config:config())
|
||||||
) ->
|
) ->
|
||||||
ok.
|
ok.
|
||||||
post_config_update(_ProfileId, _NewConfig, _OldConfig) ->
|
post_config_update(_ProfileId, _NewConfig, _OldConfig) ->
|
||||||
|
|
|
@ -89,7 +89,7 @@
|
||||||
|
|
||||||
-type readable_error_msg(_Error) :: binary().
|
-type readable_error_msg(_Error) :: binary().
|
||||||
|
|
||||||
-type maybe(T) :: undefined | T.
|
-type option(T) :: undefined | T.
|
||||||
|
|
||||||
-dialyzer({nowarn_function, [nolink_apply/2]}).
|
-dialyzer({nowarn_function, [nolink_apply/2]}).
|
||||||
|
|
||||||
|
@ -128,8 +128,8 @@ merge_opts(Defaults, Options) ->
|
||||||
).
|
).
|
||||||
|
|
||||||
%% @doc Apply a function to a maybe argument.
|
%% @doc Apply a function to a maybe argument.
|
||||||
-spec maybe_apply(fun((maybe(A)) -> maybe(A)), maybe(A)) ->
|
-spec maybe_apply(fun((option(A)) -> option(A)), option(A)) ->
|
||||||
maybe(A)
|
option(A)
|
||||||
when
|
when
|
||||||
A :: any().
|
A :: any().
|
||||||
maybe_apply(_Fun, undefined) ->
|
maybe_apply(_Fun, undefined) ->
|
||||||
|
@ -184,17 +184,17 @@ apply_fun(Fun, Input, State) ->
|
||||||
{arity, 2} -> Fun(Input, State)
|
{arity, 2} -> Fun(Input, State)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec start_timer(integer() | atom(), term()) -> maybe(reference()).
|
-spec start_timer(integer() | atom(), term()) -> option(reference()).
|
||||||
start_timer(Interval, Msg) ->
|
start_timer(Interval, Msg) ->
|
||||||
start_timer(Interval, self(), Msg).
|
start_timer(Interval, self(), Msg).
|
||||||
|
|
||||||
-spec start_timer(integer() | atom(), pid() | atom(), term()) -> maybe(reference()).
|
-spec start_timer(integer() | atom(), pid() | atom(), term()) -> option(reference()).
|
||||||
start_timer(Interval, Dest, Msg) when is_number(Interval) ->
|
start_timer(Interval, Dest, Msg) when is_number(Interval) ->
|
||||||
erlang:start_timer(erlang:ceil(Interval), Dest, Msg);
|
erlang:start_timer(erlang:ceil(Interval), Dest, Msg);
|
||||||
start_timer(_Atom, _Dest, _Msg) ->
|
start_timer(_Atom, _Dest, _Msg) ->
|
||||||
undefined.
|
undefined.
|
||||||
|
|
||||||
-spec cancel_timer(maybe(reference())) -> ok.
|
-spec cancel_timer(option(reference())) -> ok.
|
||||||
cancel_timer(Timer) when is_reference(Timer) ->
|
cancel_timer(Timer) when is_reference(Timer) ->
|
||||||
case erlang:cancel_timer(Timer) of
|
case erlang:cancel_timer(Timer) of
|
||||||
false ->
|
false ->
|
||||||
|
|
|
@ -66,8 +66,8 @@ t_traverse_dir(Config) ->
|
||||||
{"nonempty/d2/deep/down/here", #file_info{type = regular, mode = ORW}},
|
{"nonempty/d2/deep/down/here", #file_info{type = regular, mode = ORW}},
|
||||||
{"nonempty/d2/deep/mutrec", #file_info{type = symlink, mode = ARWX}}
|
{"nonempty/d2/deep/mutrec", #file_info{type = symlink, mode = ARWX}}
|
||||||
] when
|
] when
|
||||||
((ORW band 8#00600 =:= 8#00600) and
|
(((ORW band 8#00600 =:= 8#00600) and
|
||||||
(ARWX band 8#00777 =:= 8#00777)),
|
(ARWX band 8#00777 =:= 8#00777))),
|
||||||
|
|
||||||
[{string:prefix(Filename, Dir), Info} || {Filename, Info} <- Traversal]
|
[{string:prefix(Filename, Dir), Info} || {Filename, Info} <- Traversal]
|
||||||
).
|
).
|
||||||
|
|
|
@ -132,7 +132,7 @@
|
||||||
{eunit_opts, [verbose]}.
|
{eunit_opts, [verbose]}.
|
||||||
|
|
||||||
{project_plugins, [
|
{project_plugins, [
|
||||||
erlfmt,
|
{erlfmt, "1.3.0"},
|
||||||
{rebar3_hex, "7.0.2"},
|
{rebar3_hex, "7.0.2"},
|
||||||
{rebar3_sbom, {git, "https://github.com/emqx/rebar3_sbom.git", {tag, "v0.6.1-1"}}}
|
{rebar3_sbom, {git, "https://github.com/emqx/rebar3_sbom.git", {tag, "v0.6.1-1"}}}
|
||||||
]}.
|
]}.
|
||||||
|
|
BIN
scripts/erlfmt
BIN
scripts/erlfmt
Binary file not shown.
Loading…
Reference in New Issue