Browse Source

Update copyright and change the format of -type, -callback

Feng Lee 9 years atrás
parent
commit
9e0b2ed57b

+ 9 - 13
src/emqttd_access_control.erl

@@ -1,5 +1,5 @@
 %%--------------------------------------------------------------------
-%% Copyright (c) 2012-2017 Feng Lee <feng@emqtt.io>.
+%% 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 <feng@emqtt.io>").
+
+-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, {}).
 

+ 10 - 7
src/emqttd_access_rule.erl

@@ -1,5 +1,5 @@
 %%--------------------------------------------------------------------
-%% Copyright (c) 2012-2017 Feng Lee <feng@emqtt.io>.
+%% 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 <feng@emqtt.io>").
+
 -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]).
 

+ 3 - 1
src/emqttd_acl_internal.erl

@@ -1,5 +1,5 @@
 %%--------------------------------------------------------------------
-%% Copyright (c) 2012-2017 Feng Lee <feng@emqtt.io>.
+%% 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 <feng@emqtt.io>").
+
 -include("emqttd.hrl").
 
 -export([all_rules/0]).

+ 6 - 5
src/emqttd_acl_mod.erl

@@ -1,5 +1,5 @@
 %%--------------------------------------------------------------------
-%% Copyright (c) 2012-2017 Feng Lee <feng@emqtt.io>.
+%% 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 <feng@emqtt.io>").
+
 -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()}).
 

+ 3 - 1
src/emqttd_alarm.erl

@@ -1,5 +1,5 @@
 %%--------------------------------------------------------------------
-%% Copyright (c) 2012-2017 Feng Lee <feng@emqtt.io>.
+%% 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 <feng@emqtt.io>").
+
 -behaviour(gen_event).
 
 -include("emqttd.hrl").

+ 7 - 5
src/emqttd_auth_mod.erl

@@ -1,5 +1,5 @@
 %%--------------------------------------------------------------------
-%% Copyright (c) 2012-2017 Feng Lee <feng@emqtt.io>.
+%% 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 <feng@emqtt.io>").
+
 -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()).
 

+ 3 - 1
src/emqttd_base62.erl

@@ -1,5 +1,5 @@
 %%--------------------------------------------------------------------
-%% Copyright (c) 2016-2017 Feng Lee <feng@emqtt.io>.
+%% 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 <feng@emqtt.io>").
+
 -export([encode/1, decode/1]).
 
 %% @doc Encode an integer to base62 string

+ 3 - 1
src/emqttd_boot.erl

@@ -1,5 +1,5 @@
 %%--------------------------------------------------------------------
-%% Copyright (c) 2012-2017 Feng Lee <feng@emqtt.io>.
+%% 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 <feng@emqtt.io>").
+
 -export([apply_module_attributes/1, all_module_attributes/1]).
 
 %% only {F, Args}...

+ 5 - 3
src/emqttd_bridge.erl

@@ -1,5 +1,5 @@
 %%--------------------------------------------------------------------
-%% Copyright (c) 2012-2017 Feng Lee <feng@emqtt.io>.
+%% 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 <feng@emqtt.io>").
+
 -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]).
 

+ 1 - 1
src/emqttd_bridge_sup.erl

@@ -1,5 +1,5 @@
 %%--------------------------------------------------------------------
-%% Copyright (c) 2012-2017 Feng Lee <feng@emqtt.io>.
+%% 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.

+ 4 - 2
src/emqttd_bridge_sup_sup.erl

@@ -1,5 +1,5 @@
 %%--------------------------------------------------------------------
-%% Copyright (c) 2012-2017 Feng Lee <feng@emqtt.io>.
+%% 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 <feng@emqtt.io>").
+
 -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

+ 13 - 11
src/emqttd_broker.erl

@@ -1,5 +1,5 @@
 %%--------------------------------------------------------------------
-%% Copyright (c) 2012-2017 Feng Lee <feng@emqtt.io>.
+%% 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 <feng@emqtt.io>").
+
 -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),

+ 3 - 1
src/emqttd_cluster.erl

@@ -1,5 +1,5 @@
 %%--------------------------------------------------------------------
-%% Copyright (c) 2012-2017 Feng Lee <feng@emqtt.io>.
+%% 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 <feng@emqtt.io>").
+
 -include("emqttd.hrl").
 
 %% Cluster API

+ 6 - 1
src/emqttd_ctl.erl

@@ -1,5 +1,5 @@
 %%--------------------------------------------------------------------
-%% Copyright (c) 2012-2017 Feng Lee <feng@emqtt.io>.
+%% 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 <feng@emqtt.io>").
+
 -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.

+ 6 - 4
src/emqttd_gen_mod.erl

@@ -1,5 +1,5 @@
 %%--------------------------------------------------------------------
-%% Copyright (c) 2012-2017 Feng Lee <feng@emqtt.io>.
+%% 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 <feng@emqtt.io>").
+
 -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.
-

+ 3 - 2
src/emqttd_guid.erl

@@ -1,5 +1,5 @@
 %%--------------------------------------------------------------------
-%% Copyright (c) 2012-2017 Feng Lee <feng@emqtt.io>.
+%% 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()).

+ 5 - 2
src/emqttd_http.erl

@@ -1,5 +1,5 @@
 %%--------------------------------------------------------------------
-%% Copyright (c) 2012-2017 Feng Lee <feng@emqtt.io>.
+%% 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 <feng@emqtt.io>").
+
 -include("emqttd.hrl").
 
 -include("emqttd_protocol.hrl").

+ 8 - 5
src/emqttd_keepalive.erl

@@ -1,5 +1,5 @@
 %%--------------------------------------------------------------------
-%% Copyright (c) 2012-2017 Feng Lee <feng@emqtt.io>.
+%% 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 <feng@emqtt.io>").
+
 -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()).

+ 3 - 1
src/emqttd_mnesia.erl

@@ -1,5 +1,5 @@
 %%--------------------------------------------------------------------
-%% Copyright (c) 2012-2017 Feng Lee <feng@emqtt.io>.
+%% 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 <feng@emqtt.io>").
+
 -include("emqttd.hrl").
 
 -include("emqttd_internal.hrl").

+ 2 - 6
src/emqttd_mod_sup.erl

@@ -1,5 +1,5 @@
 %%--------------------------------------------------------------------
-%% Copyright (c) 2012-2017 Feng Lee <feng@emqtt.io>.
+%% 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()}).

+ 1 - 2
src/emqttd_net.erl

@@ -1,5 +1,5 @@
 %%--------------------------------------------------------------------
-%% Copyright (c) 2012-2017 Feng Lee <feng@emqtt.io>.
+%% 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").

+ 3 - 1
src/emqttd_node.erl

@@ -1,5 +1,5 @@
 %%--------------------------------------------------------------------
-%% Copyright (c) 2012-2017 Feng Lee <feng@emqtt.io>.
+%% 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 <feng@emqtt.io>").
+
 -import(lists, [concat/1]).
 
 -export([is_aliving/1, parse_name/1]).

+ 3 - 1
src/emqttd_pool_sup.erl

@@ -1,5 +1,5 @@
 %%--------------------------------------------------------------------
-%% Copyright (c) 2012-2017 Feng Lee <feng@emqtt.io>.
+%% 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 <feng@emqtt.io>").
+
 -behaviour(supervisor).
 
 %% API

+ 2 - 1
src/emqttd_pooler.erl

@@ -1,5 +1,5 @@
 %%--------------------------------------------------------------------
-%% Copyright (c) 2012-2017 Feng Lee <feng@emqtt.io>.
+%% 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], []).

+ 5 - 4
src/emqttd_pubsub.erl

@@ -1,5 +1,5 @@
 %%--------------------------------------------------------------------
-%% Copyright (c) 2012-2017 Feng Lee <feng@emqtt.io>.
+%% 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 <feng@emqtt.io>").
+
 -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).
 

+ 3 - 1
src/emqttd_pubsub_sup.erl

@@ -1,5 +1,5 @@
 %%--------------------------------------------------------------------
-%% Copyright (c) 2012-2017 Feng Lee <feng@emqtt.io>.
+%% 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 <feng@emqtt.io>").
+
 -behaviour(supervisor).
 
 %% API

+ 3 - 1
src/emqttd_sysmon.erl

@@ -1,5 +1,5 @@
 %%--------------------------------------------------------------------
-%% Copyright (c) 2012-2017 Feng Lee <feng@emqtt.io>.
+%% 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 <feng@emqtt.io>").
+
 -behavior(gen_server).
 
 -include("emqttd_internal.hrl").

+ 1 - 1
src/emqttd_sysmon_sup.erl

@@ -1,5 +1,5 @@
 %%--------------------------------------------------------------------
-%% Copyright (c) 2012-2017 Feng Lee <feng@emqtt.io>.
+%% 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.

+ 5 - 5
src/emqttd_trace.erl

@@ -1,5 +1,5 @@
 %%--------------------------------------------------------------------
-%% Copyright (c) 2012-2017 Feng Lee <feng@emqtt.io>.
+%% 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 <feng@emqtt.io>").
+
 -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"]}]).
 

+ 5 - 3
src/emqttd_trace_sup.erl

@@ -1,5 +1,5 @@
 %%--------------------------------------------------------------------
-%% Copyright (c) 2012-2017 Feng Lee <feng@emqtt.io>.
+%% 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 <feng@emqtt.io>").
+
 -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]}}.
 

+ 4 - 1
src/emqttd_trie.erl

@@ -1,5 +1,5 @@
 %%--------------------------------------------------------------------
-%% Copyright (c) 2012-2017 Feng Lee <feng@emqtt.io>.
+%% 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 <feng@emqtt.io>").
+
 -include("emqttd_trie.hrl").
 
 %% Mnesia Callbacks

+ 1 - 1
src/emqttd_vm.erl

@@ -1,5 +1,5 @@
 %%--------------------------------------------------------------------
-%% Copyright (c) 2012-2017 Feng Lee <feng@emqtt.io>.
+%% 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.

+ 3 - 1
src/lager_emqtt_backend.erl

@@ -1,5 +1,5 @@
 %%--------------------------------------------------------------------
-%% Copyright (c) 2012-2017 Feng Lee <feng@emqtt.io>.
+%% 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 <feng@emqtt.io>").
+
 -behaviour(gen_event).
 
 -include_lib("lager/include/lager.hrl").