feat: upgrade erlfmt to support maybe syntax

This commit is contained in:
zhongwencool 2024-01-30 17:33:36 +08:00
parent 5bc67cb288
commit e9c8446d57
47 changed files with 131 additions and 131 deletions

View File

@ -14,7 +14,7 @@
%% limitations under the License.
%%--------------------------------------------------------------------
-type maybe(T) :: undefined | T.
-type option(T) :: undefined | T.
-type startlink_ret() :: {ok, pid()} | ignore | {error, term()}.

View File

@ -71,7 +71,7 @@
{statistics, true}
]}.
{project_plugins, [erlfmt]}.
{project_plugins, [{erlfmt, "1.3.0"}]}.
{erlfmt, [
{files, [

View File

@ -440,7 +440,7 @@ subscribed(SubId, Topic) when ?IS_SUBID(SubId) ->
SubPid = emqx_broker_helper:lookup_subpid(SubId),
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) ->
lookup_value(?SUBOPTION, {Topic, SubPid});
get_subopts(SubId, Topic) when ?IS_SUBID(SubId) ->

View File

@ -71,11 +71,11 @@ register_sub(SubPid, SubId) when is_pid(SubPid) ->
error(subid_conflict)
end.
-spec lookup_subid(pid()) -> maybe(emqx_types:subid()).
-spec lookup_subid(pid()) -> option(emqx_types:subid()).
lookup_subid(SubPid) when is_pid(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) ->
emqx_utils_ets:lookup_value(?SUBID, SubId).

View File

@ -84,21 +84,21 @@
%% MQTT ClientInfo
clientinfo :: emqx_types:clientinfo(),
%% MQTT Session
session :: maybe(emqx_session:t()),
session :: option(emqx_session:t()),
%% Keepalive
keepalive :: maybe(emqx_keepalive:keepalive()),
keepalive :: option(emqx_keepalive:keepalive()),
%% MQTT Will Msg
will_msg :: maybe(emqx_types:message()),
will_msg :: option(emqx_types:message()),
%% MQTT Topic Aliases
topic_aliases :: emqx_types:topic_aliases(),
%% MQTT Topic Alias Maximum
alias_maximum :: maybe(map()),
alias_maximum :: option(map()),
%% Authentication Data Cache
auth_cache :: maybe(map()),
auth_cache :: option(map()),
%% Quota checkers
quota :: emqx_limiter_container:container(),
%% Timers
timers :: #{atom() => disabled | maybe(reference())},
timers :: #{atom() => disabled | option(reference())},
%% Conn State
conn_state :: conn_state(),
%% Takeover

View File

@ -200,12 +200,12 @@ do_unregister_channel({_ClientId, ChanPid} = Chan) ->
true.
%% @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) ->
with_channel(ClientId, fun(ChanPid) -> get_chan_info(ClientId, ChanPid) end).
-spec do_get_chan_info(emqx_types:clientid(), chan_pid()) ->
maybe(emqx_types:infos()).
option(emqx_types:infos()).
do_get_chan_info(ClientId, ChanPid) ->
Chan = {ClientId, ChanPid},
try
@ -215,7 +215,7 @@ do_get_chan_info(ClientId, ChanPid) ->
end.
-spec get_chan_info(emqx_types:clientid(), chan_pid()) ->
maybe(emqx_types:infos()).
option(emqx_types:infos()).
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.
%% @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) ->
with_channel(ClientId, fun(ChanPid) -> get_chan_stats(ClientId, ChanPid) end).
-spec do_get_chan_stats(emqx_types:clientid(), chan_pid()) ->
maybe(emqx_types:stats()).
option(emqx_types:stats()).
do_get_chan_stats(ClientId, ChanPid) ->
Chan = {ClientId, ChanPid},
try
@ -245,7 +245,7 @@ do_get_chan_stats(ClientId, ChanPid) ->
end.
-spec get_chan_stats(emqx_types:clientid(), chan_pid()) ->
maybe(emqx_types:stats()).
option(emqx_types:stats()).
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.
-spec pick_channel(emqx_types:clientid()) ->
maybe(pid()).
option(pid()).
pick_channel(ClientId) ->
case lookup_channels(ClientId) of
[] ->

View File

@ -32,7 +32,7 @@ start_link() ->
ekka_locker:start_link(?MODULE).
-spec trans(
maybe(emqx_types:clientid()),
option(emqx_types:clientid()),
fun(([node()]) -> any())
) -> any().
trans(undefined, Fun) ->

View File

@ -99,13 +99,13 @@
%% Channel State
channel :: emqx_channel:channel(),
%% GC State
gc_state :: maybe(emqx_gc:gc_state()),
gc_state :: option(emqx_gc:gc_state()),
%% Stats Timer
stats_timer :: disabled | maybe(reference()),
stats_timer :: disabled | option(reference()),
%% Idle Timeout
idle_timeout :: integer() | infinity,
%% Idle Timer
idle_timer :: maybe(reference()),
idle_timer :: option(reference()),
%% Zone name
zone :: atom(),
%% Listener Type and Name
@ -121,7 +121,7 @@
limiter_timer :: undefined | reference(),
%% QUIC conn owner pid if in use.
quic_conn_pid :: maybe(pid())
quic_conn_pid :: option(pid())
}).
-record(retry, {

View File

@ -86,11 +86,11 @@ do_run([{K, N} | T], St) ->
end.
%% @doc Info of GC state.
-spec info(maybe(gc_state())) -> maybe(map()).
-spec info(option(gc_state())) -> option(map()).
info(?GCS(St)) -> St.
%% @doc Reset counters to zero.
-spec reset(maybe(gc_state())) -> gc_state().
-spec reset(option(gc_state())) -> gc_state().
reset(?GCS(St)) ->
?GCS(do_reset(St)).

View File

@ -76,7 +76,7 @@
-record(callback, {
action :: action(),
filter :: maybe(filter()),
filter :: option(filter()),
priority :: integer()
}).

View File

@ -23,30 +23,30 @@
-export([define/2]).
-export([apply/2]).
-type t(T) :: maybe(T).
-type t(T) :: option(T).
-export_type([t/1]).
-spec to_list(maybe(A)) -> [A].
-spec to_list(option(A)) -> [A].
to_list(undefined) ->
[];
to_list(Term) ->
[Term].
-spec from_list([A]) -> maybe(A).
-spec from_list([A]) -> option(A).
from_list([]) ->
undefined;
from_list([Term]) ->
Term.
-spec define(maybe(A), B) -> A | B.
-spec define(option(A), B) -> A | B.
define(undefined, Term) ->
Term;
define(Term, _) ->
Term.
%% @doc Apply a function to a maybe argument.
-spec apply(fun((A) -> B), maybe(A)) ->
maybe(B).
-spec apply(fun((A) -> B), option(A)) ->
option(B).
apply(_Fun, undefined) ->
undefined;
apply(Fun, Term) when is_function(Fun) ->

View File

@ -186,7 +186,7 @@ estimate_size(#message{topic = Topic, payload = Payload}) ->
TopicLengthSize = 2,
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.
-spec qos(emqx_types:message()) -> emqx_types:qos().
@ -229,7 +229,7 @@ get_flag(Flag, Msg) ->
get_flag(Flag, #message{flags = 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.
-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) ->
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.
-spec get_header(term(), emqx_types:message()) -> term().

View File

@ -32,7 +32,7 @@
-type mountpoint() :: binary().
-spec mount(maybe(mountpoint()), Any) -> Any when
-spec mount(option(mountpoint()), Any) -> Any when
Any ::
emqx_types:topic()
| emqx_types:share()
@ -47,7 +47,7 @@ mount(MountPoint, Msg = #message{topic = Topic}) when is_binary(Topic) ->
mount(MountPoint, TopicFilters) when is_list(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 ::
emqx_types:topic()
| 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)}.
-spec unmount(maybe(mountpoint()), Any) -> Any when
-spec unmount(option(mountpoint()), Any) -> Any when
Any ::
emqx_types:topic()
| emqx_types:share()
@ -84,7 +84,7 @@ unmount_maybe_share(MountPoint, TopicFilter = #share{topic = Topic}) when
->
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) ->
undefined;
replvar(MountPoint, Vars) ->

View File

@ -189,7 +189,7 @@ stats(#mqueue{max_len = MaxLen, dropped = Dropped} = MQ) ->
[{len, len(MQ)}, {max_len, MaxLen}, {dropped, Dropped}].
%% @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}) ->
{_Dropped = Msg, MQ};
in(

View File

@ -48,7 +48,7 @@ get_counter(Key) ->
Cnt -> Cnt
end.
-spec inc_counter(key(), number()) -> maybe(number()).
-spec inc_counter(key(), number()) -> option(number()).
inc_counter(Key, Inc) ->
put(Key, get_counter(Key) + Inc).

View File

@ -135,7 +135,7 @@
-type custom_timer_name() :: atom().
-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 reply() :: publish() | pubrel().
-type replies() :: [reply()] | reply().

View File

@ -62,7 +62,7 @@
-record(update, {name, countdown, interval, func}).
-record(state, {
timer :: maybe(reference()),
timer :: option(reference()),
updates :: [#update{}],
tick_ms :: timeout()
}).

View File

@ -65,8 +65,8 @@
-import(emqx_utils, [start_timer/2]).
-record(state, {
heartbeat :: maybe(reference()),
ticker :: maybe(reference()),
heartbeat :: option(reference()),
ticker :: option(reference()),
sysdescr :: binary()
}).

View File

@ -173,7 +173,7 @@
atom() => term()
}.
-type clientinfo() :: #{
zone := maybe(zone()),
zone := option(zone()),
protocol := protocol(),
peerhost := peerhost(),
sockport := non_neg_integer(),
@ -181,9 +181,9 @@
username := username(),
is_bridge := boolean(),
is_superuser := boolean(),
mountpoint := maybe(binary()),
ws_cookie => maybe(list()),
password => maybe(binary()),
mountpoint := option(binary()),
ws_cookie => option(list()),
password => option(binary()),
auth_result => auth_result(),
anonymous => boolean(),
cn => binary(),
@ -191,8 +191,8 @@
atom() => term()
}.
-type clientid() :: binary() | atom().
-type username() :: maybe(binary()).
-type password() :: maybe(binary()).
-type username() :: option(binary()).
-type password() :: option(binary()).
-type peerhost() :: inet:ip_address().
-type peername() ::
{inet:ip_address(), inet:port_number()}
@ -222,8 +222,8 @@
-type packet_id() :: 1..16#FFFF.
-type alias_id() :: 0..16#FFFF.
-type topic_aliases() :: #{
inbound => maybe(map()),
outbound => maybe(map())
inbound => option(map()),
outbound => option(map())
}.
-type properties() :: #{atom() => term()}.
-type topic_filters() :: list({topic(), subopts()}).

View File

@ -76,15 +76,15 @@
%% Channel
channel :: emqx_channel:channel(),
%% GC State
gc_state :: maybe(emqx_gc:gc_state()),
gc_state :: option(emqx_gc:gc_state()),
%% Postponed Packets|Cmds|Events
postponed :: list(emqx_types:packet() | ws_cmd() | tuple()),
%% Stats Timer
stats_timer :: disabled | maybe(reference()),
stats_timer :: disabled | option(reference()),
%% Idle Timeout
idle_timeout :: timeout(),
%% Idle Timer
idle_timer :: maybe(reference()),
idle_timer :: option(reference()),
%% Zone name
zone :: atom(),
%% Listener Type and Name

View File

@ -405,9 +405,9 @@ t_quic_update_opts(Config) ->
%% Unable to connect with old SSL options, server's cert is signed by another CA.
?assertError(
{transport_down, #{error := _, status := Status}} when
(Status =:= bad_certificate orelse
((Status =:= bad_certificate orelse
Status =:= cert_untrusted_root orelse
Status =:= handshake_failure),
Status =:= handshake_failure)),
ConnectFun(Host, Port, [
{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.
?assertError(
{transport_down, #{error := _, status := Status}} when
(Status =:= bad_certificate orelse
((Status =:= bad_certificate orelse
Status =:= cert_untrusted_root orelse
Status =:= handshake_failure),
Status =:= handshake_failure)),
ConnectFun(Host, Port, [
{cacertfile, filename:join(PrivDir, "ca.pem")} | ClientSSLOpts
])

View File

@ -114,8 +114,8 @@ clientinfo() ->
{username, username()},
{is_bridge, boolean()},
{is_supuser, boolean()},
{mountpoint, maybe(utf8())},
{ws_cookie, maybe(list())}
{mountpoint, option(utf8())},
{ws_cookie, option(list())}
% password,
% auth_result,
% anonymous,
@ -496,7 +496,7 @@ pubsub() ->
%% Basic Types
%%--------------------------------------------------------------------
maybe(T) ->
option(T) ->
oneof([undefined, T]).
socktype() ->
@ -522,7 +522,7 @@ clientid() ->
utf8().
username() ->
maybe(utf8()).
option(utf8()).
properties() ->
map(limited_latin_atom(), binary()).

View File

@ -1,7 +1,7 @@
%% -*- mode: erlang -*-
{application, emqx_exhook, [
{description, "EMQX Extension for Hook"},
{vsn, "5.0.15"},
{vsn, "5.0.16"},
{modules, []},
{registered, []},
{mod, {emqx_exhook_app, []}},

View File

@ -306,7 +306,7 @@ conninfo(
#{
node => stringfy(node()),
clientid => ClientId,
username => maybe(Username),
username => option(Username),
peerhost => ntoa(Peerhost),
peerport => PeerPort,
sockport => SockPort,
@ -330,17 +330,17 @@ clientinfo(
#{
node => stringfy(node()),
clientid => ClientId,
username => maybe(Username),
password => maybe(maps:get(password, ClientInfo, undefined)),
username => option(Username),
password => option(maps:get(password, ClientInfo, undefined)),
peerhost => ntoa(PeerHost),
peerport => PeerPort,
sockport => SockPort,
protocol => stringfy(Protocol),
mountpoint => maybe(Mountpoiont),
mountpoint => option(Mountpoiont),
is_superuser => maps:get(is_superuser, ClientInfo, false),
anonymous => maps:get(anonymous, ClientInfo, true),
cn => maybe(maps:get(cn, ClientInfo, undefined)),
dn => maybe(maps:get(dn, ClientInfo, undefined))
cn => option(maps:get(cn, ClientInfo, undefined)),
dn => option(maps:get(dn, ClientInfo, undefined))
}.
message(#message{
@ -435,8 +435,8 @@ ntoa({0, 0, 0, 0, 0, 16#ffff, AB, CD}) ->
ntoa(IP) ->
list_to_binary(inet_parse:ntoa(IP)).
maybe(undefined) -> <<>>;
maybe(B) -> B.
option(undefined) -> <<>>;
option(B) -> B.
%% @private
stringfy(Term) when is_binary(Term) ->

View File

@ -509,8 +509,8 @@ ntoa({0, 0, 0, 0, 0, 16#ffff, AB, CD}) ->
ntoa(IP) ->
list_to_binary(inet_parse:ntoa(IP)).
maybe(undefined) -> <<>>;
maybe(B) -> B.
option(undefined) -> <<>>;
option(B) -> B.
properties(undefined) ->
[];
@ -568,7 +568,7 @@ from_conninfo(ConnInfo) ->
#{
node => nodestr(),
clientid => maps:get(clientid, ConnInfo),
username => maybe(maps:get(username, ConnInfo, <<>>)),
username => option(maps:get(username, ConnInfo, <<>>)),
peerhost => peerhost(ConnInfo),
peerport => peerport(ConnInfo),
sockport => sockport(ConnInfo),
@ -581,17 +581,17 @@ from_clientinfo(ClientInfo) ->
#{
node => nodestr(),
clientid => maps:get(clientid, ClientInfo),
username => maybe(maps:get(username, ClientInfo, <<>>)),
password => maybe(maps:get(password, ClientInfo, <<>>)),
username => option(maps:get(username, ClientInfo, <<>>)),
password => option(maps:get(password, ClientInfo, <<>>)),
peerhost => ntoa(maps:get(peerhost, ClientInfo)),
peerport => maps:get(peerport, ClientInfo),
sockport => maps:get(sockport, 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),
anonymous => maps:get(anonymous, ClientInfo, true),
cn => maybe(maps:get(cn, ClientInfo, <<>>)),
dn => maybe(maps:get(dn, ClientInfo, <<>>))
cn => option(maps:get(cn, ClientInfo, <<>>)),
dn => option(maps:get(dn, ClientInfo, <<>>))
}.
from_message(Msg) ->

View File

@ -218,7 +218,7 @@ do_on_file_command(TopicReplyData, FileId, Msg, FileCommand) ->
[<<"fin">>, FinalSizeBin | MaybeChecksum] when length(MaybeChecksum) =< 1 ->
ChecksumBin = emqx_maybe:from_list(MaybeChecksum),
validate(
[{size, FinalSizeBin}, {{maybe, checksum}, ChecksumBin}],
[{size, FinalSizeBin}, {{option, checksum}, ChecksumBin}],
fun([FinalSize, FinalChecksum]) ->
on_fin(TopicReplyData, Msg, Transfer, FinalSize, FinalChecksum)
end
@ -464,9 +464,9 @@ do_validate([{integrity, Payload, {Algo, Checksum}} | Rest], Parsed) ->
Mismatch ->
{error, {checksum_mismatch, binary:encode_hex(Mismatch)}}
end;
do_validate([{{maybe, _}, undefined} | Rest], Parsed) ->
do_validate([{{option, _}, undefined} | Rest], 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).
parse_checksum(Checksum) when is_binary(Checksum) andalso byte_size(Checksum) =:= 64 ->

View File

@ -100,7 +100,7 @@
-callback start(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().
%%--------------------------------------------------------------------

View File

@ -41,8 +41,8 @@
-export([handle_info/2]).
-record(st, {
next_gc_timer :: maybe(reference()),
last_gc :: maybe(gcstats())
next_gc_timer :: option(reference()),
last_gc :: option(gcstats())
}).
-type gcstats() :: #gcstats{}.

View File

@ -67,9 +67,9 @@
%% The {active, N} option
active_n :: pos_integer(),
%% Limiter
limiter :: maybe(emqx_htb_limiter:limiter()),
limiter :: option(emqx_htb_limiter:limiter()),
%% Limit Timer
limit_timer :: maybe(reference()),
limit_timer :: option(reference()),
%% Parse State
parse_state :: emqx_gateway_frame:parse_state(),
%% Serialize options
@ -77,15 +77,15 @@
%% Channel State
channel :: emqx_gateway_channel:channel(),
%% GC State
gc_state :: maybe(emqx_gc:gc_state()),
gc_state :: option(emqx_gc:gc_state()),
%% Stats Timer
stats_timer :: disabled | maybe(reference()),
stats_timer :: disabled | option(reference()),
%% Idle Timeout
idle_timeout :: integer(),
%% Idle Timer
idle_timer :: maybe(reference()),
idle_timer :: option(reference()),
%% OOM Policy
oom_policy :: maybe(emqx_types:oom_policy()),
oom_policy :: option(emqx_types:oom_policy()),
%% Frame Module
frame_mod :: atom(),
%% Channel Module

View File

@ -50,15 +50,15 @@
%% Conn info
conninfo :: emqx_types:conninfo(),
%% Client info from `register` function
clientinfo :: maybe(map()),
clientinfo :: option(map()),
%% Connection state
conn_state :: conn_state(),
%% Subscription
subscriptions = #{},
%% Keepalive
keepalive :: maybe(emqx_keepalive:keepalive()),
keepalive :: option(emqx_keepalive:keepalive()),
%% Timers
timers :: #{atom() => disabled | maybe(reference())},
timers :: #{atom() => disabled | option(reference())},
%% Closed reason
closed_reason = undefined
}).

View File

@ -1,7 +1,7 @@
%% -*- mode: erlang -*-
{application, emqx_gateway_gbt32960, [
{description, "GBT32960 Gateway"},
{vsn, "0.1.0"},
{vsn, "0.1.1"},
{registered, []},
{applications, [kernel, stdlib, emqx, emqx_gateway]},
{env, []},

View File

@ -42,7 +42,7 @@
%% Session
session :: undefined | map(),
%% Keepalive
keepalive :: maybe(emqx_keepalive:keepalive()),
keepalive :: option(emqx_keepalive:keepalive()),
%% Conn State
conn_state :: conn_state(),
%% Timers

View File

@ -1,7 +1,7 @@
%% -*- mode: erlang -*-
{application, emqx_gateway_jt808, [
{description, "JT/T 808 Gateway"},
{vsn, "0.0.1"},
{vsn, "0.0.2"},
{registered, []},
{applications, [kernel, stdlib, emqx, emqx_gateway]},
{env, []},

View File

@ -48,7 +48,7 @@
%% AuthCode
authcode :: undefined | anonymous | binary(),
%% Keepalive
keepalive :: maybe(emqx_keepalive:keepalive()),
keepalive :: option(emqx_keepalive:keepalive()),
%% Msg SN
msg_sn,
%% Down Topic

View File

@ -1,7 +1,7 @@
%% -*- mode: erlang -*-
{application, emqx_gateway_mqttsn, [
{description, "MQTT-SN Gateway"},
{vsn, "0.1.7"},
{vsn, "0.1.8"},
{registered, []},
{applications, [kernel, stdlib, emqx, emqx_gateway]},
{env, []},

View File

@ -71,7 +71,7 @@
%% Connection State
conn_state :: conn_state(),
%% Inflight register message queue
register_inflight :: maybe(term()),
register_inflight :: option(term()),
%% Topics list for awaiting to register to client
register_awaiting_queue :: list(),
%% Duration for asleep

View File

@ -63,15 +63,15 @@
%% ClientInfo
clientinfo :: emqx_types:clientinfo(),
%% Session
session :: maybe(map()),
session :: option(map()),
%% ClientInfo override specs
clientinfo_override :: map(),
%% Keepalive
keepalive :: maybe(emqx_ocpp_keepalive:keepalive()),
keepalive :: option(emqx_ocpp_keepalive:keepalive()),
%% Stores all unsent messages.
mqueue :: queue:queue(),
%% Timers
timers :: #{atom() => disabled | maybe(reference())},
timers :: #{atom() => disabled | option(reference())},
%% Conn State
conn_state :: conn_state()
}).

View File

@ -72,9 +72,9 @@
%% Piggyback
piggyback :: single | multiple,
%% Limiter
limiter :: maybe(emqx_htb_limiter:limiter()),
limiter :: option(emqx_htb_limiter:limiter()),
%% Limit Timer
limit_timer :: maybe(reference()),
limit_timer :: option(reference()),
%% Parse State
parse_state :: emqx_ocpp_frame:parse_state(),
%% Serialize options
@ -82,17 +82,17 @@
%% Channel
channel :: emqx_ocpp_channel:channel(),
%% GC State
gc_state :: maybe(emqx_gc:gc_state()),
gc_state :: option(emqx_gc:gc_state()),
%% Postponed Packets|Cmds|Events
postponed :: list(emqx_types:packet() | ws_cmd() | tuple()),
%% Stats Timer
stats_timer :: disabled | maybe(reference()),
stats_timer :: disabled | option(reference()),
%% Idle Timeout
idle_timeout :: timeout(),
%%% Idle Timer
idle_timer :: maybe(reference()),
idle_timer :: option(reference()),
%% OOM Policy
oom_policy :: maybe(emqx_types:oom_policy()),
oom_policy :: option(emqx_types:oom_policy()),
%% Frame Module
frame_mod :: atom(),
%% Channel Module

View File

@ -92,10 +92,10 @@
-export_type([with_id_return/0, with_id_return/1]).
-type state() :: #{
publish_timer := maybe(reference()),
publish_timer := option(reference()),
publish_at := non_neg_integer(),
stats_timer := maybe(reference()),
stats_fun := maybe(fun((pos_integer()) -> ok))
stats_timer := option(reference()),
stats_fun := option(fun((pos_integer()) -> ok))
}.
%% sync ms with record change

View File

@ -825,7 +825,7 @@ handle_remove_channel_exists(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
%% 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,
NewChannels = maps:remove(ChannelId, Channels),
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().
channels_health_check(?status_connected = _ConnectorStatus, Data0) ->
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
ChannelsNotAdded = [
ChannelId

View File

@ -18,7 +18,7 @@
-define(KV_TAB, '@rule_engine_db').
-type maybe(T) :: T | undefined.
-type option(T) :: T | undefined.
-type rule_id() :: binary().
-type rule_name() :: binary().

View File

@ -1,6 +1,6 @@
{application, emqx_s3, [
{description, "EMQX S3"},
{vsn, "5.0.13"},
{vsn, "5.0.14"},
{modules, []},
{registered, [emqx_s3_sup]},
{applications, [

View File

@ -103,9 +103,9 @@ with_client(ProfileId, Fun) when is_function(Fun, 1) andalso ?IS_PROFILE_ID(Prof
%%
-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) ->
case emqx_connector_ssl:convert_certs(mk_certs_dir(ProfileId), TransportOpts) of
{ok, TransportOptsConv} ->
@ -118,8 +118,8 @@ pre_config_update(_ProfileId, NewConfig, _OldConfig) ->
-spec post_config_update(
profile_id(),
maybe(emqx_config:config()),
maybe(emqx_config:config())
option(emqx_config:config()),
option(emqx_config:config())
) ->
ok.
post_config_update(_ProfileId, _NewConfig, _OldConfig) ->

View File

@ -89,7 +89,7 @@
-type readable_error_msg(_Error) :: binary().
-type maybe(T) :: undefined | T.
-type option(T) :: undefined | T.
-dialyzer({nowarn_function, [nolink_apply/2]}).
@ -128,8 +128,8 @@ merge_opts(Defaults, Options) ->
).
%% @doc Apply a function to a maybe argument.
-spec maybe_apply(fun((maybe(A)) -> maybe(A)), maybe(A)) ->
maybe(A)
-spec maybe_apply(fun((option(A)) -> option(A)), option(A)) ->
option(A)
when
A :: any().
maybe_apply(_Fun, undefined) ->
@ -184,17 +184,17 @@ apply_fun(Fun, Input, State) ->
{arity, 2} -> Fun(Input, State)
end.
-spec start_timer(integer() | atom(), term()) -> maybe(reference()).
-spec start_timer(integer() | atom(), term()) -> option(reference()).
start_timer(Interval, 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) ->
erlang:start_timer(erlang:ceil(Interval), Dest, Msg);
start_timer(_Atom, _Dest, _Msg) ->
undefined.
-spec cancel_timer(maybe(reference())) -> ok.
-spec cancel_timer(option(reference())) -> ok.
cancel_timer(Timer) when is_reference(Timer) ->
case erlang:cancel_timer(Timer) of
false ->

View File

@ -66,8 +66,8 @@ t_traverse_dir(Config) ->
{"nonempty/d2/deep/down/here", #file_info{type = regular, mode = ORW}},
{"nonempty/d2/deep/mutrec", #file_info{type = symlink, mode = ARWX}}
] when
((ORW band 8#00600 =:= 8#00600) and
(ARWX band 8#00777 =:= 8#00777)),
(((ORW band 8#00600 =:= 8#00600) and
(ARWX band 8#00777 =:= 8#00777))),
[{string:prefix(Filename, Dir), Info} || {Filename, Info} <- Traversal]
).

View File

@ -132,7 +132,7 @@
{eunit_opts, [verbose]}.
{project_plugins, [
erlfmt,
{erlfmt, "1.3.0"},
{rebar3_hex, "7.0.2"},
{rebar3_sbom, {git, "https://github.com/emqx/rebar3_sbom.git", {tag, "v0.6.1-1"}}}
]}.

Binary file not shown.