Skip to content

Commit

Permalink
refactor: delete stale code
Browse files Browse the repository at this point in the history
'hash' strategy has been removed from config schema
hence no need to keep the compatibility code
  • Loading branch information
zmstone committed Dec 19, 2022
1 parent ad3a793 commit e932569
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
5 changes: 0 additions & 5 deletions apps/emqx/src/emqx_shared_sub.erl
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@
| round_robin_per_group
| sticky
| local
%% same as hash_clientid, backward compatible
| hash
| hash_clientid
| hash_topic.

Expand Down Expand Up @@ -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) ->
Expand Down
6 changes: 3 additions & 3 deletions apps/emqx/test/emqx_shared_sub_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit e932569

Please sign in to comment.