Explorar o código

sync with imac

Feng Lee %!s(int64=11) %!d(string=hai) anos
pai
achega
eb84783d4a
Modificáronse 4 ficheiros con 28 adicións e 9 borrados
  1. 13 0
      apps/emqtt/src/emqtt_topic.erl
  2. 1 4
      apps/emqttd/src/emqttd_stats.erl
  3. 8 0
      quickstart.md
  4. 6 5
      rel/files/app.config

+ 13 - 0
apps/emqtt/src/emqtt_topic.erl

@@ -32,6 +32,8 @@
  
 -export([match/2, validate/1, triples/1, words/1, wildcard/1]).
 
+-export([systop/1]).
+
 %-type type()   :: static | dynamic.
 
 -type word()   :: '' | '+' | '#' | binary().
@@ -164,3 +166,14 @@ word(<<"+">>) -> '+';
 word(<<"#">>) -> '#';
 word(Bin)     -> Bin.
 
+%%------------------------------------------------------------------------------
+%% @doc '$SYS' Topic.
+%% @end
+%%------------------------------------------------------------------------------
+
+systop(Name) when is_atom(Name) ->
+    list_to_binary(lists:concat(["$SYS/brokers/", node(), "/", Name]));
+
+systop(Name) when is_binary(Name) ->
+    list_to_binary(["$SYS/brokers/", atom_to_list(node()), "/", Name]).
+

+ 1 - 4
apps/emqttd/src/emqttd_stats.erl

@@ -122,7 +122,7 @@ init([]) ->
     Topics = ?SYSTOP_CLIENTS ++ ?SYSTOP_SESSIONS ++ ?SYSTOP_PUBSUB,
     [ets:insert(?STATS_TAB, {Topic, 0}) || Topic <- Topics],
     % Create $SYS Topics
-    [ok = emqttd_pubsub:create(systop(Topic)) || Topic <- Topics],
+    [ok = emqttd_pubsub:create(emqtt_topic:systop(Topic)) || Topic <- Topics],
     SysInterval = proplists:get_value(sys_interval, Options, 60),
     {ok, #state{}}.
 
@@ -150,6 +150,3 @@ code_change(_OldVsn, State, _Extra) ->
 %%% Internal functions
 %%%=============================================================================
 
-systop(Name) when is_atom(Name) ->
-    list_to_binary(lists:concat(["$SYS/brokers/", node(), "/", Name])).
-

+ 8 - 0
quickstart.md

@@ -123,3 +123,11 @@ retain  |  Retain(0, 1)
 topic   |  Topic
 message |  Message
 
+
+## Contributors
+
+@hejin1026 <260495915 at qq.com>
+
+@desoulter <assoulter123 at gmail.com>
+
+@turtleDeng

+ 6 - 5
rel/files/app.config

@@ -66,17 +66,18 @@
         {max_queue, 1000},
         {store_qos0, false}
     ]},
+    %% MQTT Broker
+    {mqtt_broker, [
+        %% System interval of publishing broker $SYS messages
+        {sys_interval, 60}
+    ]},
     %% Retain messages
     {retained, [
         {max_message_num, 100000},
         {max_playload_size, 4096}
     ]},
     %% PubSub
-    {pubsub, []},
-    %% Broker
-    {broker, [
-        {sys_interval, 60}
-    ]},
+    {mqtt_pubsub, []},
     %% Metrics
     {metrics, [
         {pub_interval, 60}