buraksezer / consistent

Consistent hashing with bounded loads in Golang
https://research.googleblog.com/2017/04/consistent-hashing-with-bounded-loads.html
MIT License
693 stars 69 forks source link

`ErrInsufficientMemberCount` when calling `GetClosestN(key, 2)` on a Consistent with 2 members #6

Closed ryanschneider closed 5 years ago

ryanschneider commented 5 years ago

I've been testing this library as a possible solution and came across this curious behavior. I have a Consistent object with 3 members, and then .Remove()'d one of them, and started getting ErrInsufficientMemberCount, which surprised me.

I see in the code you check against len(c.members)-1, is this a typo or or there some reason why all the members shouldn't be returned?

https://github.com/buraksezer/consistent/blob/master/consistent.go#L308

buraksezer commented 5 years ago

Fixed with #7