fix(dialyzer): fix some dialyzer issues found on otp 26

This commit is contained in:
Zaiming (Stone) Shi 2023-12-03 19:17:46 +01:00
parent 6affda8194
commit 423b586c56
70 changed files with 163 additions and 103 deletions

View File

@ -19,6 +19,6 @@
-callback import_config(RawConf :: map()) ->
{ok, #{
root_key => emqx_utils_maps:config_key(),
changed => [emqx_utils_maps:config_path()]
changed => [emqx_utils_maps:config_key_path()]
}}
| {error, #{root_key => emqx_utils_maps:config_key(), reason => term()}}.

View File

@ -11,6 +11,7 @@
gproc,
gen_rpc,
mria,
ekka,
esockd,
cowboy,
sasl,

View File

@ -96,7 +96,7 @@
%% Authentication Data Cache
auth_cache :: maybe(map()),
%% Quota checkers
quota :: emqx_limiter_container:limiter(),
quota :: emqx_limiter_container:container(),
%% Timers
timers :: #{atom() => disabled | maybe(reference())},
%% Conn State

View File

@ -49,7 +49,7 @@ trans(ClientId, Fun) ->
{error, client_id_unavailable}
end.
-spec lock(emqx_types:clientid()) -> {boolean, [node() | {node(), any()}]}.
-spec lock(emqx_types:clientid()) -> {boolean(), [node() | {node(), any()}]}.
lock(ClientId) ->
ekka_locker:acquire(?MODULE, ClientId, strategy()).

View File

@ -84,6 +84,7 @@
ok | {ok, Result :: any()} | {error, Reason :: term()}.
-type state() :: #{handlers := any()}.
-type config_key_path() :: emqx_utils_maps:config_key_path().
start_link() ->
gen_server:start_link({local, ?MODULE}, ?MODULE, {}, []).
@ -91,21 +92,21 @@ start_link() ->
stop() ->
gen_server:stop(?MODULE).
-spec update_config(module(), emqx_config:config_key_path(), emqx_config:update_args()) ->
-spec update_config(module(), config_key_path(), emqx_config:update_args()) ->
{ok, emqx_config:update_result()} | {error, emqx_config:update_error()}.
update_config(SchemaModule, ConfKeyPath, UpdateArgs) ->
%% force convert the path to a list of atoms, as there maybe some wildcard names/ids in the path
AtomKeyPath = [atom(Key) || Key <- ConfKeyPath],
gen_server:call(?MODULE, {change_config, SchemaModule, AtomKeyPath, UpdateArgs}, infinity).
-spec add_handler(emqx_config:config_key_path(), handler_name()) ->
-spec add_handler(config_key_path(), handler_name()) ->
ok | {error, {conflict, list()}}.
add_handler(ConfKeyPath, HandlerName) ->
assert_callback_function(HandlerName),
gen_server:call(?MODULE, {add_handler, ConfKeyPath, HandlerName}).
%% @doc Remove handler asynchronously
-spec remove_handler(emqx_config:config_key_path()) -> ok.
-spec remove_handler(config_key_path()) -> ok.
remove_handler(ConfKeyPath) ->
gen_server:cast(?MODULE, {remove_handler, ConfKeyPath}).
@ -764,7 +765,7 @@ assert_callback_function(Mod) ->
end,
ok.
-spec schema(module(), emqx_utils_maps:config_key_path()) -> hocon_schema:schema().
-spec schema(module(), config_key_path()) -> hocon_schema:schema().
schema(SchemaModule, [RootKey | _]) ->
Roots = hocon_schema:roots(SchemaModule),
{Field, Translations} =

View File

@ -58,12 +58,14 @@
-define(DEFAULT_CACHE_CAPACITY, 100).
-define(CONF_KEY_PATH, [crl_cache]).
-type duration() :: non_neg_integer().
-record(state, {
refresh_timers = #{} :: #{binary() => timer:tref()},
refresh_interval = timer:minutes(15) :: timer:time(),
http_timeout = ?HTTP_TIMEOUT :: timer:time(),
refresh_timers = #{} :: #{binary() => reference()},
refresh_interval = timer:minutes(15) :: duration(),
http_timeout = ?HTTP_TIMEOUT :: duration(),
%% keeps track of URLs by insertion time
insertion_times = gb_trees:empty() :: gb_trees:tree(timer:time(), url()),
insertion_times = gb_trees:empty() :: gb_trees:tree(duration(), url()),
%% the set of cached URLs, for testing if an URL is already
%% registered.
cached_urls = sets:new([{version, 2}]) :: sets:set(url()),

View File

@ -25,7 +25,7 @@
module := ?MODULE,
id := emqx_limiter_schema:limiter_id(),
type := emqx_limiter_schema:limiter_type(),
bucket := hocons:config()
bucket := hocon:config()
}.
%%--------------------------------------------------------------------
@ -35,7 +35,7 @@
-spec new_create_options(
emqx_limiter_schema:limiter_id(),
emqx_limiter_schema:limiter_type(),
hocons:config()
hocon:config()
) -> create_options().
new_create_options(Id, Type, BucketCfg) ->
#{module => ?MODULE, id => Id, type => Type, bucket => BucketCfg}.

View File

@ -32,7 +32,7 @@
make_future/1,
available/1
]).
-export_type([local_limiter/0]).
-export_type([local_limiter/0, limiter/0]).
%% a token bucket limiter which may or not contains a reference to another limiter,
%% and can be used in a client alone

View File

@ -70,7 +70,7 @@
-spec get_limiter_by_types(
limiter_id() | {atom(), atom()},
list(limiter_type()),
#{limiter_type() => hocons:config()}
#{limiter_type() => hocon:config()}
) -> container().
get_limiter_by_types({Type, Listener}, Types, BucketCfgs) ->
Id = emqx_listeners:listener_id(Type, Listener),

View File

@ -77,7 +77,7 @@
start_server(Type) ->
emqx_limiter_server_sup:start(Type).
-spec start_server(limiter_type(), hocons:config()) -> _.
-spec start_server(limiter_type(), hocon:config()) -> _.
start_server(Type, Cfg) ->
emqx_limiter_server_sup:start(Type, Cfg).

View File

@ -112,7 +112,7 @@
-spec connect(
limiter_id(),
limiter_type(),
hocons:config() | undefined
hocon:config() | undefined
) ->
{ok, emqx_htb_limiter:limiter()} | {error, _}.
%% undefined is the default situation, no limiter setting by default
@ -128,7 +128,7 @@ connect(Id, Type, Cfg) ->
maps:get(Type, Cfg, undefined)
).
-spec add_bucket(limiter_id(), limiter_type(), hocons:config() | undefined) -> ok.
-spec add_bucket(limiter_id(), limiter_type(), hocon:config() | undefined) -> ok.
add_bucket(_Id, _Type, undefined) ->
ok;
%% a bucket with an infinity rate shouldn't be added to this server, because it is always full
@ -153,7 +153,7 @@ name(Type) ->
restart(Type) ->
?CALL(Type).
-spec update_config(limiter_type(), hocons:config()) -> ok | {error, _}.
-spec update_config(limiter_type(), hocon:config()) -> ok | {error, _}.
update_config(Type, Config) ->
?CALL(Type, {update_config, Type, Config}).
@ -166,7 +166,7 @@ whereis(Type) ->
%% Starts the server
%% @end
%%--------------------------------------------------------------------
-spec start_link(limiter_type(), hocons:config()) -> _.
-spec start_link(limiter_type(), hocon:config()) -> _.
start_link(Type, Cfg) ->
gen_server:start_link({local, name(Type)}, ?MODULE, [Type, Cfg], []).
@ -500,7 +500,7 @@ init_tree(Type, #{rate := Rate} = Cfg) ->
buckets => #{}
}.
-spec make_root(hocons:confg()) -> root().
-spec make_root(hocon:config()) -> root().
make_root(#{rate := Rate, burst := Burst}) ->
#{
rate => Rate,
@ -554,7 +554,7 @@ do_del_bucket(Id, #{type := Type, buckets := Buckets} = State) ->
State#{buckets := maps:remove(Id, Buckets)}
end.
-spec get_initial_val(hocons:config()) -> decimal().
-spec get_initial_val(hocon:config()) -> decimal().
get_initial_val(
#{
initial := Initial,

View File

@ -47,7 +47,7 @@ start(Type) ->
Spec = make_child(Type),
supervisor:start_child(?MODULE, Spec).
-spec start(emqx_limiter_schema:limiter_type(), hocons:config()) -> _.
-spec start(emqx_limiter_schema:limiter_type(), hocon:config()) -> _.
start(Type, Cfg) ->
Spec = make_child(Type, Cfg),
supervisor:start_child(?MODULE, Spec).

View File

@ -3373,7 +3373,7 @@ naive_env_interpolation("$" ++ Maybe = Original) ->
filename:join([Path, Tail]);
error ->
?SLOG(warning, #{
msg => "failed_to_resolve_env_variable",
msg => "cannot_resolve_env_variable",
env => Env,
original => Original
}),

View File

@ -114,7 +114,9 @@
reply/0,
replies/0,
common_timer_name/0,
custom_timer_name/0
custom_timer_name/0,
session_id/0,
session/0
]).
-type session_id() :: _TODO.
@ -150,6 +152,8 @@
await_rel_timeout := timeout()
}.
-type session() :: t().
-type t() ::
emqx_session_mem:session()
| emqx_persistent_session_ds:session().

View File

@ -114,6 +114,8 @@
-export_type([takeover_data/0]).
-export_type([startlink_ret/0]).
-type proto_ver() ::
?MQTT_PROTO_V3
| ?MQTT_PROTO_V4

View File

@ -35,7 +35,7 @@ t_start_link(_) ->
emqx_cm_locker:start_link().
t_trans(_) ->
ok = emqx_cm_locker:trans(undefined, fun(_) -> ok end, []),
ok = emqx_cm_locker:trans(undefined, fun(_) -> ok end),
ok = emqx_cm_locker:trans(<<"clientid">>, fun(_) -> ok end).
t_lock_unlock(_) ->

View File

@ -1,7 +1,7 @@
%% -*- mode: erlang -*-
{application, emqx_auto_subscribe, [
{description, "Auto subscribe Application"},
{vsn, "0.1.5"},
{vsn, "0.1.6"},
{registered, []},
{mod, {emqx_auto_subscribe_app, []}},
{applications, [

View File

@ -17,7 +17,7 @@
-export([init/1]).
-spec init(hocons:config()) -> {Module :: atom(), Config :: term()}.
-spec init(hocon:config()) -> {Module :: atom(), Config :: term()}.
init(Config) ->
do_init(Config).

View File

@ -88,7 +88,7 @@ keyspace(_) -> undefined.
callback_mode() -> async_if_possible.
-spec on_start(binary(), hoconsc:config()) -> {ok, state()} | {error, _}.
-spec on_start(binary(), hocon:config()) -> {ok, state()} | {error, _}.
on_start(
InstId,
#{

View File

@ -27,6 +27,7 @@
-type service_account_json() :: emqx_bridge_gcp_pubsub:service_account_json().
-type project_id() :: binary().
-type duration() :: non_neg_integer().
-type config() :: #{
connect_timeout := emqx_schema:duration_ms(),
max_retries := non_neg_integer(),
@ -35,12 +36,12 @@
any() => term()
}.
-opaque state() :: #{
connect_timeout := timer:time(),
connect_timeout := duration(),
jwt_config := emqx_connector_jwt:jwt_config(),
max_retries := non_neg_integer(),
pool_name := binary(),
project_id := project_id(),
request_ttl := infinity | timer:time()
request_ttl := erlang:timeout()
}.
-type headers() :: [{binary(), iodata()}].
-type body() :: iodata().
@ -414,7 +415,7 @@ reply_delegator(ResourceId, ReplyFunAndArgs, Response) ->
Result = handle_response(Response, ResourceId, _QueryMode = async),
emqx_resource:apply_reply_fun(ReplyFunAndArgs, Result).
-spec do_get_status(resource_id(), timer:time()) -> boolean().
-spec do_get_status(resource_id(), duration()) -> boolean().
do_get_status(ResourceId, Timeout) ->
Workers = [Worker || {_WorkerName, Worker} <- ehttpc:workers(ResourceId)],
DoPerWorker =

View File

@ -30,12 +30,13 @@
-type bridge_name() :: atom() | binary().
-type ack_id() :: binary().
-type message_id() :: binary().
-type duration() :: non_neg_integer().
-type config() :: #{
ack_deadline := emqx_schema:timeout_duration_s(),
ack_retry_interval := emqx_schema:timeout_duration_ms(),
client := emqx_bridge_gcp_pubsub_client:state(),
ecpool_worker_id => non_neg_integer(),
forget_interval := timer:time(),
forget_interval := duration(),
hookpoint := binary(),
instance_id := binary(),
mqtt_config => emqx_bridge_gcp_pubsub_impl_consumer:mqtt_config(),
@ -52,7 +53,7 @@
async_workers := #{pid() => reference()},
client := emqx_bridge_gcp_pubsub_client:state(),
ecpool_worker_id := non_neg_integer(),
forget_interval := timer:time(),
forget_interval := duration(),
hookpoint := binary(),
instance_id := binary(),
mqtt_config := emqx_bridge_gcp_pubsub_impl_consumer:mqtt_config(),

View File

@ -25,9 +25,11 @@
-include("emqx_bridge_syskeeper.hrl").
-type duration() :: non_neg_integer().
-type state() :: #{
ack_mode := need_ack | no_ack,
ack_timeout := timer:time(),
ack_timeout := duration(),
socket := undefined | inet:socket(),
frame_state := emqx_bridge_syskeeper_frame:state(),
last_error := undefined | tuple()

View File

@ -33,8 +33,9 @@
-type jwt() :: binary().
-type wrapped_jwk() :: fun(() -> jose_jwk:key()).
-type jwk() :: jose_jwk:key().
-type duration() :: non_neg_integer().
-type jwt_config() :: #{
expiration := timer:time(),
expiration := duration(),
resource_id := resource_id(),
table := ets:table(),
jwk := wrapped_jwk() | jwk(),

View File

@ -41,10 +41,12 @@
-include_lib("jose/include/jose_jwk.hrl").
-include_lib("snabbkaffe/include/snabbkaffe.hrl").
-type duration() :: non_neg_integer().
-type config() :: #{
private_key := binary(),
resource_id := resource_id(),
expiration := timer:time(),
expiration := duration(),
table := ets:table(),
iss := binary(),
sub := binary(),
@ -54,9 +56,9 @@
}.
-type jwt() :: binary().
-type state() :: #{
refresh_timer := undefined | timer:tref() | reference(),
refresh_timer := undefined | reference(),
resource_id := resource_id(),
expiration := timer:time(),
expiration := duration(),
table := ets:table(),
jwt := undefined | jwt(),
%% only undefined during startup
@ -221,7 +223,7 @@ censor_secret(undefined) ->
censor_secret(_Secret) ->
"******".
-spec cancel_timer(undefined | timer:tref() | reference()) -> ok.
-spec cancel_timer(undefined | reference() | reference()) -> ok.
cancel_timer(undefined) ->
ok;
cancel_timer(TRef) ->

View File

@ -30,6 +30,6 @@ evict_session_channel(Node, ClientId, ConnInfo, ClientInfo) ->
rpc:call(Node, emqx_eviction_agent, evict_session_channel, [ClientId, ConnInfo, ClientInfo]).
%% Introduced in v2:
-spec all_channels_count([node()], time:time()) -> emqx_rpc:erpc_multicall(non_neg_integer()).
-spec all_channels_count([node()], timeout()) -> emqx_rpc:erpc_multicall(non_neg_integer()).
all_channels_count(Nodes, Timeout) ->
erpc:multicall(Nodes, emqx_eviction_agent, all_local_channels_count, [], Timeout).

View File

@ -20,6 +20,8 @@
%% module if it integrated with emqx_gateway_conn module
-module(emqx_gateway_channel).
-export_type([gen_server_from/0]).
-type channel() :: any().
%%--------------------------------------------------------------------

View File

@ -16,6 +16,8 @@
-module(emqx_gateway_impl).
-export_type([state/0]).
-include("emqx_gateway.hrl").
-type state() :: map().

View File

@ -774,7 +774,6 @@ init(Options) ->
{ok, Registry} = emqx_gateway_cm_registry:start_link(GwName),
%% Start locker process
LockerName = lockername(GwName),
{ok, _LockerPid} = ekka_locker:start_link(lockername(GwName)),
%% Interval update stats

View File

@ -53,7 +53,7 @@
-record(channel, {chid, pid}).
%% @doc Start the global channel registry for the given gateway name.
-spec start_link(gateway_name()) -> gen_server:startlink_ret().
-spec start_link(gateway_name()) -> emqx_types:startlink_ret().
start_link(Name) ->
gen_server:start_link(?MODULE, [Name], []).

View File

@ -17,6 +17,8 @@
%% @doc The gateway instance context
-module(emqx_gateway_ctx).
-export_type([context/0]).
-include("emqx_gateway.hrl").
%% @doc The running context for a Connection/Channel process.

View File

@ -89,17 +89,17 @@
-elvis([{elvis_style, god_modules, disable}]).
-spec childspec(supervisor:worker(), Mod :: atom()) ->
-spec childspec(worker | supervisor, Mod :: atom()) ->
supervisor:child_spec().
childspec(Type, Mod) ->
childspec(Mod, Type, Mod, []).
-spec childspec(supervisor:worker(), Mod :: atom(), Args :: list()) ->
-spec childspec(worker | supervisor, Mod :: atom(), Args :: list()) ->
supervisor:child_spec().
childspec(Type, Mod, Args) ->
childspec(Mod, Type, Mod, Args).
-spec childspec(atom(), supervisor:worker(), Mod :: atom(), Args :: list()) ->
-spec childspec(atom(), worker | supervisor, Mod :: atom(), Args :: list()) ->
supervisor:child_spec().
childspec(Id, Type, Mod, Args) ->
#{
@ -121,7 +121,7 @@ supervisor_ret({error, {Reason, Child}}) ->
supervisor_ret(Ret) ->
Ret.
-spec find_sup_child(Sup :: pid() | atom(), ChildId :: supervisor:child_id()) ->
-spec find_sup_child(Sup :: pid() | atom(), ChildId :: term()) ->
false
| {ok, pid()}.
find_sup_child(Sup, ChildId) ->

View File

@ -40,7 +40,7 @@ introduced_in() ->
"5.0.0".
-spec lookup_by_clientid([node()], emqx_gateway_cm:gateway_name(), emqx_types:clientid()) ->
emqx_rpc:multicall_return([pid()]).
emqx_rpc:multicall_result([pid()]).
lookup_by_clientid(Nodes, GwName, ClientId) ->
rpc:multicall(Nodes, emqx_gateway_cm, do_lookup_by_clientid, [GwName, ClientId]).

View File

@ -40,7 +40,7 @@
token :: token() | undefined,
observe :: 0 | 1 | undefined | observed,
state :: atom(),
timers :: maps:map(),
timers :: map(),
transport :: emqx_coap_transport:transport()
}).
-type state_machine() :: #state_machine{}.

View File

@ -131,7 +131,7 @@ stats(#channel{subscriptions = Subs}) ->
%% Init the channel
%%--------------------------------------------------------------------
-spec init(emqx_exproto_types:conninfo(), map()) -> channel().
-spec init(emqx_types:conninfo(), map()) -> channel().
init(
ConnInfo = #{
socktype := Socktype,

View File

@ -29,6 +29,8 @@
is_empty/1
]).
-export_type([grpc_client_state/0]).
-define(CONN_HANDLER_MOD, emqx_exproto_v_1_connection_handler_client).
-define(CONN_UNARY_HANDLER_MOD, emqx_exproto_v_1_connection_unary_handler_client).

View File

@ -38,13 +38,18 @@
unsubscribe/2
]).
%% TODO:
%% The spec should be :: grpc_cowboy_h:error_response()
%% But there is no such module as grpc_cowboy_h
-type error_response() :: term().
%%--------------------------------------------------------------------
%% gRPC ConnectionAdapter service
%%--------------------------------------------------------------------
-spec send(emqx_exproto_pb:send_bytes_request(), grpc:metadata()) ->
{ok, emqx_exproto_pb:code_response(), grpc:metadata()}
| {error, grpc_cowboy_h:error_response()}.
| {error, error_response()}.
send(Req = #{conn := Conn, bytes := Bytes}, Md) ->
?SLOG(debug, #{
msg => "recv_grpc_function_call",
@ -55,7 +60,7 @@ send(Req = #{conn := Conn, bytes := Bytes}, Md) ->
-spec close(emqx_exproto_pb:close_socket_request(), grpc:metadata()) ->
{ok, emqx_exproto_pb:code_response(), grpc:metadata()}
| {error, grpc_cowboy_h:error_response()}.
| {error, error_response()}.
close(Req = #{conn := Conn}, Md) ->
?SLOG(debug, #{
msg => "recv_grpc_function_call",
@ -66,7 +71,7 @@ close(Req = #{conn := Conn}, Md) ->
-spec authenticate(emqx_exproto_pb:authenticate_request(), grpc:metadata()) ->
{ok, emqx_exproto_pb:code_response(), grpc:metadata()}
| {error, grpc_cowboy_h:error_response()}.
| {error, error_response()}.
authenticate(
Req = #{
conn := Conn,
@ -89,7 +94,7 @@ authenticate(
-spec start_timer(emqx_exproto_pb:timer_request(), grpc:metadata()) ->
{ok, emqx_exproto_pb:code_response(), grpc:metadata()}
| {error, grpc_cowboy_h:error_response()}.
| {error, error_response()}.
start_timer(Req = #{conn := Conn, type := Type, interval := Interval}, Md) when
Type =:= 'KEEPALIVE' andalso Interval > 0
->
@ -111,7 +116,7 @@ start_timer(Req, Md) ->
-spec publish(emqx_exproto_pb:publish_request(), grpc:metadata()) ->
{ok, emqx_exproto_pb:code_response(), grpc:metadata()}
| {error, grpc_cowboy_h:error_response()}.
| {error, error_response()}.
publish(Req = #{conn := Conn, topic := Topic, qos := Qos, payload := Payload}, Md) when
?IS_QOS(Qos)
->
@ -132,7 +137,7 @@ publish(Req, Md) ->
-spec raw_publish(emqx_exproto_pb:raw_publish_request(), grpc:metadata()) ->
{ok, emqx_exproto_pb:code_response(), grpc:metadata()}
| {error, grpc_stream:error_response()}.
| {error, error_response()}.
raw_publish(Req = #{topic := Topic, qos := Qos, payload := Payload}, Md) ->
?SLOG(debug, #{
msg => "recv_grpc_function_call",
@ -145,7 +150,7 @@ raw_publish(Req = #{topic := Topic, qos := Qos, payload := Payload}, Md) ->
-spec subscribe(emqx_exproto_pb:subscribe_request(), grpc:metadata()) ->
{ok, emqx_exproto_pb:code_response(), grpc:metadata()}
| {error, grpc_cowboy_h:error_response()}.
| {error, error_response()}.
subscribe(Req = #{conn := Conn, topic := Topic, qos := Qos}, Md) when
?IS_QOS(Qos)
->
@ -165,7 +170,7 @@ subscribe(Req, Md) ->
-spec unsubscribe(emqx_exproto_pb:unsubscribe_request(), grpc:metadata()) ->
{ok, emqx_exproto_pb:code_response(), grpc:metadata()}
| {error, grpc_cowboy_h:error_response()}.
| {error, error_response()}.
unsubscribe(Req = #{conn := Conn, topic := Topic}, Md) ->
?SLOG(debug, #{
msg => "recv_grpc_function_call",

View File

@ -1,7 +1,7 @@
%% -*- mode: erlang -*-
{application, emqx_gateway_exproto, [
{description, "ExProto Gateway"},
{vsn, "0.1.5"},
{vsn, "0.1.6"},
{registered, []},
{applications, [kernel, stdlib, grpc, emqx, emqx_gateway]},
{env, []},

View File

@ -3,7 +3,7 @@
{description, "LwM2M Gateway"},
{vsn, "0.1.5"},
{registered, []},
{applications, [kernel, stdlib, emqx, emqx_gateway, emqx_gateway_coap]},
{applications, [kernel, stdlib, emqx, emqx_gateway, emqx_gateway_coap, xmerl]},
{env, []},
{modules, []},
{licenses, ["Apache 2.0"]},

View File

@ -43,6 +43,8 @@
-define(LWM2M_OBJECT_DEF_TAB, lwm2m_object_def_tab).
-define(LWM2M_OBJECT_NAME_TO_ID_TAB, lwm2m_object_name_to_id_tab).
-type xmlElement() :: tuple().
-record(state, {}).
-elvis([{elvis_style, atom_naming_convention, disable}]).
@ -59,7 +61,7 @@
start_link(XmlDir) ->
gen_server:start_link({local, ?MODULE}, ?MODULE, [XmlDir], []).
-spec find_objectid(integer()) -> {error, no_xml_definition} | xmerl:xmlElement().
-spec find_objectid(integer()) -> {error, no_xml_definition} | xmlElement().
find_objectid(ObjectId) ->
ObjectIdInt =
case is_list(ObjectId) of
@ -71,7 +73,7 @@ find_objectid(ObjectId) ->
[{_ObjectId, Xml}] -> Xml
end.
-spec find_name(string()) -> {error, no_xml_definition} | xmerl:xmlElement().
-spec find_name(string()) -> {error, no_xml_definition} | xmlElement().
find_name(Name) ->
NameBinary =
case is_list(Name) of

View File

@ -32,6 +32,8 @@
lookup_topic_id/2
]).
-export_type([registry/0]).
-define(PKEY(Id), {mqttsn, predef_topics, Id}).
-type registry() :: #{

View File

@ -72,13 +72,13 @@
%% Piggyback
piggyback :: single | multiple,
%% Limiter
limiter :: maybe(emqx_limiter:limiter()),
limiter :: maybe(emqx_htb_limiter:limiter()),
%% Limit Timer
limit_timer :: maybe(reference()),
%% Parse State
parse_state :: emqx_ocpp_frame:parse_state(),
%% Serialize options
serialize :: emqx_ocpp_frame:serialize_opts(),
serialize :: emqx_ocpp_frame:serialize_options(),
%% Channel
channel :: emqx_ocpp_channel:channel(),
%% GC State
@ -268,7 +268,7 @@ init_state_and_channel([Req, Opts, _WsOpts], _State = undefined) ->
ws_cookie => WsCookie,
conn_mod => ?MODULE
},
Limiter = undeined,
Limiter = undefined,
ActiveN = emqx_gateway_utils:active_n(Opts),
Piggyback = emqx_utils_maps:deep_get([websocket, piggyback], Opts, multiple),
ParseState = emqx_ocpp_frame:initial_parse_state(#{}),

View File

@ -39,9 +39,12 @@
-export_type([
parse_state/0,
parse_result/0,
frame/0
frame/0,
serialize_options/0
]).
-type serialize_options() :: emqx_gateway_frame:serialize_options().
-dialyzer({nowarn_function, [format/1]}).
-spec initial_parse_state(map()) -> parse_state().
@ -114,7 +117,7 @@ parse(
},
<<>>, Parser}.
-spec serialize_opts() -> emqx_gateway_frame:serialize_options().
-spec serialize_opts() -> serialize_options().
serialize_opts() ->
#{}.

View File

@ -69,7 +69,7 @@
%% Channel State
conn_state :: conn_state(),
%% Heartbeat
heartbeat :: emqx_stomp_heartbeat:heartbeat(),
heartbeat :: undefined | emqx_stomp_heartbeat:heartbeat(),
%% Subscriptions
subscriptions = [],
%% Timer

View File

@ -27,6 +27,8 @@
interval/2
]).
-export_type([heartbeat/0]).
-record(heartbeater, {interval, statval, repeat}).
-type name() :: incoming | outgoing.

View File

@ -130,7 +130,7 @@ ensure_username(Field) ->
%% ===================================================================
callback_mode() -> always_sync.
-spec on_start(binary(), hoconsc:config()) -> {ok, state()} | {error, _}.
-spec on_start(binary(), hocon:config()) -> {ok, state()} | {error, _}.
on_start(
InstId,
#{

View File

@ -33,7 +33,7 @@
-define(POOL_NAME_SUFFIX, "bind_worker").
%% ===================================================================
-spec on_start(binary(), hoconsc:config(), proplists:proplist(), map()) ->
-spec on_start(binary(), hocon:config(), proplists:proplist(), map()) ->
{ok, binary(), map()} | {error, _}.
on_start(InstId, #{method := #{bind_password := _}} = Config, Options, State) ->
PoolName = pool_name(InstId),

View File

@ -43,7 +43,8 @@
start_link() ->
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
-spec run() -> {ok, timer:time()}.
%% @doc Run global garbage collection and return the time (in milliseconds) spent.
-spec run() -> {ok, non_neg_integer()}.
run() -> gen_server:call(?MODULE, run, infinity).
-spec stop() -> ok.

View File

@ -6,7 +6,7 @@
{vsn, "0.2.17"},
{modules, []},
{registered, []},
{applications, [kernel, stdlib, emqx_ctl]},
{applications, [kernel, stdlib, emqx_ctl, system_monitor, covertool]},
{mod, {emqx_machine_app, []}},
{env, []},
{licenses, ["Apache-2.0"]},

View File

@ -5,7 +5,9 @@
{vsn, "5.0.34"},
{modules, []},
{registered, [emqx_management_sup]},
{applications, [kernel, stdlib, emqx_plugins, minirest, emqx, emqx_ctl, emqx_bridge_http]},
{applications, [
kernel, stdlib, emqx_plugins, minirest, emqx, emqx_ctl, emqx_bridge_http, emqx_http_lib
]},
{mod, {emqx_mgmt_app, []}},
{env, []},
{licenses, ["Apache-2.0"]},

View File

@ -105,7 +105,7 @@
}.
-type db_error_details() :: #{mria:table() => {error, _}}.
-type config_error_details() :: #{emqx_utils_maps:config_path() => {error, _}}.
-type config_error_details() :: #{emqx_utils_maps:config_key_path() => {error, _}}.
-type import_res() ::
{ok, #{db_errors => db_error_details(), config_errors => config_error_details()}} | {error, _}.

View File

@ -86,7 +86,7 @@
-export_type([with_id_return/0, with_id_return/1]).
-type state() :: #{
publish_timer := maybe(timer:tref()),
publish_timer := maybe(reference()),
publish_at := non_neg_integer(),
stats_timer := maybe(reference()),
stats_fun := maybe(fun((pos_integer()) -> ok))

View File

@ -3,7 +3,7 @@
{description, "EMQX Modules"},
{vsn, "5.0.24"},
{modules, []},
{applications, [kernel, stdlib, emqx, emqx_ctl]},
{applications, [kernel, stdlib, emqx, emqx_ctl, observer_cli]},
{mod, {emqx_modules_app, []}},
{registered, [emqx_modules_sup]},
{env, []}

View File

@ -83,7 +83,7 @@ server() ->
%% ===================================================================
callback_mode() -> always_sync.
-spec on_start(binary(), hoconsc:config()) -> {ok, state()} | {error, _}.
-spec on_start(binary(), hocon:config()) -> {ok, state()} | {error, _}.
on_start(
InstId,
#{

View File

@ -34,7 +34,8 @@
-export_type([
start_opts/0,
start_error/0
start_error/0,
migrate_to/0
]).
-ifdef(TEST).

View File

@ -66,7 +66,7 @@
% be sync for now.
callback_mode() -> always_sync.
-spec on_start(binary(), hoconsc:config()) -> {ok, state()} | {error, _}.
-spec on_start(binary(), hocon:config()) -> {ok, state()} | {error, _}.
on_start(
InstId,
#{

View File

@ -100,7 +100,7 @@ adjust_fields(Fields) ->
%% ===================================================================
callback_mode() -> always_sync.
-spec on_start(binary(), hoconsc:config()) -> {ok, state()} | {error, _}.
-spec on_start(binary(), hocon:config()) -> {ok, state()} | {error, _}.
on_start(
InstId,
#{

View File

@ -42,7 +42,7 @@ deregister_cleanup(_) -> ok.
%% @private
-spec collect_mf(_Registry, Callback) -> ok when
_Registry :: prometheus_registry:registry(),
Callback :: prometheus_collector:callback().
Callback :: prometheus_collector:collect_mf_callback().
collect_mf(_Registry, Callback) ->
case mria_rlog:backend() of
rlog ->

View File

@ -80,8 +80,9 @@
-type queue_query() :: ?QUERY(reply_fun(), request(), HasBeenSent :: boolean(), expire_at()).
-type request() :: term().
-type request_from() :: undefined | gen_statem:from().
-type request_ttl() :: infinity | timer:time().
-type health_check_interval() :: timer:time().
-type timeout_ms() :: emqx_schema:timeout_duration_ms().
-type request_ttl() :: emqx_schema:timeout_duration_ms().
-type health_check_interval() :: pos_integer().
-type state() :: blocked | running.
-type inflight_key() :: integer().
-type counters() :: #{
@ -101,13 +102,13 @@
inflight_tid := inflight_table(),
async_workers := #{pid() => reference()},
batch_size := pos_integer(),
batch_time := timer:time(),
batch_time := timeout_ms(),
counters := counters(),
metrics_flush_interval := timer:time(),
metrics_flush_interval := timeout_ms(),
queue := replayq:q(),
resume_interval := timer:time(),
tref := undefined | {timer:tref() | reference(), reference()},
metrics_tref := undefined | {timer:tref() | reference(), reference()}
resume_interval := timeout_ms(),
tref := undefined | {reference(), reference()},
metrics_tref := undefined | {reference(), reference()}
}.
callback_mode() -> [state_functions, state_enter].
@ -2032,7 +2033,7 @@ replayq_opts(Id, Index, Opts) ->
%% timeout is <= resume interval and the buffer worker is ever
%% blocked, than all queued requests will basically fail without being
%% attempted.
-spec default_resume_interval(request_ttl(), health_check_interval()) -> timer:time().
-spec default_resume_interval(request_ttl(), health_check_interval()) -> timeout_ms().
default_resume_interval(_RequestTTL = infinity, HealthCheckInterval) ->
max(1, HealthCheckInterval);
default_resume_interval(RequestTTL, HealthCheckInterval) ->

View File

@ -47,7 +47,8 @@ fields("resource_opts") ->
fields("creation_opts") ->
create_opts([]).
-spec create_opts([{atom(), hocon_schema:field_schema_map()}]) -> [{atom(), hocon_schema:field()}].
-spec create_opts([{atom(), hocon_schema:field_schema()}]) ->
[{atom(), hocon_schema:field_schema()}].
create_opts(Overrides) ->
override(
[

View File

@ -307,7 +307,7 @@ clean(Context) ->
Mod = get_backend_module(),
Mod:clean(Context).
-spec update_config(state(), hocons:config(), hocons:config()) -> state().
-spec update_config(state(), hocon:config(), hocon:config()) -> state().
update_config(State, Conf, OldConf) ->
update_config(
maps:get(enable, Conf),
@ -317,7 +317,7 @@ update_config(State, Conf, OldConf) ->
OldConf
).
-spec update_config(boolean(), boolean(), state(), hocons:config(), hocons:config()) -> state().
-spec update_config(boolean(), boolean(), state(), hocon:config(), hocon:config()) -> state().
update_config(false, _, State, _, _) ->
disable_retainer(State);
update_config(true, false, State, NewConf, _) ->

View File

@ -83,7 +83,7 @@ index_score(Index, Tokens) ->
%% Returns `undefined' if there are no indices with score `> 0'.
%%
%% @see index_score/2
-spec select_index(emqx:words(), list(index())) -> index() | undefined.
-spec select_index(emqx_types:words(), list(index())) -> index() | undefined.
select_index(Tokens, Indices) ->
select_index(Tokens, Indices, 0, undefined).

View File

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

View File

@ -82,7 +82,7 @@ update_profile(ProfileId, ProfileConfig) when ?IS_PROFILE_ID(ProfileId) ->
emqx_s3_profile_conf:update_config(ProfileId, ProfileConfig).
-spec start_uploader(profile_id(), emqx_s3_uploader:opts()) ->
supervisor:start_ret() | {error, profile_not_found}.
emqx_types:startlink_ret() | {error, profile_not_found}.
start_uploader(ProfileId, Opts) when ?IS_PROFILE_ID(ProfileId) ->
emqx_s3_profile_uploader_sup:start_uploader(ProfileId, Opts).

View File

@ -28,7 +28,12 @@
-export_type([
client/0,
headers/0
headers/0,
key/0,
upload_id/0,
etag/0,
part_number/0,
config/0
]).
-type headers() :: #{binary() | string() => iodata()}.

View File

@ -15,7 +15,7 @@
-export([init/1]).
-spec start_link(emqx_s3:profile_id(), emqx_s3:profile_config()) -> supervisor:start_ret().
-spec start_link(emqx_s3:profile_id(), emqx_s3:profile_config()) -> emqx_types:startlink_ret().
start_link(ProfileId, ProfileConfig) ->
supervisor:start_link(?MODULE, [ProfileId, ProfileConfig]).

View File

@ -24,7 +24,7 @@
-type id() :: {?MODULE, emqx_s3:profile_id()}.
-spec start_link(emqx_s3:profile_id()) -> supervisor:start_ret().
-spec start_link(emqx_s3:profile_id()) -> emqx_types:startlink_ret().
start_link(ProfileId) ->
supervisor:start_link(?VIA_GPROC(id(ProfileId)), ?MODULE, [ProfileId]).
@ -44,7 +44,7 @@ id(ProfileId) ->
{?MODULE, ProfileId}.
-spec start_uploader(emqx_s3:profile_id(), emqx_s3_uploader:opts()) ->
supervisor:start_ret() | {error, profile_not_found}.
emqx_types:startlink_ret() | {error, profile_not_found}.
start_uploader(ProfileId, Opts) ->
try supervisor:start_child(?VIA_GPROC(id(ProfileId)), [Opts]) of
Result -> Result

View File

@ -16,7 +16,7 @@
-export([init/1]).
-spec start_link() -> supervisor:start_ret().
-spec start_link() -> emqx_types:startlink_ret().
start_link() ->
supervisor:start_link({local, ?MODULE}, ?MODULE, []).

View File

@ -33,7 +33,12 @@
format_status/2
]).
-export_type([opts/0]).
-export_type([opts/0, config/0]).
-type config() :: #{
min_part_size => pos_integer(),
max_part_size => pos_integer()
}.
-type opts() :: #{
key := string(),

View File

@ -191,7 +191,7 @@ push_err(Line, Err, S = #s{errors = Errs}) ->
push_target(Target, S = #s{targets = Targets}) ->
S#s{targets = [Target | Targets]}.
-spec api_and_version(module()) -> {ok, emqx_bpapi:api(), emqx_bpapi:version()} | error.
-spec api_and_version(module()) -> {ok, emqx_bpapi:api(), emqx_bpapi:api_version()} | error.
api_and_version(Module) ->
Opts = [{capture, all_but_first, list}],
case re:run(atom_to_list(Module), "(.*)_proto_v([0-9]+)$", Opts) of

View File

@ -79,6 +79,12 @@
-export([clamp/3, redact/1, redact/2, is_redacted/2, is_redacted/3]).
-export_type([
readable_error_msg/1
]).
-type readable_error_msg(_Error) :: binary().
-type maybe(T) :: undefined | T.
-dialyzer({nowarn_function, [nolink_apply/2]}).
@ -435,7 +441,7 @@ pmap(Fun, List, Timeout) when
nolink_apply(Fun) -> nolink_apply(Fun, infinity).
%% @doc Same as `nolink_apply/1', with a timeout.
-spec nolink_apply(function(), timer:timeout()) -> term().
-spec nolink_apply(function(), timeout()) -> term().
nolink_apply(Fun, Timeout) when is_function(Fun, 0) ->
Caller = self(),
ResRef = alias([reply]),