Improve export_type attr
This commit is contained in:
parent
795fe4e0bc
commit
fb54fe0fad
|
@ -23,6 +23,8 @@
|
|||
, compile/1
|
||||
]).
|
||||
|
||||
-export_type([rule/0]).
|
||||
|
||||
-type(acl_result() :: allow | deny).
|
||||
|
||||
-type(who() :: all | binary() |
|
||||
|
@ -35,8 +37,6 @@
|
|||
-type(rule() :: {acl_result(), all} |
|
||||
{acl_result(), who(), access(), list(emqx_topic:topic())}).
|
||||
|
||||
-export_type([rule/0]).
|
||||
|
||||
-define(ALLOW_DENY(A), ((A =:= allow) orelse (A =:= deny))).
|
||||
-define(PUBSUB(A), ((A =:= subscribe) orelse (A =:= publish) orelse (A =:= pubsub))).
|
||||
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
, items/1
|
||||
]).
|
||||
|
||||
-export_type([options/0, batch/0]).
|
||||
|
||||
-record(batch, {
|
||||
batch_size :: non_neg_integer(),
|
||||
batch_q :: list(any()),
|
||||
|
@ -40,10 +42,6 @@
|
|||
|
||||
-opaque(batch() :: #batch{}).
|
||||
|
||||
-export_type([options/0]).
|
||||
|
||||
-export_type([batch/0]).
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% APIs
|
||||
%%--------------------------------------------------------------------
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
, getstat/2
|
||||
]).
|
||||
|
||||
-export_type([socket/0, option/0]).
|
||||
|
||||
-record(ssl_socket, {tcp, ssl}).
|
||||
|
||||
-type(socket() :: inet:socket() | #ssl_socket{}).
|
||||
|
@ -34,8 +36,6 @@
|
|||
|
||||
-type(option() :: gen_tcp:connect_option() | {ssl_opts, [ssl:ssl_option()]}).
|
||||
|
||||
-export_type([socket/0, option/0]).
|
||||
|
||||
-define(DEFAULT_TCP_OPTIONS, [binary, {packet, raw}, {active, false},
|
||||
{nodelay, true}, {reuseaddr, true}]).
|
||||
|
||||
|
|
|
@ -73,14 +73,14 @@
|
|||
%% Internal export
|
||||
-export([stats_fun/0]).
|
||||
|
||||
-export_type([attrs/0, stats/0]).
|
||||
|
||||
-type(chan_pid() :: pid()).
|
||||
|
||||
-opaque(attrs() :: #{atom() => term()}).
|
||||
|
||||
-opaque(stats() :: #{atom() => integer()}).
|
||||
|
||||
-export_type([attrs/0, stats/0]).
|
||||
|
||||
%% Tables for channel management.
|
||||
-define(CHAN_TAB, emqx_channel).
|
||||
|
||||
|
@ -164,7 +164,7 @@ get_conn_attrs(ClientId, ChanPid) ->
|
|||
|
||||
%% @doc Set conn attrs.
|
||||
-spec(set_conn_attrs(emqx_types:client_id(), attrs()) -> ok).
|
||||
set_conn_attrs(ClientId, Attrs) when is_map(Attrs) ->
|
||||
set_conn_attrs(ClientId, Attrs) when is_binary(ClientId), is_map(Attrs) ->
|
||||
Chan = {ClientId, self()},
|
||||
case ets:update_element(?CONN_TAB, Chan, {2, Attrs}) of
|
||||
true -> ok;
|
||||
|
|
|
@ -14,12 +14,14 @@
|
|||
%% limitations under the License.
|
||||
%%--------------------------------------------------------------------
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% @doc This module manages an opaque collection of statistics data used
|
||||
%% to force garbage collection on `self()' process when hitting thresholds.
|
||||
%% Namely:
|
||||
%% (1) Total number of messages passed through
|
||||
%% (2) Total data volume passed through
|
||||
%% @end
|
||||
%%--------------------------------------------------------------------
|
||||
|
||||
-module(emqx_gc).
|
||||
|
||||
|
@ -31,6 +33,8 @@
|
|||
, reset/1
|
||||
]).
|
||||
|
||||
-export_type([gc_state/0]).
|
||||
|
||||
-type(opts() :: #{count => integer(),
|
||||
bytes => integer()}).
|
||||
|
||||
|
@ -39,8 +43,6 @@
|
|||
|
||||
-opaque(gc_state() :: {?MODULE, st()}).
|
||||
|
||||
-export_type([gc_state/0]).
|
||||
|
||||
-define(GCS(St), {?MODULE, St}).
|
||||
|
||||
-define(disabled, disabled).
|
||||
|
|
|
@ -46,6 +46,11 @@
|
|||
, code_change/3
|
||||
]).
|
||||
|
||||
-export_type([ hookpoint/0
|
||||
, action/0
|
||||
, filter/0
|
||||
]).
|
||||
|
||||
%% Multiple callbacks can be registered on a hookpoint.
|
||||
%% The execution order depends on the priority value:
|
||||
%% - Callbacks with greater priority values will be run before
|
||||
|
@ -69,8 +74,6 @@
|
|||
callbacks :: list(#callback{})
|
||||
}).
|
||||
|
||||
-export_type([hookpoint/0, action/0, filter/0]).
|
||||
|
||||
-define(TAB, ?MODULE).
|
||||
-define(SERVER, ?MODULE).
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
, cancel/1
|
||||
]).
|
||||
|
||||
-export_type([keepalive/0]).
|
||||
|
||||
-record(keepalive, {
|
||||
statfun,
|
||||
statval,
|
||||
|
@ -33,8 +35,6 @@
|
|||
|
||||
-opaque(keepalive() :: #keepalive{}).
|
||||
|
||||
-export_type([keepalive/0]).
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% APIs
|
||||
%%--------------------------------------------------------------------
|
||||
|
|
|
@ -60,12 +60,12 @@
|
|||
, code_change/3
|
||||
]).
|
||||
|
||||
-export_type([metric_idx/0]).
|
||||
|
||||
-opaque(metric_idx() :: 1..1024).
|
||||
|
||||
-type(metric_name() :: atom() | string() | binary()).
|
||||
|
||||
-export_type([metric_idx/0]).
|
||||
|
||||
-define(MAX_SIZE, 1024).
|
||||
-define(RESERVED_IDX, 256).
|
||||
-define(TAB, ?MODULE).
|
||||
|
|
|
@ -27,10 +27,10 @@
|
|||
|
||||
-export([replvar/2]).
|
||||
|
||||
-type(mountpoint() :: binary()).
|
||||
|
||||
-export_type([mountpoint/0]).
|
||||
|
||||
-type(mountpoint() :: binary()).
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% APIs
|
||||
%%--------------------------------------------------------------------
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
, get_caps/2
|
||||
]).
|
||||
|
||||
-export_type([caps/0]).
|
||||
|
||||
-type(caps() :: #{max_packet_size => integer(),
|
||||
max_clientid_len => integer(),
|
||||
max_topic_alias => integer(),
|
||||
|
@ -35,9 +37,8 @@
|
|||
mqtt_shared_subscription => boolean(),
|
||||
mqtt_wildcard_subscription => boolean()}).
|
||||
|
||||
-export_type([caps/0]).
|
||||
|
||||
-define(UNLIMITED, 0).
|
||||
|
||||
-define(DEFAULT_CAPS, [{max_packet_size, ?MAX_PACKET_SIZE},
|
||||
{max_clientid_len, ?MAX_CLIENTID_LEN},
|
||||
{max_topic_alias, ?UNLIMITED},
|
||||
|
|
|
@ -32,9 +32,10 @@
|
|||
|
||||
-export([count/1]).
|
||||
|
||||
-type(pmon() :: {?MODULE, map()}).
|
||||
-export_type([pmon/0]).
|
||||
|
||||
-opaque(pmon() :: {?MODULE, map()}).
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% APIs
|
||||
%%--------------------------------------------------------------------
|
||||
|
|
|
@ -57,6 +57,8 @@
|
|||
, highest/1
|
||||
]).
|
||||
|
||||
-export_type([q/0]).
|
||||
|
||||
%%----------------------------------------------------------------------------
|
||||
|
||||
-type(priority() :: integer() | 'infinity').
|
||||
|
@ -64,8 +66,6 @@
|
|||
-type(pqueue() :: squeue() | {pqueue, [{priority(), squeue()}]}).
|
||||
-type(q() :: pqueue()).
|
||||
|
||||
-export_type([q/0]).
|
||||
|
||||
%%----------------------------------------------------------------------------
|
||||
|
||||
-spec(new() -> pqueue()).
|
||||
|
|
|
@ -23,14 +23,14 @@
|
|||
, delete/1
|
||||
]).
|
||||
|
||||
-export_type([seqid/0]).
|
||||
|
||||
-type(key() :: term()).
|
||||
|
||||
-type(name() :: atom()).
|
||||
|
||||
-type(seqid() :: non_neg_integer()).
|
||||
|
||||
-export_type([seqid/0]).
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
%% APIs
|
||||
%%--------------------------------------------------------------------
|
||||
|
|
|
@ -51,18 +51,18 @@
|
|||
, code_change/3
|
||||
]).
|
||||
|
||||
-export_type([stats/0]).
|
||||
|
||||
-record(update, {name, countdown, interval, func}).
|
||||
|
||||
-record(state, {
|
||||
timer :: reference(),
|
||||
timer :: reference(),
|
||||
updates :: [#update{}],
|
||||
tick_ms :: timeout()
|
||||
}).
|
||||
|
||||
-type(stats() :: list({atom(), non_neg_integer()})).
|
||||
|
||||
-export_type([stats/0]).
|
||||
|
||||
%% Connection stats
|
||||
-define(CONNECTION_STATS, [
|
||||
'connections.count', % current connections
|
||||
|
|
|
@ -35,14 +35,18 @@
|
|||
, parse/2
|
||||
]).
|
||||
|
||||
-export_type([ group/0
|
||||
, topic/0
|
||||
, word/0
|
||||
, triple/0
|
||||
]).
|
||||
|
||||
-type(group() :: binary()).
|
||||
-type(topic() :: binary()).
|
||||
-type(word() :: '' | '+' | '#' | binary()).
|
||||
-type(words() :: list(word())).
|
||||
-opaque(triple() :: {root | binary(), word(), binary()}).
|
||||
|
||||
-export_type([group/0, topic/0, word/0, triple/0]).
|
||||
|
||||
-define(MAX_TOPIC_LEN, 4096).
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
|
@ -232,3 +236,4 @@ parse(Topic, Options = #{qos := QoS}) ->
|
|||
{Topic, Options#{rc => QoS}};
|
||||
parse(Topic, Options) ->
|
||||
{Topic, Options}.
|
||||
|
||||
|
|
|
@ -45,9 +45,13 @@
|
|||
, code_change/3
|
||||
]).
|
||||
|
||||
-export_type([zone/0]).
|
||||
|
||||
%% dummy state
|
||||
-record(state, {}).
|
||||
|
||||
-type(zone() :: atom()).
|
||||
|
||||
-define(TAB, ?MODULE).
|
||||
-define(SERVER, ?MODULE).
|
||||
-define(KEY(Zone, Key), {?MODULE, Zone, Key}).
|
||||
|
@ -60,13 +64,13 @@
|
|||
start_link() ->
|
||||
gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).
|
||||
|
||||
-spec(get_env(maybe(emqx_types:zone()), atom()) -> maybe(term())).
|
||||
-spec(get_env(maybe(zone()), atom()) -> maybe(term())).
|
||||
get_env(undefined, Key) ->
|
||||
emqx_config:get_env(Key);
|
||||
get_env(Zone, Key) ->
|
||||
get_env(Zone, Key, undefined).
|
||||
|
||||
-spec(get_env(maybe(emqx_types:zone()), atom(), term()) -> maybe(term())).
|
||||
-spec(get_env(maybe(zone()), atom(), term()) -> maybe(term())).
|
||||
get_env(undefined, Key, Def) ->
|
||||
emqx_config:get_env(Key, Def);
|
||||
get_env(Zone, Key, Def) ->
|
||||
|
@ -75,7 +79,7 @@ get_env(Zone, Key, Def) ->
|
|||
emqx_config:get_env(Key, Def)
|
||||
end.
|
||||
|
||||
-spec(set_env(emqx_types:zone(), atom(), term()) -> ok).
|
||||
-spec(set_env(zone(), atom(), term()) -> ok).
|
||||
set_env(Zone, Key, Val) ->
|
||||
gen_server:cast(?SERVER, {set_env, Zone, Key, Val}).
|
||||
|
||||
|
|
Loading…
Reference in New Issue