-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add wrapping around to key_to_nodes
#40
base: main
Are you sure you want to change the base?
Conversation
Kindly pinging @Gazler as well :) |
@@ -246,27 +246,32 @@ defmodule HashRing do | |||
|
|||
case :gb_trees.iterator_from(hash, r) |> :gb_trees.next() do | |||
{_key, node, iter} -> | |||
find_nodes_from_iter(iter, count - 1, [node]) | |||
find_nodes_from_iter(r, iter, count - 1, [node], _restarted? = false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if restarted?
is needed, but I added it to be safe.
On second though, if we count = min(length(nodes), count)
it's not needed.
results | ||
:none -> | ||
if restarted? do | ||
Enum.reverse(results) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
results
were not reversed originally, but I think they need to be since the "happy path" does it (on line 257).
key_to_nodes
👋
This is a possible fix for #39