refactor: delete stale code

'hash' strategy has been removed from config schema
hence no need to keep the compatibility code
This commit is contained in:
Zaiming (Stone) Shi 2022-12-19 20:19:32 +01:00
parent ad3a793910
commit e932569f34
2 changed files with 3 additions and 8 deletions

View File

@ -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) ->

View File

@ -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.