Parcourir la source

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

Don't use default values in module, use global mqtt config as default
William Yang il y a 2 ans
Parent
commit
be6cd5705f
2 fichiers modifiés avec 16 ajouts et 14 suppressions
  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
     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(
 -spec check_pub(
     emqx_types:zone(),
     emqx_types:zone(),
@@ -152,12 +152,12 @@ do_check_sub(_Flags, _Caps, _, _) ->
     ok.
     ok.
 
 
 get_caps(Zone) ->
 get_caps(Zone) ->
-    get_caps(maps:keys(?DEFAULT_CAPS), Zone).
+    get_caps(?DEFAULT_CAPS_KEYS, Zone).
 get_caps(Keys, Zone) ->
 get_caps(Keys, Zone) ->
     maps:with(
     maps:with(
         Keys,
         Keys,
         maps:merge(
         maps:merge(
-            ?DEFAULT_CAPS,
+            emqx_config:get([mqtt]),
             emqx_config:get_zone_conf(Zone, [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(_) ->
 t_chan_caps(_) ->
     ?assertMatch(
     ?assertMatch(
         #{
         #{
+            exclusive_subscription := false,
+            max_packet_size := 1048576,
             max_clientid_len := 65535,
             max_clientid_len := 65535,
             max_qos_allowed := 2,
             max_qos_allowed := 2,
             max_topic_alias := 65535,
             max_topic_alias := 65535,