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

refactor: delete stale code

'hash' strategy has been removed from config schema
hence no need to keep the compatibility code
Zaiming (Stone) Shi 3 лет назад
Родитель
Сommit
e932569f34
2 измененных файлов с 3 добавлено и 8 удалено
  1. 0 5
      apps/emqx/src/emqx_shared_sub.erl
  2. 3 3
      apps/emqx/test/emqx_shared_sub_SUITE.erl

+ 0 - 5
apps/emqx/src/emqx_shared_sub.erl

@@ -81,8 +81,6 @@
     | round_robin_per_group
     | sticky
     | local
-    %% same as hash_clientid, backward compatible
-    | hash
     | hash_clientid
     | hash_topic.
 
@@ -360,9 +358,6 @@ pick_subscriber(Group, Topic, Strategy, ClientId, SourceTopic, Subs) ->
 
 do_pick_subscriber(_Group, _Topic, random, _ClientId, _SourceTopic, Count) ->
     rand:uniform(Count);
-do_pick_subscriber(Group, Topic, hash, ClientId, SourceTopic, Count) ->
-    %% backward compatible
-    do_pick_subscriber(Group, Topic, hash_clientid, ClientId, SourceTopic, Count);
 do_pick_subscriber(_Group, _Topic, hash_clientid, ClientId, _SourceTopic, Count) ->
     1 + erlang:phash2(ClientId) rem Count;
 do_pick_subscriber(_Group, _Topic, hash_topic, _ClientId, SourceTopic, Count) ->

+ 3 - 3
apps/emqx/test/emqx_shared_sub_SUITE.erl

@@ -378,8 +378,8 @@ t_sticky_unsubscribe(Config) when is_list(Config) ->
     ok.
 
 t_hash(Config) when is_list(Config) ->
-    ok = ensure_config(hash, false),
-    test_two_messages(hash).
+    ok = ensure_config(hash_clientid, false),
+    test_two_messages(hash_clientid).
 
 t_hash_clinetid(Config) when is_list(Config) ->
     ok = ensure_config(hash_clientid, false),
@@ -486,7 +486,7 @@ test_two_messages(Strategy, Group) ->
         sticky -> ?assertEqual(UsedSubPid1, UsedSubPid2);
         round_robin -> ?assertNotEqual(UsedSubPid1, UsedSubPid2);
         round_robin_per_group -> ?assertNotEqual(UsedSubPid1, UsedSubPid2);
-        hash -> ?assertEqual(UsedSubPid1, UsedSubPid2);
+        hash_clientid -> ?assertEqual(UsedSubPid1, UsedSubPid2);
         _ -> ok
     end,
     ok.