From 9e0b2ed57b7de50f5a967918eaffb959e3059731 Mon Sep 17 00:00:00 2001 From: Feng Lee Date: Thu, 16 Feb 2017 11:07:47 +0800 Subject: [PATCH] Update copyright and change the format of -type, -callback --- src/emqttd_access_control.erl | 22 +++++++++------------- src/emqttd_access_rule.erl | 17 ++++++++++------- src/emqttd_acl_internal.erl | 4 +++- src/emqttd_acl_mod.erl | 11 ++++++----- src/emqttd_alarm.erl | 4 +++- src/emqttd_auth_mod.erl | 12 +++++++----- src/emqttd_base62.erl | 4 +++- src/emqttd_boot.erl | 4 +++- src/emqttd_bridge.erl | 8 +++++--- src/emqttd_bridge_sup.erl | 2 +- src/emqttd_bridge_sup_sup.erl | 6 ++++-- src/emqttd_broker.erl | 24 +++++++++++++----------- src/emqttd_cluster.erl | 4 +++- src/emqttd_ctl.erl | 7 ++++++- src/emqttd_gen_mod.erl | 10 ++++++---- src/emqttd_guid.erl | 5 +++-- src/emqttd_http.erl | 7 +++++-- src/emqttd_keepalive.erl | 13 ++++++++----- src/emqttd_mnesia.erl | 4 +++- src/emqttd_mod_sup.erl | 8 ++------ src/emqttd_net.erl | 3 +-- src/emqttd_node.erl | 4 +++- src/emqttd_pool_sup.erl | 4 +++- src/emqttd_pooler.erl | 3 ++- src/emqttd_pubsub.erl | 9 +++++---- src/emqttd_pubsub_sup.erl | 4 +++- src/emqttd_sysmon.erl | 4 +++- src/emqttd_sysmon_sup.erl | 2 +- src/emqttd_trace.erl | 10 +++++----- src/emqttd_trace_sup.erl | 8 +++++--- src/emqttd_trie.erl | 5 ++++- src/emqttd_vm.erl | 2 +- src/lager_emqtt_backend.erl | 4 +++- 33 files changed, 142 insertions(+), 96 deletions(-) diff --git a/src/emqttd_access_control.erl b/src/emqttd_access_control.erl index 7aea58e79..cc60a57f2 100644 --- a/src/emqttd_access_control.erl +++ b/src/emqttd_access_control.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2017 Feng Lee . +%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io) %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -16,29 +16,25 @@ -module(emqttd_access_control). --include("emqttd.hrl"). - -behaviour(gen_server). --define(SERVER, ?MODULE). +-author("Feng Lee "). + +-include("emqttd.hrl"). %% API Function Exports --export([start_link/0, - auth/2, % authentication - check_acl/3, % acl check - reload_acl/0, % reload acl - lookup_mods/1, - register_mod/3, register_mod/4, - unregister_mod/2, - stop/0]). +-export([start_link/0, auth/2, check_acl/3, reload_acl/0, lookup_mods/1, + register_mod/3, register_mod/4, unregister_mod/2, stop/0]). %% gen_server callbacks -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). +-define(SERVER, ?MODULE). + -define(ACCESS_CONTROL_TAB, mqtt_access_control). --type password() :: undefined | binary(). +-type(password() :: undefined | binary()). -record(state, {}). diff --git a/src/emqttd_access_rule.erl b/src/emqttd_access_rule.erl index 1590d2efe..73718fd3a 100644 --- a/src/emqttd_access_rule.erl +++ b/src/emqttd_access_rule.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2017 Feng Lee . +%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io) %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -16,21 +16,24 @@ -module(emqttd_access_rule). +-author("Feng Lee "). + -include("emqttd.hrl"). --type who() :: all | binary() | + +-type(who() :: all | binary() | {ipaddr, esockd_cidr:cidr_string()} | {client, binary()} | - {user, binary()}. + {user, binary()}). --type access() :: subscribe | publish | pubsub. +-type(access() :: subscribe | publish | pubsub). --type topic() :: binary(). +-type(topic() :: binary()). --type rule() :: {allow, all} | +-type(rule() :: {allow, all} | {allow, who(), access(), list(topic())} | {deny, all} | - {deny, who(), access(), list(topic())}. + {deny, who(), access(), list(topic())}). -export_type([rule/0]). diff --git a/src/emqttd_acl_internal.erl b/src/emqttd_acl_internal.erl index 74ab8519a..f1c8b801b 100644 --- a/src/emqttd_acl_internal.erl +++ b/src/emqttd_acl_internal.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2017 Feng Lee . +%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io) %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -18,6 +18,8 @@ -behaviour(emqttd_acl_mod). +-author("Feng Lee "). + -include("emqttd.hrl"). -export([all_rules/0]). diff --git a/src/emqttd_acl_mod.erl b/src/emqttd_acl_mod.erl index 44c775460..12e949afe 100644 --- a/src/emqttd_acl_mod.erl +++ b/src/emqttd_acl_mod.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2017 Feng Lee . +%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io) %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -16,6 +16,8 @@ -module(emqttd_acl_mod). +-author("Feng Lee "). + -include("emqttd.hrl"). %%-------------------------------------------------------------------- @@ -26,10 +28,9 @@ -callback(init(AclOpts :: list()) -> {ok, State :: any()}). --callback(check_acl({Client, PubSub, Topic}, State :: any()) -> allow | deny | ignore when - Client :: mqtt_client(), - PubSub :: pubsub(), - Topic :: binary()). +-callback(check_acl({Client :: mqtt_client(), + PubSub :: pubsub(), + Topic :: binary()}, State :: any()) -> allow | deny | ignore). -callback(reload_acl(State :: any()) -> ok | {error, any()}). diff --git a/src/emqttd_alarm.erl b/src/emqttd_alarm.erl index 1ff4a5ae9..b214ab8fc 100644 --- a/src/emqttd_alarm.erl +++ b/src/emqttd_alarm.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2017 Feng Lee . +%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io) %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -16,6 +16,8 @@ -module(emqttd_alarm). +-author("Feng Lee "). + -behaviour(gen_event). -include("emqttd.hrl"). diff --git a/src/emqttd_auth_mod.erl b/src/emqttd_auth_mod.erl index d6d4a55b0..c27f49d36 100644 --- a/src/emqttd_auth_mod.erl +++ b/src/emqttd_auth_mod.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2017 Feng Lee . +%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io) %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -16,6 +16,8 @@ -module(emqttd_auth_mod). +-author("Feng Lee "). + -include("emqttd.hrl"). -export([passwd_hash/2]). @@ -30,10 +32,10 @@ -callback(init(AuthOpts :: list()) -> {ok, State :: any()}). --callback(check(Client, Password, State) -> ok | | {ok, boolean()} | ignore | {error, string()} when - Client :: mqtt_client(), - Password :: binary(), - State :: any()). +-callback(check(Client :: mqtt_client(), + Password :: binary(), + State :: any()) + -> ok | | {ok, boolean()} | ignore | {error, string()}). -callback(description() -> string()). diff --git a/src/emqttd_base62.erl b/src/emqttd_base62.erl index 5895fa245..481488fb9 100644 --- a/src/emqttd_base62.erl +++ b/src/emqttd_base62.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2016-2017 Feng Lee . +%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io) %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -16,6 +16,8 @@ -module(emqttd_base62). +-author("Feng Lee "). + -export([encode/1, decode/1]). %% @doc Encode an integer to base62 string diff --git a/src/emqttd_boot.erl b/src/emqttd_boot.erl index dd1b8a65b..d7a6d311e 100644 --- a/src/emqttd_boot.erl +++ b/src/emqttd_boot.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2017 Feng Lee . +%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io) %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -16,6 +16,8 @@ -module(emqttd_boot). +-author("Feng Lee "). + -export([apply_module_attributes/1, all_module_attributes/1]). %% only {F, Args}... diff --git a/src/emqttd_bridge.erl b/src/emqttd_bridge.erl index 3dca7bf0f..7e36ad256 100644 --- a/src/emqttd_bridge.erl +++ b/src/emqttd_bridge.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2017 Feng Lee . +%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io) %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -18,6 +18,8 @@ -behaviour(gen_server2). +-author("Feng Lee "). + -include("emqttd.hrl"). -include("emqttd_protocol.hrl"). @@ -43,11 +45,11 @@ ping_down_interval = ?PING_DOWN_INTERVAL, status = up}). --type option() :: {qos, mqtt_qos()} | +-type(option() :: {qos, mqtt_qos()} | {topic_suffix, binary()} | {topic_prefix, binary()} | {max_queue_len, pos_integer()} | - {ping_down_interval, pos_integer()}. + {ping_down_interval, pos_integer()}). -export_type([option/0]). diff --git a/src/emqttd_bridge_sup.erl b/src/emqttd_bridge_sup.erl index dd418b2f6..d28b2274c 100644 --- a/src/emqttd_bridge_sup.erl +++ b/src/emqttd_bridge_sup.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2017 Feng Lee . +%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io) %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_bridge_sup_sup.erl b/src/emqttd_bridge_sup_sup.erl index 47e246273..1d47bd003 100644 --- a/src/emqttd_bridge_sup_sup.erl +++ b/src/emqttd_bridge_sup_sup.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2017 Feng Lee . +%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io) %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -18,6 +18,8 @@ -behavior(supervisor). +-author("Feng Lee "). + -export([start_link/0, bridges/0, start_bridge/2, start_bridge/3, stop_bridge/2]). -export([init/1]). @@ -47,7 +49,7 @@ start_bridge(Node, _Topic, _Options) when Node =:= node() -> {error, bridge_to_self}; start_bridge(Node, Topic, Options) when is_atom(Node) andalso is_binary(Topic) -> {ok, BridgeEnv} = emqttd:env(bridge), - Options1 = emqttd_opts:merge(BridgeEnv, Options), + Options1 = emqttd_misc:merge_opts(BridgeEnv, Options), supervisor:start_child(?MODULE, bridge_spec(Node, Topic, Options1)). %% @doc Stop a bridge diff --git a/src/emqttd_broker.erl b/src/emqttd_broker.erl index 96dd7d553..ce2e4210c 100644 --- a/src/emqttd_broker.erl +++ b/src/emqttd_broker.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2017 Feng Lee . +%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io) %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -18,6 +18,8 @@ -behaviour(gen_server). +-author("Feng Lee "). + -include("emqttd.hrl"). -include("emqttd_internal.hrl"). @@ -40,16 +42,18 @@ -record(state, {started_at, sys_interval, heartbeat, tick_tref, version, sysdescr}). +-define(APP, emqttd). + -define(SERVER, ?MODULE). -define(BROKER_TAB, mqtt_broker). %% $SYS Topics of Broker -define(SYSTOP_BROKERS, [ - version, % Broker version - uptime, % Broker uptime - datetime, % Broker local datetime - sysdescr % Broker description + version, % Broker version + uptime, % Broker uptime + datetime, % Broker local datetime + sysdescr % Broker description ]). %%-------------------------------------------------------------------- @@ -74,12 +78,12 @@ notify(EventType, Event) -> %% @doc Get broker version -spec(version() -> string()). version() -> - {ok, Version} = application:get_key(emqttd, vsn), Version. + {ok, Version} = application:get_key(?APP, vsn), Version. %% @doc Get broker description -spec(sysdescr() -> string()). sysdescr() -> - {ok, Descr} = application:get_key(emqttd, description), Descr. + {ok, Descr} = application:get_key(?APP, description), Descr. %% @doc Get broker uptime -spec(uptime() -> string()). @@ -161,13 +165,11 @@ retain(brokers) -> Payload = list_to_binary(string:join([atom_to_list(N) || N <- emqttd_mnesia:running_nodes()], ",")), Msg = emqttd_message:make(broker, <<"$SYS/brokers">>, Payload), - Msg1 = emqttd_message:set_flag(sys, emqttd_message:set_flag(retain, Msg)), - emqttd:publish(Msg1). + emqttd:publish(emqttd_message:set_flag(sys, emqttd_message:set_flag(retain, Msg))). retain(Topic, Payload) when is_binary(Payload) -> Msg = emqttd_message:make(broker, emqttd_topic:systop(Topic), Payload), - Msg1 = emqttd_message:set_flag(sys, emqttd_message:set_flag(retain, Msg)), - emqttd:publish(Msg1). + emqttd:publish(emqttd_message:set_flag(sys, emqttd_message:set_flag(retain, Msg))). publish(Topic, Payload) when is_binary(Payload) -> Msg = emqttd_message:make(broker, emqttd_topic:systop(Topic), Payload), diff --git a/src/emqttd_cluster.erl b/src/emqttd_cluster.erl index 7c83c079c..7990a5d51 100644 --- a/src/emqttd_cluster.erl +++ b/src/emqttd_cluster.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2017 Feng Lee . +%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io) %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -16,6 +16,8 @@ -module(emqttd_cluster). +-author("Feng Lee "). + -include("emqttd.hrl"). %% Cluster API diff --git a/src/emqttd_ctl.erl b/src/emqttd_ctl.erl index c0b7dcf70..0aa8ce353 100644 --- a/src/emqttd_ctl.erl +++ b/src/emqttd_ctl.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2017 Feng Lee . +%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io) %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -18,6 +18,8 @@ -behaviour(gen_server). +-author("Feng Lee "). + -include("emqttd.hrl"). -include("emqttd_cli.hrl"). @@ -134,7 +136,9 @@ next_seq(State = #state{seq = Seq}) -> State#state{seq = Seq + 1}. -ifdef(TEST). + -include_lib("eunit/include/eunit.hrl"). + register_cmd_test_() -> {setup, fun() -> @@ -149,4 +153,5 @@ register_cmd_test_() -> [?_assertMatch([{{0,test0},{?MODULE, test0}, []}], ets:lookup(?CMD_TAB, {Seq,test0}))] end }. + -endif. diff --git a/src/emqttd_gen_mod.erl b/src/emqttd_gen_mod.erl index b201f7bdd..824b65f4c 100644 --- a/src/emqttd_gen_mod.erl +++ b/src/emqttd_gen_mod.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2017 Feng Lee . +%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io) %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -15,15 +15,18 @@ %%-------------------------------------------------------------------- %% @doc emqttd gen_mod behaviour + -module(emqttd_gen_mod). +-author("Feng Lee "). + -include("emqttd.hrl"). -ifdef(use_specs). --callback load(Opts :: any()) -> ok | {error, any()}. +-callback(load(Opts :: any()) -> ok | {error, any()}). --callback unload(State :: any()) -> any(). +-callback(unload(State :: any()) -> any()). -else. @@ -35,4 +38,3 @@ behaviour_info(_Other) -> undefined. -endif. - diff --git a/src/emqttd_guid.erl b/src/emqttd_guid.erl index a4c2d1ea4..24199fa01 100644 --- a/src/emqttd_guid.erl +++ b/src/emqttd_guid.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2017 Feng Lee . +%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io) %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -27,13 +27,14 @@ %% 4. Sequence: 2 bytes sequence in one process %% %% @end + -module(emqttd_guid). -export([gen/0, new/0, timestamp/1, to_hexstr/1, from_hexstr/1, to_base62/1, from_base62/1]). -define(MAX_SEQ, 16#FFFF). --type guid() :: <<_:128>>. +-type(guid() :: <<_:128>>). %% @doc Generate a global unique id. -spec(gen() -> guid()). diff --git a/src/emqttd_http.erl b/src/emqttd_http.erl index 8ad37dd10..692477447 100644 --- a/src/emqttd_http.erl +++ b/src/emqttd_http.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2017 Feng Lee . +%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io) %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -14,9 +14,12 @@ %% limitations under the License. %%-------------------------------------------------------------------- -%% @doc emqttd http publish API and websocket client. +%% @doc HTTP publish API and websocket client. + -module(emqttd_http). +-author("Feng Lee "). + -include("emqttd.hrl"). -include("emqttd_protocol.hrl"). diff --git a/src/emqttd_keepalive.erl b/src/emqttd_keepalive.erl index 54a4d20e5..51d45c89c 100644 --- a/src/emqttd_keepalive.erl +++ b/src/emqttd_keepalive.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2017 Feng Lee . +%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io) %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -15,15 +15,18 @@ %%-------------------------------------------------------------------- %% @doc Client Keepalive + -module(emqttd_keepalive). +-author("Feng Lee "). + -export([start/3, check/1, cancel/1]). --record(keepalive, {statfun, statval, - tsec, tmsg, tref, - repeat = 0}). +-record(keepalive, {statfun, statval, tsec, tmsg, tref, repeat = 0}). --type keepalive() :: #keepalive{}. +-type(keepalive() :: #keepalive{}). + +-export_type([keepalive/0]). %% @doc Start a keepalive -spec(start(fun(), integer(), any()) -> undefined | keepalive()). diff --git a/src/emqttd_mnesia.erl b/src/emqttd_mnesia.erl index 52dca1d1b..31fa88d3a 100644 --- a/src/emqttd_mnesia.erl +++ b/src/emqttd_mnesia.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2017 Feng Lee . +%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io) %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -16,6 +16,8 @@ -module(emqttd_mnesia). +-author("Feng Lee "). + -include("emqttd.hrl"). -include("emqttd_internal.hrl"). diff --git a/src/emqttd_mod_sup.erl b/src/emqttd_mod_sup.erl index 57b13bc37..586d5af1a 100644 --- a/src/emqttd_mod_sup.erl +++ b/src/emqttd_mod_sup.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2017 Feng Lee . +%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io) %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -39,11 +39,7 @@ start_link() -> start_child(ChildSpec) when is_tuple(ChildSpec) -> supervisor:start_child(?MODULE, ChildSpec). -%% -%% start_child(Mod::atom(), Type::type()) -> {ok, pid()} -%% @type type() = worker | supervisor -%% -start_child(Mod, Type) when is_atom(Mod) and is_atom(Type) -> +start_child(Mod, Type) when is_atom(Mod) andalso is_atom(Type) -> supervisor:start_child(?MODULE, ?CHILD(Mod, Type)). -spec(stop_child(any()) -> ok | {error, any()}). diff --git a/src/emqttd_net.erl b/src/emqttd_net.erl index 8278e1f74..1f246a315 100644 --- a/src/emqttd_net.erl +++ b/src/emqttd_net.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2017 Feng Lee . +%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io) %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -14,7 +14,6 @@ %% limitations under the License. %%-------------------------------------------------------------------- -%% @doc emqttd net utilities. -module(emqttd_net). -include_lib("kernel/include/inet.hrl"). diff --git a/src/emqttd_node.erl b/src/emqttd_node.erl index e48f71fae..ecf44503f 100644 --- a/src/emqttd_node.erl +++ b/src/emqttd_node.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2017 Feng Lee . +%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io) %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -16,6 +16,8 @@ -module(emqttd_node). +-author("Feng Lee "). + -import(lists, [concat/1]). -export([is_aliving/1, parse_name/1]). diff --git a/src/emqttd_pool_sup.erl b/src/emqttd_pool_sup.erl index e06d09e8f..bc8f59562 100644 --- a/src/emqttd_pool_sup.erl +++ b/src/emqttd_pool_sup.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2017 Feng Lee . +%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io) %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -17,6 +17,8 @@ %% @doc Common Pool Supervisor -module(emqttd_pool_sup). +-author("Feng Lee "). + -behaviour(supervisor). %% API diff --git a/src/emqttd_pooler.erl b/src/emqttd_pooler.erl index 2701c470e..1b73d138c 100644 --- a/src/emqttd_pooler.erl +++ b/src/emqttd_pooler.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2017 Feng Lee . +%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -39,6 +39,7 @@ start_link() -> %%-------------------------------------------------------------------- %% API %%-------------------------------------------------------------------- + -spec(start_link(atom(), pos_integer()) -> {ok, pid()} | ignore | {error, any()}). start_link(Pool, Id) -> gen_server:start_link({local, ?PROC_NAME(?MODULE, Id)}, ?MODULE, [Pool, Id], []). diff --git a/src/emqttd_pubsub.erl b/src/emqttd_pubsub.erl index 83a080ff6..c99aca513 100644 --- a/src/emqttd_pubsub.erl +++ b/src/emqttd_pubsub.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2017 Feng Lee . +%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io) %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -18,11 +18,12 @@ -behaviour(gen_server2). +-author("Feng Lee "). + -include("emqttd.hrl"). -include("emqttd_internal.hrl"). -%% Start API. -export([start_link/3]). %% PubSub API. @@ -31,7 +32,7 @@ -export([dispatch/2]). -%% gen_server. +%% gen_server Callbacks -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). @@ -45,7 +46,6 @@ %% Start PubSub %%-------------------------------------------------------------------- -%% @doc Start one Pubsub -spec(start_link(atom(), pos_integer(), list()) -> {ok, pid()} | ignore | {error, any()}). start_link(Pool, Id, Env) -> gen_server2:start_link({local, ?PROC_NAME(?MODULE, Id)}, ?MODULE, [Pool, Id, Env], []). @@ -115,6 +115,7 @@ dispatch({_Share, [Sub]}, Topic, Msg) -> dispatch(Sub, Topic, Msg); dispatch({_Share, []}, _Topic, _Msg) -> ok; +%%TODO: round-robbin dispatch({_Share, Subs}, Topic, Msg) -> dispatch(lists:nth(rand:uniform(length(Subs)), Subs), Topic, Msg). diff --git a/src/emqttd_pubsub_sup.erl b/src/emqttd_pubsub_sup.erl index 882fce57c..09d08d110 100644 --- a/src/emqttd_pubsub_sup.erl +++ b/src/emqttd_pubsub_sup.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2017 Feng Lee . +%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io) %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -17,6 +17,8 @@ %% @doc PubSub Supervisor. -module(emqttd_pubsub_sup). +-author("Feng Lee "). + -behaviour(supervisor). %% API diff --git a/src/emqttd_sysmon.erl b/src/emqttd_sysmon.erl index 7c338a842..c94c1df54 100644 --- a/src/emqttd_sysmon.erl +++ b/src/emqttd_sysmon.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2017 Feng Lee . +%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io) %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -17,6 +17,8 @@ %% @doc VM System Monitor -module(emqttd_sysmon). +-author("Feng Lee "). + -behavior(gen_server). -include("emqttd_internal.hrl"). diff --git a/src/emqttd_sysmon_sup.erl b/src/emqttd_sysmon_sup.erl index 0131c42db..99e7a628d 100644 --- a/src/emqttd_sysmon_sup.erl +++ b/src/emqttd_sysmon_sup.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2017 Feng Lee . +%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io) %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/emqttd_trace.erl b/src/emqttd_trace.erl index 069f44937..4d46d9165 100644 --- a/src/emqttd_trace.erl +++ b/src/emqttd_trace.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2017 Feng Lee . +%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io) %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -14,13 +14,13 @@ %% limitations under the License. %%-------------------------------------------------------------------- -%% @doc -%% Trace MQTT packets/messages by ClientID or Topic. -%% @end +%% @docTrace MQTT packets/messages by ClientID or Topic. -module(emqttd_trace). -behaviour(gen_server). +-author("Feng Lee "). + -include("emqttd_internal.hrl"). %% API Function Exports @@ -34,7 +34,7 @@ -record(state, {level, traces}). --type trace_who() :: {client | topic, binary()}. +-type(trace_who() :: {client | topic, binary()}). -define(TRACE_OPTIONS, [{formatter_config, [time, " [",severity,"] ", message, "\n"]}]). diff --git a/src/emqttd_trace_sup.erl b/src/emqttd_trace_sup.erl index 22736b1a2..728e6818e 100644 --- a/src/emqttd_trace_sup.erl +++ b/src/emqttd_trace_sup.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2017 Feng Lee . +%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io) %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -16,6 +16,8 @@ -module(emqttd_trace_sup). +-author("Feng Lee "). + -behaviour(supervisor). %% API @@ -29,6 +31,6 @@ start_link() -> init([]) -> Trace = {trace, {emqttd_trace, start_link, []}, - permanent, 5000, worker, [emqttd_trace]}, - {ok, {{one_for_one, 10, 100}, [Trace]}}. + permanent, 5000, worker, [emqttd_trace]}, + {ok, {{one_for_one, 10, 3600}, [Trace]}}. diff --git a/src/emqttd_trie.erl b/src/emqttd_trie.erl index 23bb40bcf..70b1c003f 100644 --- a/src/emqttd_trie.erl +++ b/src/emqttd_trie.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2017 Feng Lee . +%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io) %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -17,8 +17,11 @@ %% @doc MQTT Topic Trie: %% [Trie](http://en.wikipedia.org/wiki/Trie) %% @end + -module(emqttd_trie). +-author("Feng Lee "). + -include("emqttd_trie.hrl"). %% Mnesia Callbacks diff --git a/src/emqttd_vm.erl b/src/emqttd_vm.erl index abf4d3b78..16fae60ae 100644 --- a/src/emqttd_vm.erl +++ b/src/emqttd_vm.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2017 Feng Lee . +%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io) %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/src/lager_emqtt_backend.erl b/src/lager_emqtt_backend.erl index 214182b8d..69c1aece4 100644 --- a/src/lager_emqtt_backend.erl +++ b/src/lager_emqtt_backend.erl @@ -1,5 +1,5 @@ %%-------------------------------------------------------------------- -%% Copyright (c) 2012-2017 Feng Lee . +%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io) %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -16,6 +16,8 @@ -module(lager_emqtt_backend). +-author("Feng Lee "). + -behaviour(gen_event). -include_lib("lager/include/lager.hrl").