|
|
@@ -1,30 +1,28 @@
|
|
|
-%%%===================================================================
|
|
|
-%%% Copyright (c) 2013-2018 EMQ Inc. All rights reserved.
|
|
|
-%%%
|
|
|
-%%% Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
-%%% you may not use this file except in compliance with the License.
|
|
|
-%%% You may obtain a copy of the License at
|
|
|
-%%%
|
|
|
-%%% http://www.apache.org/licenses/LICENSE-2.0
|
|
|
-%%%
|
|
|
-%%% Unless required by applicable law or agreed to in writing, software
|
|
|
-%%% distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
-%%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
-%%% See the License for the specific language governing permissions and
|
|
|
-%%% limitations under the License.
|
|
|
-%%%===================================================================
|
|
|
+%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
|
|
+%%
|
|
|
+%% Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
+%% you may not use this file except in compliance with the License.
|
|
|
+%% You may obtain a copy of the License at
|
|
|
+%%
|
|
|
+%% http://www.apache.org/licenses/LICENSE-2.0
|
|
|
+%%
|
|
|
+%% Unless required by applicable law or agreed to in writing, software
|
|
|
+%% distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
+%% See the License for the specific language governing permissions and
|
|
|
+%% limitations under the License.
|
|
|
|
|
|
%%--------------------------------------------------------------------
|
|
|
%% Banner
|
|
|
%%--------------------------------------------------------------------
|
|
|
|
|
|
--define(COPYRIGHT, "Copyright (c) 2013-2018 EMQ Inc.").
|
|
|
+-define(COPYRIGHT, "Copyright (c) 2018 EMQ Technologies Co., Ltd").
|
|
|
|
|
|
-define(LICENSE_MESSAGE, "Licensed under the Apache License, Version 2.0").
|
|
|
|
|
|
-define(PROTOCOL_VERSION, "MQTT/5.0").
|
|
|
|
|
|
--define(ERTS_MINIMUM_REQUIRED, "9.2").
|
|
|
+-define(ERTS_MINIMUM_REQUIRED, "10.0").
|
|
|
|
|
|
%%--------------------------------------------------------------------
|
|
|
%% Topics' prefix: $SYS | $queue | $share
|
|
|
@@ -52,11 +50,9 @@
|
|
|
| {share, binary()}
|
|
|
| {atom(), term()}).
|
|
|
|
|
|
--record(subscription,
|
|
|
- { subid :: binary() | atom(),
|
|
|
- topic :: topic(),
|
|
|
- subopts :: list(suboption())
|
|
|
- }).
|
|
|
+-record(subscription, {subid :: binary() | atom(),
|
|
|
+ topic :: topic(),
|
|
|
+ subopts :: list(suboption())}).
|
|
|
|
|
|
-type(subscription() :: #subscription{}).
|
|
|
|
|
|
@@ -76,29 +72,20 @@
|
|
|
|
|
|
-type(mountpoint() :: binary()).
|
|
|
|
|
|
--type(connector() :: atom()).
|
|
|
-
|
|
|
--type(zone() :: atom()).
|
|
|
-
|
|
|
--record(client,
|
|
|
- { client_id :: client_id(),
|
|
|
- client_pid :: pid(),
|
|
|
- zone :: zone(),
|
|
|
- node :: node(),
|
|
|
- username :: username(),
|
|
|
- peername :: peername(),
|
|
|
- protocol :: protocol(),
|
|
|
- connector :: connector(),
|
|
|
- mountpoint :: mountpoint(),
|
|
|
- attributes :: #{atom() => term()}
|
|
|
- }).
|
|
|
+-type(zone() :: undefined | atom()).
|
|
|
+
|
|
|
+-record(client, {id :: client_id(),
|
|
|
+ pid :: pid(),
|
|
|
+ zone :: zone(),
|
|
|
+ peername :: peername(),
|
|
|
+ username :: username(),
|
|
|
+ protocol :: protocol(),
|
|
|
+ attributes :: #{atom() => term()},
|
|
|
+ connected_at :: erlang:timestamp()}).
|
|
|
|
|
|
-type(client() :: #client{}).
|
|
|
|
|
|
--record(session,
|
|
|
- { sid :: client_id(),
|
|
|
- pid :: pid()
|
|
|
- }).
|
|
|
+-record(session, {sid :: client_id(), pid :: pid()}).
|
|
|
|
|
|
-type(session() :: #session{}).
|
|
|
|
|
|
@@ -108,11 +95,12 @@
|
|
|
|
|
|
-type(message_id() :: binary() | undefined).
|
|
|
|
|
|
--type(message_flag() :: sys | dup | retain | atom()).
|
|
|
+-type(message_flag() :: sys | qos | dup | retain | atom()).
|
|
|
|
|
|
--type(message_flags() :: #{message_flag() => boolean()}).
|
|
|
+-type(message_flags() :: #{message_flag() => boolean() | integer()}).
|
|
|
|
|
|
--type(message_headers() :: #{packet_id => pos_integer(),
|
|
|
+-type(message_headers() :: #{protocol => protocol(),
|
|
|
+ packet_id => pos_integer(),
|
|
|
priority => non_neg_integer(),
|
|
|
ttl => pos_integer(),
|
|
|
atom() => term()}).
|
|
|
@@ -121,13 +109,13 @@
|
|
|
|
|
|
%% See 'Application Message' in MQTT Version 5.0
|
|
|
-record(message,
|
|
|
- { id :: message_id(), %% Global unique id
|
|
|
- qos :: qos(), %% Message QoS
|
|
|
+ { id :: message_id(), %% Message guid
|
|
|
+ qos :: qos(), %% Message qos
|
|
|
from :: atom() | client(), %% Message from
|
|
|
sender :: pid(), %% The pid of the sender/publisher
|
|
|
flags :: message_flags(), %% Message flags
|
|
|
headers :: message_headers(), %% Message headers
|
|
|
- topic :: binary(), %% Message topic
|
|
|
+ topic :: topic(), %% Message topic
|
|
|
properties :: map(), %% Message user properties
|
|
|
payload :: payload(), %% Message payload
|
|
|
timestamp :: erlang:timestamp() %% Timestamp
|
|
|
@@ -136,8 +124,9 @@
|
|
|
-type(message() :: #message{}).
|
|
|
|
|
|
-record(delivery,
|
|
|
- { message :: message(),
|
|
|
- flows :: list()
|
|
|
+ { node :: node(), %% The node that created the delivery
|
|
|
+ message :: message(), %% The message delivered
|
|
|
+ flows :: list() %% The message flow path
|
|
|
}).
|
|
|
|
|
|
-type(delivery() :: #delivery{}).
|
|
|
@@ -219,12 +208,12 @@
|
|
|
%%--------------------------------------------------------------------
|
|
|
|
|
|
-record(command,
|
|
|
- { name,
|
|
|
- action,
|
|
|
- args = [],
|
|
|
- opts = [],
|
|
|
- usage,
|
|
|
- descr
|
|
|
+ { name :: atom(),
|
|
|
+ action :: atom(),
|
|
|
+ args = [] :: list(),
|
|
|
+ opts = [] :: list(),
|
|
|
+ usage :: string(),
|
|
|
+ descr :: string()
|
|
|
}).
|
|
|
|
|
|
-type(command() :: #command{}).
|