Просмотр исходного кода

fix(mqtt-cap): use global config as defaults

Don't use default values in module, use global mqtt config as default
William Yang 2 лет назад
Родитель
Сommit
be6cd5705f
2 измененных файлов с 16 добавлено и 14 удалено
  1. 14 14
      apps/emqx/src/emqx_mqtt_caps.erl
  2. 2 0
      apps/emqx/test/emqx_channel_SUITE.erl

+ 14 - 14
apps/emqx/src/emqx_mqtt_caps.erl

@@ -58,18 +58,18 @@
     exclusive_subscription
 ]).
 
--define(DEFAULT_CAPS, #{
-    max_packet_size => ?MAX_PACKET_SIZE,
-    max_clientid_len => ?MAX_CLIENTID_LEN,
-    max_topic_alias => ?MAX_TOPIC_AlIAS,
-    max_topic_levels => ?MAX_TOPIC_LEVELS,
-    max_qos_allowed => ?QOS_2,
-    retain_available => true,
-    wildcard_subscription => true,
-    subscription_identifiers => true,
-    shared_subscription => true,
-    exclusive_subscription => false
-}).
+-define(DEFAULT_CAPS_KEYS, [
+    max_packet_size,
+    max_clientid_len,
+    max_topic_alias,
+    max_topic_levels,
+    max_qos_allowed,
+    retain_available,
+    wildcard_subscription,
+    subscription_identifiers,
+    shared_subscription,
+    exclusive_subscription
+]).
 
 -spec check_pub(
     emqx_types:zone(),
@@ -152,12 +152,12 @@ do_check_sub(_Flags, _Caps, _, _) ->
     ok.
 
 get_caps(Zone) ->
-    get_caps(maps:keys(?DEFAULT_CAPS), Zone).
+    get_caps(?DEFAULT_CAPS_KEYS, Zone).
 get_caps(Keys, Zone) ->
     maps:with(
         Keys,
         maps:merge(
-            ?DEFAULT_CAPS,
+            emqx_config:get([mqtt]),
             emqx_config:get_zone_conf(Zone, [mqtt])
         )
     ).

+ 2 - 0
apps/emqx/test/emqx_channel_SUITE.erl

@@ -267,6 +267,8 @@ t_chan_info(_) ->
 t_chan_caps(_) ->
     ?assertMatch(
         #{
+            exclusive_subscription := false,
+            max_packet_size := 1048576,
             max_clientid_len := 65535,
             max_qos_allowed := 2,
             max_topic_alias := 65535,