derekkraan / horde

Horde is a distributed Supervisor and Registry backed by DeltaCrdt
MIT License
1.32k stars 106 forks source link

Hash the child spec minus the id for consistent hashing. #128

Closed derekkraan closed 5 years ago

derekkraan commented 5 years ago

With #122 we started assigning random ids to bring us in line with DynamicSupervisor's API. This broke consistent hashing. This PR restores that, by hashing the child spec minus the id.

Caveat: if you are starting processes that only differ by the id, and want them to end up on different nodes, then you will have to add something to the child_spec to differentiate them, or alternatively supply your own distribution_strategy.

Also removes xxhash as dependency.

~This PR needs a test.~

redrabbit commented 3 years ago

Caveat: if you are starting processes that only differ by the id, and want them to end up on different nodes, then you will have to add something to the child_spec to differentiate them, or alternatively supply your own distribution_strategy.

Hi @derekkraan, the changes of this PR make it hard to implement a custom distribution strategy based on the child_spec given to Horde.DynamicSupervisor.start_child/2. Is Horde.DynamicSupervisor meant to be used only with a consistent hash mechanism?

In my project I need to choose a node based on some criteria given to the child_spec. Is there any way to achieve this?