Ver código fonte

improve: rename quota option name

JianBo He 5 anos atrás
pai
commit
f6b35d63f2
2 arquivos alterados com 31 adições e 27 exclusões
  1. 14 10
      etc/emqx.conf
  2. 17 17
      priv/emqx.schema

+ 14 - 10
etc/emqx.conf

@@ -863,25 +863,29 @@ zone.external.enable_flapping_detect = off
 ##
 ##
 ## Value: Number,Duration
 ## Value: Number,Duration
 ## Example: 100 messages per 10 seconds.
 ## Example: 100 messages per 10 seconds.
-#zone.external.rate_limit.conn_messages_in = 100, 10s
+#zone.external.rate_limit.conn_messages_in = 100,10s
 
 
 ## Bytes limit for a external MQTT connections.
 ## Bytes limit for a external MQTT connections.
 ##
 ##
 ## Value: Number,Duration
 ## Value: Number,Duration
 ## Example: 100KB incoming per 10 seconds.
 ## Example: 100KB incoming per 10 seconds.
-#zone.external.rate_limit.conn_bytes_in = 100KB, 10s
+#zone.external.rate_limit.conn_bytes_in = 100KB,10s
 
 
-## Messages quota for the external MQTT connections. This value
-## consumed by the number of PUBLISH message forwarding times.
+## Messages quota for the each of external MQTT connection.
+## This value consumed by the number of recipient on a message.
 ##
 ##
-## This option allows you to configure up to 2 parameters that are split by '|'.
-## The former represents the quota per connection, while the latter represents
-## the quota for all external zone's connections.
+## Value: Number, Duration
+##
+## Example: 100 messaegs per 1s
+#zone.external.quota.conn_messages_routing = 100,1s
+
+## Messages quota for the all of external MQTT connections.
+## This value consumed by the number of recipient on a message.
 ##
 ##
 ## Value: Number, Duration
 ## Value: Number, Duration
 ##
 ##
-## Example: 100 messaegs per 1s and 200000 messages per 1s in zone
-#zone.external.quota.routing.messages = 100,1s | 200000,1s
+## Example: 200000 messaegs per 1s
+#zone.external.quota.overall_messages_routing = 200000,1s
 
 
 ## All the topics will be prefixed with the mountpoint path if this option is enabled.
 ## All the topics will be prefixed with the mountpoint path if this option is enabled.
 ##
 ##
@@ -2214,4 +2218,4 @@ alarm.size_limit = 1000
 ## Default: 24h
 ## Default: 24h
 alarm.validity_period = 24h
 alarm.validity_period = 24h
 
 
-{{ additional_configs }}
+{{ additional_configs }}

+ 17 - 17
priv/emqx.schema

@@ -997,15 +997,19 @@ end}.
   {default, off}
   {default, off}
 ]}.
 ]}.
 
 
-{mapping, "zone.$name.rate_limit.messages_in", "emqx.zones", [
+{mapping, "zone.$name.rate_limit.conn_messages_in", "emqx.zones", [
   {datatype, string}
   {datatype, string}
 ]}.
 ]}.
 
 
-{mapping, "zone.$name.rate_limit.bytes_in", "emqx.zones", [
+{mapping, "zone.$name.rate_limit.conn_bytes_in", "emqx.zones", [
   {datatype, string}
   {datatype, string}
 ]}.
 ]}.
 
 
-{mapping, "zone.$name.quota.routing.messages", "emqx.zones", [
+{mapping, "zone.$name.quota.conn_messages_routing", "emqx.zones", [
+  {datatype, string}
+]}.
+
+{mapping, "zone.$name.quota.overall_messages_routing", "emqx.zones", [
   {datatype, string}
   {datatype, string}
 ]}.
 ]}.
 
 
@@ -1115,18 +1119,13 @@ end}.
                (["response_information"], Val) ->
                (["response_information"], Val) ->
                    {response_information, iolist_to_binary(Val)};
                    {response_information, iolist_to_binary(Val)};
                (["rate_limit", "conn_messages_in"], Val) ->
                (["rate_limit", "conn_messages_in"], Val) ->
-                    {ratelimit, {conn_messages_in, Ratelimit(Val)}};
+                   {ratelimit, {conn_messages_in, Ratelimit(Val)}};
                (["rate_limit", "conn_bytes_in"], Val) ->
                (["rate_limit", "conn_bytes_in"], Val) ->
-                    {ratelimit, {conn_bytes_in, Ratelimit(Val)}};
-               (["quota", "routing", "messages"], Val) ->
-                    Policy = case string:tokens(Val, "|") of
-                                 [T] ->
-                                     [{conn_messages_routing, Ratelimit(T)}];
-                                 [T1, T2] ->
-                                     [{conn_messages_routing, Ratelimit(T1)},
-                                      {overall_messages_routing, Ratelimit(T2)}]
-                             end,
-                    {quota, Policy};
+                   {ratelimit, {conn_bytes_in, Ratelimit(Val)}};
+               (["quota", "conn_messages_routing"], Val) ->
+                   {quota, {conn_messages_routing, Ratelimit(Val)}};
+               (["quota", "overall_messages_routing"], Val) ->
+                   {quota, {overall_messages_routing, Ratelimit(Val)}};
                ([Opt], Val) ->
                ([Opt], Val) ->
                     {list_to_atom(Opt), Val}
                     {list_to_atom(Opt), Val}
             end,
             end,
@@ -1137,9 +1136,10 @@ end}.
               maps:update_with(list_to_atom(Name),
               maps:update_with(list_to_atom(Name),
                                fun(Opts) ->
                                fun(Opts) ->
                                    case NVal of
                                    case NVal of
-                                       {ratelimit, Rl} ->
-                                           Rls = proplists:get_value(ratelimit, Opts, []),
-                                           lists:keystore(ratelimit, 1, Opts, {ratelimit, [Rl|Rls]});
+                                       {Key, Rl} when Key == ratelimit;
+                                                      Key == quota ->
+                                           Rls = proplists:get_value(Key, Opts, []),
+                                           lists:keystore(Key, 1, Opts, {Key, [Rl|Rls]});
                                        _ ->
                                        _ ->
                                            [NVal|Opts]
                                            [NVal|Opts]
                                    end
                                    end