Merge branch 'develop'
This commit is contained in:
commit
ee9f278738
23
Makefile
23
Makefile
|
@ -113,26 +113,3 @@ rebar-clean:
|
||||||
distclean::
|
distclean::
|
||||||
@rm -rf _build cover deps logs log data
|
@rm -rf _build cover deps logs log data
|
||||||
@rm -f rebar.lock compile_commands.json cuttlefish
|
@rm -f rebar.lock compile_commands.json cuttlefish
|
||||||
|
|
||||||
## Below are for version consistency check during erlang.mk and rebar3 dual mode support
|
|
||||||
none=
|
|
||||||
space = $(none) $(none)
|
|
||||||
comma = ,
|
|
||||||
quote = \"
|
|
||||||
curly_l = "{"
|
|
||||||
curly_r = "}"
|
|
||||||
dep-versions = [$(foreach dep,$(DEPS) $(BUILD_DEPS),$(curly_l)$(dep),$(quote)$(word $(words $(dep_$(dep))),$(dep_$(dep)))$(quote)$(curly_r)$(comma))[]]
|
|
||||||
|
|
||||||
.PHONY: dep-vsn-check
|
|
||||||
dep-vsn-check:
|
|
||||||
$(verbose) erl -noshell -eval \
|
|
||||||
"MkVsns = lists:sort(lists:flatten($(dep-versions))), \
|
|
||||||
{ok, Conf} = file:consult('rebar.config'), \
|
|
||||||
{_, Deps1} = lists:keyfind(deps, 1, Conf), \
|
|
||||||
{_, Deps2} = lists:keyfind(github_emqx_deps, 1, Conf), \
|
|
||||||
F = fun({N, V}) when is_list(V) -> {N, V}; ({N, {git, _, {branch, V}}}) -> {N, V} end, \
|
|
||||||
RebarVsns = lists:sort(lists:map(F, Deps1 ++ Deps2)), \
|
|
||||||
case {RebarVsns -- MkVsns, MkVsns -- RebarVsns} of \
|
|
||||||
{[], []} -> halt(0); \
|
|
||||||
{Rebar, Mk} -> erlang:error({deps_version_discrepancy, [{rebar, Rebar}, {mk, Mk}]}) \
|
|
||||||
end."
|
|
||||||
|
|
|
@ -286,32 +286,32 @@ rpc.tcp_client_port = 5369
|
||||||
## RCP Client connect timeout.
|
## RCP Client connect timeout.
|
||||||
##
|
##
|
||||||
## Value: Seconds
|
## Value: Seconds
|
||||||
rpc.connect_timeout = 5000
|
rpc.connect_timeout = 5s
|
||||||
|
|
||||||
## TCP send timeout of RPC client and server.
|
## TCP send timeout of RPC client and server.
|
||||||
##
|
##
|
||||||
## Value: Seconds
|
## Value: Seconds
|
||||||
rpc.send_timeout = 5000
|
rpc.send_timeout = 5s
|
||||||
|
|
||||||
## Authentication timeout
|
## Authentication timeout
|
||||||
##
|
##
|
||||||
## Value: Seconds
|
## Value: Seconds
|
||||||
rpc.authentication_timeout = 5000
|
rpc.authentication_timeout = 5s
|
||||||
|
|
||||||
## Default receive timeout for call() functions
|
## Default receive timeout for call() functions
|
||||||
##
|
##
|
||||||
## Value: Seconds
|
## Value: Seconds
|
||||||
rpc.call_receive_timeout = 15000
|
rpc.call_receive_timeout = 15s
|
||||||
|
|
||||||
## Socket idle keepalive.
|
## Socket idle keepalive.
|
||||||
##
|
##
|
||||||
## Value: Seconds
|
## Value: Seconds
|
||||||
rpc.socket_keepalive_idle = 900
|
rpc.socket_keepalive_idle = 900s
|
||||||
|
|
||||||
## TCP Keepalive probes interval.
|
## TCP Keepalive probes interval.
|
||||||
##
|
##
|
||||||
## Value: Integer
|
## Value: Seconds
|
||||||
rpc.socket_keepalive_interval = 75
|
rpc.socket_keepalive_interval = 75s
|
||||||
|
|
||||||
## Probes lost to close the connection
|
## Probes lost to close the connection
|
||||||
##
|
##
|
||||||
|
@ -947,7 +947,7 @@ listener.tcp.internal.send_timeout = 5s
|
||||||
## See: listener.tcp.$name.send_timeout_close
|
## See: listener.tcp.$name.send_timeout_close
|
||||||
##
|
##
|
||||||
## Value: on | off
|
## Value: on | off
|
||||||
listener.tcp.external.send_timeout_close = on
|
listener.tcp.internal.send_timeout_close = on
|
||||||
|
|
||||||
## The TCP receive buffer(os kernel) for internal MQTT connections.
|
## The TCP receive buffer(os kernel) for internal MQTT connections.
|
||||||
##
|
##
|
||||||
|
@ -1596,29 +1596,29 @@ listener.wss.external.ciphers = ECDHE-ECDSA-AES256-GCM-SHA384,ECDHE-RSA-AES256-G
|
||||||
## Value: enum
|
## Value: enum
|
||||||
## manual
|
## manual
|
||||||
## auto
|
## auto
|
||||||
bridge.aws.start_type = manual
|
## bridge.aws.start_type = manual
|
||||||
|
|
||||||
## Bridge reconnect time.
|
## Bridge reconnect time.
|
||||||
##
|
##
|
||||||
## Value: Duration
|
## Value: Duration
|
||||||
## Default: 30 seconds
|
## Default: 30 seconds
|
||||||
bridge.aws.reconnect_interval = 30s
|
## bridge.aws.reconnect_interval = 30s
|
||||||
|
|
||||||
## Retry interval for bridge QoS1 message delivering.
|
## Retry interval for bridge QoS1 message delivering.
|
||||||
##
|
##
|
||||||
## Value: Duration
|
## Value: Duration
|
||||||
bridge.aws.retry_interval = 20s
|
## bridge.aws.retry_interval = 20s
|
||||||
|
|
||||||
## Inflight size.
|
## Inflight size.
|
||||||
##
|
##
|
||||||
## Value: Integer
|
## Value: Integer
|
||||||
bridge.aws.max_inflight = 32
|
## bridge.aws.max_inflight = 32
|
||||||
|
|
||||||
## Bridge address: node name for local bridge, host:port for remote.
|
## Bridge address: node name for local bridge, host:port for remote.
|
||||||
##
|
##
|
||||||
## Value: String
|
## Value: String
|
||||||
## Example: emqx@127.0.0.1, 127.0.0.1:1883
|
## Example: emqx@127.0.0.1, 127.0.0.1:1883
|
||||||
bridge.aws.address = 127.0.0.1:1883
|
## bridge.aws.address = 127.0.0.1:1883
|
||||||
|
|
||||||
## Protocol version of the bridge.
|
## Protocol version of the bridge.
|
||||||
##
|
##
|
||||||
|
@ -1626,12 +1626,12 @@ bridge.aws.address = 127.0.0.1:1883
|
||||||
## - mqttv5
|
## - mqttv5
|
||||||
## - mqttv4
|
## - mqttv4
|
||||||
## - mqttv3
|
## - mqttv3
|
||||||
bridge.aws.proto_ver = mqttv4
|
## bridge.aws.proto_ver = mqttv4
|
||||||
|
|
||||||
## The ClientId of a remote bridge.
|
## The ClientId of a remote bridge.
|
||||||
##
|
##
|
||||||
## Value: String
|
## Value: String
|
||||||
bridge.aws.client_id = bridge_aws
|
## bridge.aws.client_id = bridge_aws
|
||||||
|
|
||||||
## The Clean start flag of a remote bridge.
|
## The Clean start flag of a remote bridge.
|
||||||
##
|
##
|
||||||
|
@ -1645,62 +1645,62 @@ bridge.aws.client_id = bridge_aws
|
||||||
## The username for a remote bridge.
|
## The username for a remote bridge.
|
||||||
##
|
##
|
||||||
## Value: String
|
## Value: String
|
||||||
bridge.aws.username = user
|
## bridge.aws.username = user
|
||||||
|
|
||||||
## The password for a remote bridge.
|
## The password for a remote bridge.
|
||||||
##
|
##
|
||||||
## Value: String
|
## Value: String
|
||||||
bridge.aws.password = passwd
|
## bridge.aws.password = passwd
|
||||||
|
|
||||||
## Mountpoint of the bridge.
|
## Mountpoint of the bridge.
|
||||||
##
|
##
|
||||||
## Value: String
|
## Value: String
|
||||||
bridge.aws.mountpoint = bridge/aws/${node}/
|
## bridge.aws.mountpoint = bridge/aws/${node}/
|
||||||
|
|
||||||
## Ping interval of a down bridge.
|
## Ping interval of a down bridge.
|
||||||
##
|
##
|
||||||
## Value: Duration
|
## Value: Duration
|
||||||
## Default: 10 seconds
|
## Default: 10 seconds
|
||||||
bridge.aws.keepalive = 60s
|
## bridge.aws.keepalive = 60s
|
||||||
|
|
||||||
## Forward message topics
|
## Forward message topics
|
||||||
##
|
##
|
||||||
## Value: String
|
## Value: String
|
||||||
## Example: topic1/#,topic2/#
|
## Example: topic1/#,topic2/#
|
||||||
bridge.aws.forwards = topic1/#,topic2/#
|
## bridge.aws.forwards = topic1/#,topic2/#
|
||||||
|
|
||||||
## Subscriptions of the bridge topic.
|
## Subscriptions of the bridge topic.
|
||||||
##
|
##
|
||||||
## Value: String
|
## Value: String
|
||||||
bridge.aws.subscription.1.topic = cmd/topic1
|
## bridge.aws.subscription.1.topic = cmd/topic1
|
||||||
|
|
||||||
## Subscriptions of the bridge qos.
|
## Subscriptions of the bridge qos.
|
||||||
##
|
##
|
||||||
## Value: Number
|
## Value: Number
|
||||||
bridge.aws.subscription.1.qos = 1
|
## bridge.aws.subscription.1.qos = 1
|
||||||
|
|
||||||
## Subscriptions of the bridge topic.
|
## Subscriptions of the bridge topic.
|
||||||
##
|
##
|
||||||
## Value: String
|
## Value: String
|
||||||
bridge.aws.subscription.2.topic = cmd/topic2
|
## bridge.aws.subscription.2.topic = cmd/topic2
|
||||||
|
|
||||||
## Subscriptions of the bridge qos.
|
## Subscriptions of the bridge qos.
|
||||||
##
|
##
|
||||||
## Value: Number
|
## Value: Number
|
||||||
bridge.aws.subscription.2.qos = 1
|
## bridge.aws.subscription.2.qos = 1
|
||||||
|
|
||||||
## If enabled, queue would be written into disk more quickly.
|
## If enabled, queue would be written into disk more quickly.
|
||||||
## However, If disabled, some message would be dropped in
|
## However, If disabled, some message would be dropped in
|
||||||
## the situation emqx crashed.
|
## the situation emqx crashed.
|
||||||
##
|
##
|
||||||
## Value: on | off
|
## Value: on | off
|
||||||
bridge.aws.queue.mem_cache = on
|
## bridge.aws.queue.mem_cache = on
|
||||||
|
|
||||||
## Batch size for buffer queue stored
|
## Batch size for buffer queue stored
|
||||||
##
|
##
|
||||||
## Value: Integer
|
## Value: Integer
|
||||||
## default: 1000
|
## default: 1000
|
||||||
bridge.aws.queue.batch_size = 1000
|
## bridge.aws.queue.batch_size = 1000
|
||||||
|
|
||||||
## Base directory for replayq to store messages on disk
|
## Base directory for replayq to store messages on disk
|
||||||
## If this config entry is missing or set to undefined,
|
## If this config entry is missing or set to undefined,
|
||||||
|
@ -1709,18 +1709,18 @@ bridge.aws.queue.batch_size = 1000
|
||||||
## this config entry would have no effect on mqueue
|
## this config entry would have no effect on mqueue
|
||||||
##
|
##
|
||||||
## Value: String
|
## Value: String
|
||||||
bridge.aws.queue.replayq_dir = {{ platform_data_dir }}/emqx_aws_bridge/
|
## bridge.aws.queue.replayq_dir = {{ platform_data_dir }}/emqx_aws_bridge/
|
||||||
|
|
||||||
## Replayq segment size
|
## Replayq segment size
|
||||||
##
|
##
|
||||||
## Value: Bytesize
|
## Value: Bytesize
|
||||||
|
|
||||||
bridge.aws.queue.replayq_seg_bytes = 10MB
|
## bridge.aws.queue.replayq_seg_bytes = 10MB
|
||||||
|
|
||||||
## Bribge to remote server via SSL.
|
## Bribge to remote server via SSL.
|
||||||
##
|
##
|
||||||
## Value: on | off
|
## Value: on | off
|
||||||
bridge.aws.ssl = off
|
## bridge.aws.ssl = off
|
||||||
|
|
||||||
## PEM-encoded CA certificates of the bridge.
|
## PEM-encoded CA certificates of the bridge.
|
||||||
##
|
##
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
%% Banner
|
%% Banner
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
-define(COPYRIGHT, "Copyright (c) 2018 EMQ Technologies Co., Ltd").
|
-define(COPYRIGHT, "Copyright (c) 2013-2019 EMQ Technologies Co., Ltd").
|
||||||
|
|
||||||
-define(LICENSE_MESSAGE, "Licensed under the Apache License, Version 2.0").
|
-define(LICENSE_MESSAGE, "Licensed under the Apache License, Version 2.0").
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
-define(NOTICE(Format, Args), ?LOG(notice, Format, Args)).
|
-define(NOTICE(Format, Args), ?LOG(notice, Format, Args)).
|
||||||
|
|
||||||
-define(WARN(Format), ?LOG(warning, Format, [])).
|
-define(WARN(Format), ?LOG(warning, Format, [])).
|
||||||
-define(WARN(Format, Args), ?LOG(warning, Format, [])).
|
-define(WARN(Format, Args), ?LOG(warning, Format, Args)).
|
||||||
|
|
||||||
-define(ERROR(Format), ?LOG(error, Format, [])).
|
-define(ERROR(Format), ?LOG(error, Format, [])).
|
||||||
-define(ERROR(Format, Args), ?LOG(error, Format, Args)).
|
-define(ERROR(Format, Args), ?LOG(error, Format, Args)).
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
%% Copyright (c) 2013-2019 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.
|
||||||
|
|
||||||
|
-type(maybe(T) :: undefined | T).
|
||||||
|
|
||||||
|
-type(startlink_ret() :: {ok, pid()} | ignore | {error, term()}).
|
||||||
|
|
||||||
|
-type(ok_or_error(Reason) :: ok | {error, Reason}).
|
||||||
|
|
||||||
|
-type(ok_or_error(Value, Reason) :: {ok, Value} | {error, Reason}).
|
||||||
|
|
|
@ -324,38 +324,38 @@ end}.
|
||||||
|
|
||||||
%% Client connect timeout
|
%% Client connect timeout
|
||||||
{mapping, "rpc.connect_timeout", "gen_rpc.connect_timeout", [
|
{mapping, "rpc.connect_timeout", "gen_rpc.connect_timeout", [
|
||||||
{default, 5000},
|
{default, "5s"},
|
||||||
{datatype, integer}
|
{datatype, {duration, ms}}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
%% Client and Server send timeout
|
%% Client and Server send timeout
|
||||||
{mapping, "rpc.send_timeout", "gen_rpc.send_timeout", [
|
{mapping, "rpc.send_timeout", "gen_rpc.send_timeout", [
|
||||||
{default, 5000},
|
{default, 5000},
|
||||||
{datatype, integer}
|
{datatype, {duration, ms}}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
%% Authentication timeout
|
%% Authentication timeout
|
||||||
{mapping, "rpc.authentication_timeout", "gen_rpc.authentication_timeout", [
|
{mapping, "rpc.authentication_timeout", "gen_rpc.authentication_timeout", [
|
||||||
{default, 5000},
|
{default, 5000},
|
||||||
{datatype, integer}
|
{datatype, {duration, ms}}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
%% Default receive timeout for call() functions
|
%% Default receive timeout for call() functions
|
||||||
{mapping, "rpc.call_receive_timeout", "gen_rpc.call_receive_timeout", [
|
{mapping, "rpc.call_receive_timeout", "gen_rpc.call_receive_timeout", [
|
||||||
{default, 15000},
|
{default, 15000},
|
||||||
{datatype, integer}
|
{datatype, {duration, ms}}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
%% Socket keepalive configuration
|
%% Socket keepalive configuration
|
||||||
{mapping, "rpc.socket_keepalive_idle", "gen_rpc.socket_keepalive_idle", [
|
{mapping, "rpc.socket_keepalive_idle", "gen_rpc.socket_keepalive_idle", [
|
||||||
{default, 7200},
|
{default, 7200},
|
||||||
{datatype, integer}
|
{datatype, {duration, s}}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
%% Seconds between probes
|
%% Seconds between probes
|
||||||
{mapping, "rpc.socket_keepalive_interval", "gen_rpc.socket_keepalive_interval", [
|
{mapping, "rpc.socket_keepalive_interval", "gen_rpc.socket_keepalive_interval", [
|
||||||
{default, 75},
|
{default, 75},
|
||||||
{datatype, integer}
|
{datatype, {duration, s}}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
%% Probes lost to close the connection
|
%% Probes lost to close the connection
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
CONFIG0 = case os:getenv("REBAR_GIT_CLONE_OPTIONS") of
|
CONFIG0 = case os:getenv("REBAR_GIT_CLONE_OPTIONS") of
|
||||||
"--depth 1" ->
|
"--depth 1" ->
|
||||||
CONFIG;
|
CONFIG;
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
{vsn,"git"},
|
{vsn,"git"},
|
||||||
{modules,[]},
|
{modules,[]},
|
||||||
{registered,[emqx_sup]},
|
{registered,[emqx_sup]},
|
||||||
{applications,[kernel,stdlib,jsx,gproc,gen_rpc,esockd,cowboy,replayq]},
|
{applications,[kernel,stdlib,jsx,gproc,gen_rpc,esockd,cowboy,
|
||||||
|
replayq]},
|
||||||
{env,[]},
|
{env,[]},
|
||||||
{mod,{emqx_app,[]}},
|
{mod,{emqx_app,[]}},
|
||||||
{maintainers,["Feng Lee <feng@emqx.io>"]},
|
{maintainers,["Feng Lee <feng@emqx.io>"]},
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -15,6 +15,7 @@
|
||||||
-module(emqx).
|
-module(emqx).
|
||||||
|
|
||||||
-include("emqx.hrl").
|
-include("emqx.hrl").
|
||||||
|
-include("types.hrl").
|
||||||
|
|
||||||
%% Start/Stop the application
|
%% Start/Stop the application
|
||||||
-export([start/0, restart/1, is_running/1, stop/0]).
|
-export([start/0, restart/1, is_running/1, stop/0]).
|
||||||
|
@ -167,6 +168,7 @@ reboot() ->
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
%% Internal functions
|
%% Internal functions
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
|
|
||||||
reload_config(ConfFile) ->
|
reload_config(ConfFile) ->
|
||||||
{ok, [Conf]} = file:consult(ConfFile),
|
{ok, [Conf]} = file:consult(ConfFile),
|
||||||
lists:foreach(fun({App, Vals}) ->
|
lists:foreach(fun({App, Vals}) ->
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
-include("emqx.hrl").
|
-include("emqx.hrl").
|
||||||
-include("logger.hrl").
|
-include("logger.hrl").
|
||||||
|
-include("types.hrl").
|
||||||
|
|
||||||
%% Mnesia bootstrap
|
%% Mnesia bootstrap
|
||||||
-export([mnesia/1]).
|
-export([mnesia/1]).
|
||||||
|
@ -50,7 +51,7 @@ mnesia(copy) ->
|
||||||
ok = ekka_mnesia:copy_table(?TAB).
|
ok = ekka_mnesia:copy_table(?TAB).
|
||||||
|
|
||||||
%% @doc Start the banned server.
|
%% @doc Start the banned server.
|
||||||
-spec(start_link() -> emqx_types:startlink_ret()).
|
-spec(start_link() -> startlink_ret()).
|
||||||
start_link() ->
|
start_link() ->
|
||||||
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
|
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
-include("emqx.hrl").
|
-include("emqx.hrl").
|
||||||
-include("logger.hrl").
|
-include("logger.hrl").
|
||||||
|
-include("types.hrl").
|
||||||
|
|
||||||
-export([start_link/2]).
|
-export([start_link/2]).
|
||||||
-export([subscribe/1, subscribe/2, subscribe/3]).
|
-export([subscribe/1, subscribe/2, subscribe/3]).
|
||||||
|
@ -53,7 +54,7 @@
|
||||||
%% Guards
|
%% Guards
|
||||||
-define(is_subid(Id), (is_binary(Id) orelse is_atom(Id))).
|
-define(is_subid(Id), (is_binary(Id) orelse is_atom(Id))).
|
||||||
|
|
||||||
-spec(start_link(atom(), pos_integer()) -> emqx_types:startlink_ret()).
|
-spec(start_link(atom(), pos_integer()) -> startlink_ret()).
|
||||||
start_link(Pool, Id) ->
|
start_link(Pool, Id) ->
|
||||||
ok = create_tabs(),
|
ok = create_tabs(),
|
||||||
gen_server:start_link({local, emqx_misc:proc_name(?BROKER, Id)},
|
gen_server:start_link({local, emqx_misc:proc_name(?BROKER, Id)},
|
||||||
|
@ -322,7 +323,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, {SubPid, Topic}).
|
ets:member(?SUBOPTION, {SubPid, Topic}).
|
||||||
|
|
||||||
-spec(get_subopts(pid(), emqx_topic:topic()) -> emqx_types:subopts() | undefined).
|
-spec(get_subopts(pid(), emqx_topic:topic()) -> maybe(emqx_types:subopts())).
|
||||||
get_subopts(SubPid, Topic) when is_pid(SubPid), is_binary(Topic) ->
|
get_subopts(SubPid, Topic) when is_pid(SubPid), is_binary(Topic) ->
|
||||||
lookup_value(?SUBOPTION, {SubPid, Topic});
|
lookup_value(?SUBOPTION, {SubPid, Topic});
|
||||||
get_subopts(SubId, Topic) when ?is_subid(SubId) ->
|
get_subopts(SubId, Topic) when ?is_subid(SubId) ->
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -17,6 +17,7 @@
|
||||||
-behaviour(gen_server).
|
-behaviour(gen_server).
|
||||||
|
|
||||||
-include("logger.hrl").
|
-include("logger.hrl").
|
||||||
|
-include("types.hrl").
|
||||||
|
|
||||||
-export([start_link/0]).
|
-export([start_link/0]).
|
||||||
-export([register_sub/2]).
|
-export([register_sub/2]).
|
||||||
|
@ -35,7 +36,7 @@
|
||||||
|
|
||||||
-define(BATCH_SIZE, 100000).
|
-define(BATCH_SIZE, 100000).
|
||||||
|
|
||||||
-spec(start_link() -> emqx_types:startlink_ret()).
|
-spec(start_link() -> startlink_ret()).
|
||||||
start_link() ->
|
start_link() ->
|
||||||
gen_server:start_link({local, ?HELPER}, ?MODULE, [], []).
|
gen_server:start_link({local, ?HELPER}, ?MODULE, [], []).
|
||||||
|
|
||||||
|
@ -50,7 +51,7 @@ register_sub(SubPid, SubId) when is_pid(SubPid) ->
|
||||||
error(subid_conflict)
|
error(subid_conflict)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec(lookup_subid(pid()) -> emqx_types:subid() | undefined).
|
-spec(lookup_subid(pid()) -> maybe(emqx_types:subid())).
|
||||||
lookup_subid(SubPid) when is_pid(SubPid) ->
|
lookup_subid(SubPid) when is_pid(SubPid) ->
|
||||||
emqx_tables:lookup_value(?SUBMON, SubPid).
|
emqx_tables:lookup_value(?SUBMON, SubPid).
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
-behaviour(gen_statem).
|
-behaviour(gen_statem).
|
||||||
|
|
||||||
|
-include("types.hrl").
|
||||||
-include("emqx_mqtt.hrl").
|
-include("emqx_mqtt.hrl").
|
||||||
|
|
||||||
-export([start_link/0, start_link/1]).
|
-export([start_link/0, start_link/1]).
|
||||||
|
@ -112,12 +113,12 @@
|
||||||
bridge_mode :: boolean(),
|
bridge_mode :: boolean(),
|
||||||
client_id :: binary(),
|
client_id :: binary(),
|
||||||
clean_start :: boolean(),
|
clean_start :: boolean(),
|
||||||
username :: binary() | undefined,
|
username :: maybe(binary()),
|
||||||
password :: binary() | undefined,
|
password :: maybe(binary()),
|
||||||
proto_ver :: emqx_mqtt_types:version(),
|
proto_ver :: emqx_mqtt_types:version(),
|
||||||
proto_name :: iodata(),
|
proto_name :: iodata(),
|
||||||
keepalive :: non_neg_integer(),
|
keepalive :: non_neg_integer(),
|
||||||
keepalive_timer :: reference() | undefined,
|
keepalive_timer :: maybe(reference()),
|
||||||
force_ping :: boolean(),
|
force_ping :: boolean(),
|
||||||
paused :: boolean(),
|
paused :: boolean(),
|
||||||
will_flag :: boolean(),
|
will_flag :: boolean(),
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
-include("emqx.hrl").
|
-include("emqx.hrl").
|
||||||
-include("logger.hrl").
|
-include("logger.hrl").
|
||||||
|
-include("types.hrl").
|
||||||
|
|
||||||
-export([start_link/0]).
|
-export([start_link/0]).
|
||||||
|
|
||||||
|
@ -46,7 +47,7 @@
|
||||||
-define(BATCH_SIZE, 100000).
|
-define(BATCH_SIZE, 100000).
|
||||||
|
|
||||||
%% @doc Start the connection manager.
|
%% @doc Start the connection manager.
|
||||||
-spec(start_link() -> emqx_types:startlink_ret()).
|
-spec(start_link() -> startlink_ret()).
|
||||||
start_link() ->
|
start_link() ->
|
||||||
gen_server:start_link({local, ?CM}, ?MODULE, [], []).
|
gen_server:start_link({local, ?CM}, ?MODULE, [], []).
|
||||||
|
|
||||||
|
@ -121,7 +122,7 @@ set_conn_stats(ClientId, ConnPid, Stats) when is_binary(ClientId), is_pid(ConnPi
|
||||||
ets:insert(?CONN_STATS_TAB, {Conn, Stats}).
|
ets:insert(?CONN_STATS_TAB, {Conn, Stats}).
|
||||||
|
|
||||||
%% @doc Lookup connection pid.
|
%% @doc Lookup connection pid.
|
||||||
-spec(lookup_conn_pid(emqx_types:client_id()) -> pid() | undefined).
|
-spec(lookup_conn_pid(emqx_types:client_id()) -> maybe(pid())).
|
||||||
lookup_conn_pid(ClientId) when is_binary(ClientId) ->
|
lookup_conn_pid(ClientId) when is_binary(ClientId) ->
|
||||||
emqx_tables:lookup_value(?CONN_TAB, ClientId).
|
emqx_tables:lookup_value(?CONN_TAB, ClientId).
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -21,6 +21,8 @@
|
||||||
|
|
||||||
-module(emqx_gc).
|
-module(emqx_gc).
|
||||||
|
|
||||||
|
-include("types.hrl").
|
||||||
|
|
||||||
-export([init/1, run/3, info/1, reset/1]).
|
-export([init/1, run/3, info/1, reset/1]).
|
||||||
|
|
||||||
-type(opts() :: #{count => integer(),
|
-type(opts() :: #{count => integer(),
|
||||||
|
@ -35,7 +37,7 @@
|
||||||
-define(ENABLED(X), (is_integer(X) andalso X > 0)).
|
-define(ENABLED(X), (is_integer(X) andalso X > 0)).
|
||||||
|
|
||||||
%% @doc Initialize force GC state.
|
%% @doc Initialize force GC state.
|
||||||
-spec(init(opts() | false) -> gc_state() | undefined).
|
-spec(init(opts() | false) -> maybe(gc_state())).
|
||||||
init(#{count := Count, bytes := Bytes}) ->
|
init(#{count := Count, bytes := Bytes}) ->
|
||||||
Cnt = [{cnt, {Count, Count}} || ?ENABLED(Count)],
|
Cnt = [{cnt, {Count, Count}} || ?ENABLED(Count)],
|
||||||
Oct = [{oct, {Bytes, Bytes}} || ?ENABLED(Bytes)],
|
Oct = [{oct, {Bytes, Bytes}} || ?ENABLED(Bytes)],
|
||||||
|
@ -61,7 +63,7 @@ run([{K, N}|T], St) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% @doc Info of GC state.
|
%% @doc Info of GC state.
|
||||||
-spec(info(gc_state()) -> map() | undefined).
|
-spec(info(gc_state()) -> maybe(map())).
|
||||||
info({?MODULE, St}) ->
|
info({?MODULE, St}) ->
|
||||||
St;
|
St;
|
||||||
info(undefined) ->
|
info(undefined) ->
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -17,6 +17,7 @@
|
||||||
-behaviour(gen_server).
|
-behaviour(gen_server).
|
||||||
|
|
||||||
-include("logger.hrl").
|
-include("logger.hrl").
|
||||||
|
-include("types.hrl").
|
||||||
|
|
||||||
-export([start_link/0, stop/0]).
|
-export([start_link/0, stop/0]).
|
||||||
|
|
||||||
|
@ -42,7 +43,7 @@
|
||||||
-define(TAB, ?MODULE).
|
-define(TAB, ?MODULE).
|
||||||
-define(SERVER, ?MODULE).
|
-define(SERVER, ?MODULE).
|
||||||
|
|
||||||
-spec(start_link() -> emqx_types:startlink_ret()).
|
-spec(start_link() -> startlink_ret()).
|
||||||
start_link() ->
|
start_link() ->
|
||||||
gen_server:start_link({local, ?SERVER}, ?MODULE, [], [{hibernate_after, 1000}]).
|
gen_server:start_link({local, ?SERVER}, ?MODULE, [], [{hibernate_after, 1000}]).
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
%%
|
%%
|
||||||
%% %CopyrightBegin%
|
%% %CopyrightBegin%
|
||||||
%%
|
%%
|
||||||
%% Copyright Ericsson AB 2017-2018. All Rights Reserved.
|
%% Copyright Ericsson AB 2017-2013-2019. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -15,6 +15,7 @@
|
||||||
-module(emqx_metrics).
|
-module(emqx_metrics).
|
||||||
|
|
||||||
-include("logger.hrl").
|
-include("logger.hrl").
|
||||||
|
-include("types.hrl").
|
||||||
-include("emqx_mqtt.hrl").
|
-include("emqx_mqtt.hrl").
|
||||||
|
|
||||||
-export([start_link/0]).
|
-export([start_link/0]).
|
||||||
|
@ -87,7 +88,7 @@
|
||||||
-define(SERVER, ?MODULE).
|
-define(SERVER, ?MODULE).
|
||||||
|
|
||||||
%% @doc Start the metrics server.
|
%% @doc Start the metrics server.
|
||||||
-spec(start_link() -> emqx_types:startlink_ret()).
|
-spec(start_link() -> startlink_ret()).
|
||||||
start_link() ->
|
start_link() ->
|
||||||
gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).
|
gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -46,6 +46,7 @@
|
||||||
-module(emqx_mqueue).
|
-module(emqx_mqueue).
|
||||||
|
|
||||||
-include("emqx.hrl").
|
-include("emqx.hrl").
|
||||||
|
-include("types.hrl").
|
||||||
-include("emqx_mqtt.hrl").
|
-include("emqx_mqtt.hrl").
|
||||||
|
|
||||||
-export([init/1]).
|
-export([init/1]).
|
||||||
|
@ -117,7 +118,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()) -> {undefined | message(), mqueue()}).
|
-spec(in(message(), mqueue()) -> {maybe(message()), mqueue()}).
|
||||||
in(#message{qos = ?QOS_0}, MQ = #mqueue{store_qos0 = false}) ->
|
in(#message{qos = ?QOS_0}, MQ = #mqueue{store_qos0 = false}) ->
|
||||||
{_Dropped = undefined, MQ};
|
{_Dropped = undefined, MQ};
|
||||||
in(Msg = #message{topic = Topic}, MQ = #mqueue{default_p = Dp,
|
in(Msg = #message{topic = Topic}, MQ = #mqueue{default_p = Dp,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -15,11 +15,13 @@
|
||||||
%% @doc The utility functions for erlang process dictionary.
|
%% @doc The utility functions for erlang process dictionary.
|
||||||
-module(emqx_pd).
|
-module(emqx_pd).
|
||||||
|
|
||||||
|
-include("types.hrl").
|
||||||
|
|
||||||
-export([update_counter/2, get_counter/1, reset_counter/1]).
|
-export([update_counter/2, get_counter/1, reset_counter/1]).
|
||||||
|
|
||||||
-type(key() :: term()).
|
-type(key() :: term()).
|
||||||
|
|
||||||
-spec(update_counter(key(), number()) -> undefined | number()).
|
-spec(update_counter(key(), number()) -> maybe(number())).
|
||||||
update_counter(Key, Inc) ->
|
update_counter(Key, Inc) ->
|
||||||
put(Key, get_counter(Key) + Inc).
|
put(Key, get_counter(Key) + Inc).
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -17,6 +17,7 @@
|
||||||
-behaviour(gen_server).
|
-behaviour(gen_server).
|
||||||
|
|
||||||
-include("logger.hrl").
|
-include("logger.hrl").
|
||||||
|
-include("types.hrl").
|
||||||
|
|
||||||
-export([start_link/2]).
|
-export([start_link/2]).
|
||||||
-export([submit/1, submit/2]).
|
-export([submit/1, submit/2]).
|
||||||
|
@ -34,7 +35,7 @@
|
||||||
-type(task() :: fun() | mfa() | {fun(), Args :: list(any())}).
|
-type(task() :: fun() | mfa() | {fun(), Args :: list(any())}).
|
||||||
|
|
||||||
%% @doc Start pool.
|
%% @doc Start pool.
|
||||||
-spec(start_link(atom(), pos_integer()) -> emqx_types:startlink_ret()).
|
-spec(start_link(atom(), pos_integer()) -> startlink_ret()).
|
||||||
start_link(Pool, Id) ->
|
start_link(Pool, Id) ->
|
||||||
gen_server:start_link({local, emqx_misc:proc_name(?MODULE, Id)},
|
gen_server:start_link({local, emqx_misc:proc_name(?MODULE, Id)},
|
||||||
?MODULE, [Pool, Id], [{hibernate_after, 1000}]).
|
?MODULE, [Pool, Id], [{hibernate_after, 1000}]).
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
-include("emqx.hrl").
|
-include("emqx.hrl").
|
||||||
-include("logger.hrl").
|
-include("logger.hrl").
|
||||||
|
-include("types.hrl").
|
||||||
-include_lib("ekka/include/ekka.hrl").
|
-include_lib("ekka/include/ekka.hrl").
|
||||||
|
|
||||||
%% Mnesia bootstrap
|
%% Mnesia bootstrap
|
||||||
|
@ -65,7 +66,7 @@ mnesia(copy) ->
|
||||||
%% Start a router
|
%% Start a router
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
|
|
||||||
-spec(start_link(atom(), pos_integer()) -> emqx_types:startlink_ret()).
|
-spec(start_link(atom(), pos_integer()) -> startlink_ret()).
|
||||||
start_link(Pool, Id) ->
|
start_link(Pool, Id) ->
|
||||||
gen_server:start_link({local, emqx_misc:proc_name(?MODULE, Id)},
|
gen_server:start_link({local, emqx_misc:proc_name(?MODULE, Id)},
|
||||||
?MODULE, [Pool, Id], [{hibernate_after, 1000}]).
|
?MODULE, [Pool, Id], [{hibernate_after, 1000}]).
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
-include("emqx.hrl").
|
-include("emqx.hrl").
|
||||||
-include("logger.hrl").
|
-include("logger.hrl").
|
||||||
|
-include("types.hrl").
|
||||||
|
|
||||||
%% Mnesia bootstrap
|
%% Mnesia bootstrap
|
||||||
-export([mnesia/1]).
|
-export([mnesia/1]).
|
||||||
|
@ -61,7 +62,7 @@ mnesia(copy) ->
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
|
|
||||||
%% @doc Starts the router helper
|
%% @doc Starts the router helper
|
||||||
-spec(start_link() -> emqx_types:startlink_ret()).
|
-spec(start_link() -> startlink_ret()).
|
||||||
start_link() ->
|
start_link() ->
|
||||||
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
|
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -43,6 +43,7 @@
|
||||||
-include("emqx.hrl").
|
-include("emqx.hrl").
|
||||||
-include("emqx_mqtt.hrl").
|
-include("emqx_mqtt.hrl").
|
||||||
-include("logger.hrl").
|
-include("logger.hrl").
|
||||||
|
-include("types.hrl").
|
||||||
|
|
||||||
-export([start_link/1]).
|
-export([start_link/1]).
|
||||||
-export([info/1, attrs/1]).
|
-export([info/1, attrs/1]).
|
||||||
|
@ -77,7 +78,7 @@
|
||||||
client_id :: binary(),
|
client_id :: binary(),
|
||||||
|
|
||||||
%% Username
|
%% Username
|
||||||
username :: binary() | undefined,
|
username :: maybe(binary()),
|
||||||
|
|
||||||
%% Connection pid binding with session
|
%% Connection pid binding with session
|
||||||
conn_pid :: pid(),
|
conn_pid :: pid(),
|
||||||
|
@ -107,7 +108,7 @@
|
||||||
retry_interval = 20000 :: timeout(),
|
retry_interval = 20000 :: timeout(),
|
||||||
|
|
||||||
%% Retry Timer
|
%% Retry Timer
|
||||||
retry_timer :: reference() | undefined,
|
retry_timer :: maybe(reference()),
|
||||||
|
|
||||||
%% All QoS1, QoS2 messages published to when client is disconnected.
|
%% All QoS1, QoS2 messages published to when client is disconnected.
|
||||||
%% QoS 1 and QoS 2 messages pending transmission to the Client.
|
%% QoS 1 and QoS 2 messages pending transmission to the Client.
|
||||||
|
@ -125,19 +126,19 @@
|
||||||
await_rel_timeout = 20000 :: timeout(),
|
await_rel_timeout = 20000 :: timeout(),
|
||||||
|
|
||||||
%% Awaiting PUBREL Timer
|
%% Awaiting PUBREL Timer
|
||||||
await_rel_timer :: reference() | undefined,
|
await_rel_timer :: maybe(reference()),
|
||||||
|
|
||||||
%% Session Expiry Interval
|
%% Session Expiry Interval
|
||||||
expiry_interval = 7200 :: timeout(),
|
expiry_interval = 7200 :: timeout(),
|
||||||
|
|
||||||
%% Expired Timer
|
%% Expired Timer
|
||||||
expiry_timer :: reference() | undefined,
|
expiry_timer :: maybe(reference()),
|
||||||
|
|
||||||
%% Enable Stats
|
%% Enable Stats
|
||||||
enable_stats :: boolean(),
|
enable_stats :: boolean(),
|
||||||
|
|
||||||
%% Stats timer
|
%% Stats timer
|
||||||
stats_timer :: reference() | undefined,
|
stats_timer :: maybe(reference()),
|
||||||
|
|
||||||
%% GC State
|
%% GC State
|
||||||
gc_state,
|
gc_state,
|
||||||
|
@ -147,7 +148,7 @@
|
||||||
|
|
||||||
will_msg :: emqx:message(),
|
will_msg :: emqx:message(),
|
||||||
|
|
||||||
will_delay_timer :: reference() | undefined
|
will_delay_timer :: maybe(reference())
|
||||||
|
|
||||||
}).
|
}).
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -17,6 +17,7 @@
|
||||||
-behaviour(gen_server).
|
-behaviour(gen_server).
|
||||||
|
|
||||||
-include("logger.hrl").
|
-include("logger.hrl").
|
||||||
|
-include("types.hrl").
|
||||||
|
|
||||||
-export([start_link/1]).
|
-export([start_link/1]).
|
||||||
-export([start_session/1, count_sessions/0]).
|
-export([start_session/1, count_sessions/0]).
|
||||||
|
@ -38,7 +39,7 @@
|
||||||
-define(BATCH_EXIT, 100000).
|
-define(BATCH_EXIT, 100000).
|
||||||
|
|
||||||
%% @doc Start session supervisor.
|
%% @doc Start session supervisor.
|
||||||
-spec(start_link(map()) -> emqx_types:startlink_ret()).
|
-spec(start_link(map()) -> startlink_ret()).
|
||||||
start_link(SessSpec) when is_map(SessSpec) ->
|
start_link(SessSpec) when is_map(SessSpec) ->
|
||||||
gen_server:start_link({local, ?SUP}, ?MODULE, [SessSpec], []).
|
gen_server:start_link({local, ?SUP}, ?MODULE, [SessSpec], []).
|
||||||
|
|
||||||
|
@ -47,7 +48,7 @@ start_link(SessSpec) when is_map(SessSpec) ->
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
|
|
||||||
%% @doc Start a session.
|
%% @doc Start a session.
|
||||||
-spec(start_session(map()) -> emqx_types:startlink_ret()).
|
-spec(start_session(map()) -> startlink_ret()).
|
||||||
start_session(SessAttrs) ->
|
start_session(SessAttrs) ->
|
||||||
gen_server:call(?SUP, {start_session, SessAttrs}, infinity).
|
gen_server:call(?SUP, {start_session, SessAttrs}, infinity).
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -19,6 +19,7 @@
|
||||||
-include("emqx.hrl").
|
-include("emqx.hrl").
|
||||||
-include("emqx_mqtt.hrl").
|
-include("emqx_mqtt.hrl").
|
||||||
-include("logger.hrl").
|
-include("logger.hrl").
|
||||||
|
-include("types.hrl").
|
||||||
|
|
||||||
%% Mnesia bootstrap
|
%% Mnesia bootstrap
|
||||||
-export([mnesia/1]).
|
-export([mnesia/1]).
|
||||||
|
@ -70,7 +71,7 @@ mnesia(copy) ->
|
||||||
%% API
|
%% API
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
|
|
||||||
-spec(start_link() -> emqx_types:startlink_ret()).
|
-spec(start_link() -> startlink_ret()).
|
||||||
start_link() ->
|
start_link() ->
|
||||||
gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).
|
gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
-include("emqx.hrl").
|
-include("emqx.hrl").
|
||||||
-include("logger.hrl").
|
-include("logger.hrl").
|
||||||
|
-include("types.hrl").
|
||||||
|
|
||||||
-export([start_link/0]).
|
-export([start_link/0]).
|
||||||
|
|
||||||
|
@ -55,7 +56,7 @@
|
||||||
|
|
||||||
-define(BATCH_SIZE, 100000).
|
-define(BATCH_SIZE, 100000).
|
||||||
|
|
||||||
-spec(start_link() -> emqx_types:startlink_ret()).
|
-spec(start_link() -> startlink_ret()).
|
||||||
start_link() ->
|
start_link() ->
|
||||||
gen_server:start_link({local, ?SM}, ?MODULE, [], []).
|
gen_server:start_link({local, ?SM}, ?MODULE, [], []).
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -15,13 +15,14 @@
|
||||||
-module(emqx_sm_locker).
|
-module(emqx_sm_locker).
|
||||||
|
|
||||||
-include("emqx.hrl").
|
-include("emqx.hrl").
|
||||||
|
-include("types.hrl").
|
||||||
|
|
||||||
-export([start_link/0]).
|
-export([start_link/0]).
|
||||||
|
|
||||||
-export([trans/2, trans/3]).
|
-export([trans/2, trans/3]).
|
||||||
-export([lock/1, lock/2, unlock/1]).
|
-export([lock/1, lock/2, unlock/1]).
|
||||||
|
|
||||||
-spec(start_link() -> emqx_types:startlink_ret()).
|
-spec(start_link() -> startlink_ret()).
|
||||||
start_link() ->
|
start_link() ->
|
||||||
ekka_locker:start_link(?MODULE).
|
ekka_locker:start_link(?MODULE).
|
||||||
|
|
||||||
|
@ -29,7 +30,7 @@ start_link() ->
|
||||||
trans(ClientId, Fun) ->
|
trans(ClientId, Fun) ->
|
||||||
trans(ClientId, Fun, undefined).
|
trans(ClientId, Fun, undefined).
|
||||||
|
|
||||||
-spec(trans(emqx_types:client_id() | undefined,
|
-spec(trans(maybe(emqx_types:client_id()),
|
||||||
fun(([node()])-> any()), ekka_locker:piggyback()) -> any()).
|
fun(([node()])-> any()), ekka_locker:piggyback()) -> any()).
|
||||||
trans(undefined, Fun, _Piggyback) ->
|
trans(undefined, Fun, _Piggyback) ->
|
||||||
Fun([]);
|
Fun([]);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
-include("emqx.hrl").
|
-include("emqx.hrl").
|
||||||
-include("logger.hrl").
|
-include("logger.hrl").
|
||||||
|
-include("types.hrl").
|
||||||
|
|
||||||
-export([start_link/0]).
|
-export([start_link/0]).
|
||||||
-export([is_enabled/0]).
|
-export([is_enabled/0]).
|
||||||
|
@ -36,7 +37,7 @@
|
||||||
-type(session_pid() :: pid()).
|
-type(session_pid() :: pid()).
|
||||||
|
|
||||||
%% @doc Start the global session manager.
|
%% @doc Start the global session manager.
|
||||||
-spec(start_link() -> emqx_types:startlink_ret()).
|
-spec(start_link() -> startlink_ret()).
|
||||||
start_link() ->
|
start_link() ->
|
||||||
gen_server:start_link({local, ?REGISTRY}, ?MODULE, [], []).
|
gen_server:start_link({local, ?REGISTRY}, ?MODULE, [], []).
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
-include("emqx.hrl").
|
-include("emqx.hrl").
|
||||||
-include("logger.hrl").
|
-include("logger.hrl").
|
||||||
|
-include("types.hrl").
|
||||||
|
|
||||||
-export([start_link/0, start_link/1, stop/0]).
|
-export([start_link/0, start_link/1, stop/0]).
|
||||||
|
|
||||||
|
@ -82,11 +83,11 @@
|
||||||
-type opts() :: #{tick_ms := timeout()}.
|
-type opts() :: #{tick_ms := timeout()}.
|
||||||
|
|
||||||
%% @doc Start stats server
|
%% @doc Start stats server
|
||||||
-spec(start_link() -> emqx_types:startlink_ret()).
|
-spec(start_link() -> startlink_ret()).
|
||||||
start_link() ->
|
start_link() ->
|
||||||
start_link(#{tick_ms => timer:seconds(1)}).
|
start_link(#{tick_ms => timer:seconds(1)}).
|
||||||
|
|
||||||
-spec(start_link(opts()) -> emqx_types:startlink_ret()).
|
-spec(start_link(opts()) -> startlink_ret()).
|
||||||
start_link(Opts) ->
|
start_link(Opts) ->
|
||||||
gen_server:start_link({local, ?SERVER}, ?MODULE, Opts, []).
|
gen_server:start_link({local, ?SERVER}, ?MODULE, Opts, []).
|
||||||
|
|
||||||
|
@ -112,7 +113,7 @@ getstats() ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% @doc Get stats by name
|
%% @doc Get stats by name
|
||||||
-spec(getstat(atom()) -> non_neg_integer() | undefined).
|
-spec(getstat(atom()) -> maybe(non_neg_integer())).
|
||||||
getstat(Name) ->
|
getstat(Name) ->
|
||||||
case ets:lookup(?TAB, Name) of
|
case ets:lookup(?TAB, Name) of
|
||||||
[{Name, Val}] -> Val;
|
[{Name, Val}] -> Val;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -17,6 +17,7 @@
|
||||||
-behavior(gen_server).
|
-behavior(gen_server).
|
||||||
|
|
||||||
-include("logger.hrl").
|
-include("logger.hrl").
|
||||||
|
-include("types.hrl").
|
||||||
|
|
||||||
-export([start_link/1]).
|
-export([start_link/1]).
|
||||||
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2,
|
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2,
|
||||||
|
@ -24,10 +25,16 @@
|
||||||
%% compress unused warning
|
%% compress unused warning
|
||||||
-export([procinfo/1]).
|
-export([procinfo/1]).
|
||||||
|
|
||||||
|
-type(option() :: {long_gc, false | pos_integer()}
|
||||||
|
| {long_schedule, false | pos_integer()}
|
||||||
|
| {large_heap, pos_integer()}
|
||||||
|
| {busy_port, boolean()}
|
||||||
|
| {busy_dist_port, boolean()}).
|
||||||
|
|
||||||
-define(SYSMON, ?MODULE).
|
-define(SYSMON, ?MODULE).
|
||||||
|
|
||||||
%% @doc Start system monitor
|
%% @doc Start system monitor
|
||||||
-spec(start_link(Opts :: list(tuple())) -> emqx_types:startlink_ret()).
|
-spec(start_link(list(option())) -> startlink_ret()).
|
||||||
start_link(Opts) ->
|
start_link(Opts) ->
|
||||||
gen_server:start_link({local, ?SYSMON}, ?MODULE, [Opts], []).
|
gen_server:start_link({local, ?SYSMON}, ?MODULE, [Opts], []).
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -15,9 +15,9 @@
|
||||||
-module(emqx_types).
|
-module(emqx_types).
|
||||||
|
|
||||||
-include("emqx.hrl").
|
-include("emqx.hrl").
|
||||||
|
-include("types.hrl").
|
||||||
|
|
||||||
-export_type([zone/0]).
|
-export_type([zone/0]).
|
||||||
-export_type([startlink_ret/0, ok_or_error/1]).
|
|
||||||
-export_type([pubsub/0, topic/0, subid/0, subopts/0]).
|
-export_type([pubsub/0, topic/0, subid/0, subopts/0]).
|
||||||
-export_type([client_id/0, username/0, password/0, peername/0, protocol/0]).
|
-export_type([client_id/0, username/0, password/0, peername/0, protocol/0]).
|
||||||
-export_type([credentials/0, session/0]).
|
-export_type([credentials/0, session/0]).
|
||||||
|
@ -28,8 +28,6 @@
|
||||||
-export_type([alarm/0, plugin/0, command/0]).
|
-export_type([alarm/0, plugin/0, command/0]).
|
||||||
|
|
||||||
-type(zone() :: atom()).
|
-type(zone() :: atom()).
|
||||||
-type(startlink_ret() :: {ok, pid()} | ignore | {error, term()}).
|
|
||||||
-type(ok_or_error(Reason) :: ok | {error, Reason}).
|
|
||||||
-type(pubsub() :: publish | subscribe).
|
-type(pubsub() :: publish | subscribe).
|
||||||
-type(topic() :: binary()).
|
-type(topic() :: binary()).
|
||||||
-type(subid() :: binary() | atom()).
|
-type(subid() :: binary() | atom()).
|
||||||
|
@ -39,8 +37,8 @@
|
||||||
}).
|
}).
|
||||||
-type(session() :: #session{}).
|
-type(session() :: #session{}).
|
||||||
-type(client_id() :: binary() | atom()).
|
-type(client_id() :: binary() | atom()).
|
||||||
-type(username() :: binary() | undefined).
|
-type(username() :: maybe(binary())).
|
||||||
-type(password() :: binary() | undefined).
|
-type(password() :: maybe(binary())).
|
||||||
-type(peername() :: {inet:ip_address(), inet:port_number()}).
|
-type(peername() :: {inet:ip_address(), inet:port_number()}).
|
||||||
-type(protocol() :: mqtt | 'mqtt-sn' | coap | stomp | none | atom()).
|
-type(protocol() :: mqtt | 'mqtt-sn' | coap | stomp | none | atom()).
|
||||||
-type(credentials() :: #{client_id := client_id(),
|
-type(credentials() :: #{client_id := client_id(),
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -189,7 +189,15 @@ websocket_handle({binary, Data}, State = #state{parser_state = ParserState,
|
||||||
_:Error ->
|
_:Error ->
|
||||||
?LOG(error, "Frame error:~p~nFrame data: ~p", [Error, Data]),
|
?LOG(error, "Frame error:~p~nFrame data: ~p", [Error, Data]),
|
||||||
shutdown(parse_error, State)
|
shutdown(parse_error, State)
|
||||||
end.
|
end;
|
||||||
|
%% Pings should be replied with pongs, cowboy does it automatically
|
||||||
|
%% Pongs can be safely ignored. Clause here simply prevents crash.
|
||||||
|
websocket_handle(Frame, State)
|
||||||
|
when Frame =:= ping; Frame =:= pong ->
|
||||||
|
{ok, ensure_stats_timer(State)};
|
||||||
|
websocket_handle({FrameType, _}, State)
|
||||||
|
when FrameType =:= ping; FrameType =:= pong ->
|
||||||
|
{ok, ensure_stats_timer(State)}.
|
||||||
|
|
||||||
websocket_info({call, From, info}, State) ->
|
websocket_info({call, From, info}, State) ->
|
||||||
gen_server:reply(From, info(State)),
|
gen_server:reply(From, info(State)),
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
-include("emqx.hrl").
|
-include("emqx.hrl").
|
||||||
-include("logger.hrl").
|
-include("logger.hrl").
|
||||||
|
-include("types.hrl").
|
||||||
|
|
||||||
-export([start_link/0]).
|
-export([start_link/0]).
|
||||||
-export([get_env/2, get_env/3]).
|
-export([get_env/2, get_env/3]).
|
||||||
|
@ -33,17 +34,17 @@
|
||||||
-define(TAB, ?MODULE).
|
-define(TAB, ?MODULE).
|
||||||
-define(SERVER, ?MODULE).
|
-define(SERVER, ?MODULE).
|
||||||
|
|
||||||
-spec(start_link() -> emqx_types:startlink_ret()).
|
-spec(start_link() -> startlink_ret()).
|
||||||
start_link() ->
|
start_link() ->
|
||||||
gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).
|
gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).
|
||||||
|
|
||||||
-spec(get_env(emqx_types:zone() | undefined, atom()) -> undefined | term()).
|
-spec(get_env(maybe(emqx_types:zone()), atom()) -> maybe(term())).
|
||||||
get_env(undefined, Key) ->
|
get_env(undefined, Key) ->
|
||||||
emqx_config:get_env(Key);
|
emqx_config:get_env(Key);
|
||||||
get_env(Zone, Key) ->
|
get_env(Zone, Key) ->
|
||||||
get_env(Zone, Key, undefined).
|
get_env(Zone, Key, undefined).
|
||||||
|
|
||||||
-spec(get_env(emqx_types:zone() | undefined, atom(), term()) -> undefined | term()).
|
-spec(get_env(maybe(emqx_types:zone()), atom(), term()) -> maybe(term())).
|
||||||
get_env(undefined, Key, Def) ->
|
get_env(undefined, Key, Def) ->
|
||||||
emqx_config:get_env(Key, Def);
|
emqx_config:get_env(Key, Def);
|
||||||
get_env(Zone, Key, Def) ->
|
get_env(Zone, Key, Def) ->
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%% Copyright (c) 2018 EMQ Technologies Co., Ltd. All Rights Reserved.
|
%% Copyright (c) 2013-2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue