Closed sleipnir closed 1 year ago
choose_node
receives all members of the cluster plus the identifier, so that means that you could just pick one of the members based on the identifer?
@arjan Yes I agree. As long as I know at that point which identifier to choose. We would have to receive some information about which preferred Node the user wants to connect this Process
This could be passed as an option to the DynamicSupervisor of the process.
@sleipnir, I'm in the same boat. Currently looking for a way to start my processes on a specific node. My app require a specific node based on volume id (disk storage). Did you find a way to accomplish your goal?
@arjan, it seems that the identifier
given to choose_node/2
is the hash of the child_spec
(without the :id
) in Horde.DynamicSupervisor.start_child/2
. In my case it's not feasible because the params given to :start
would differ between processes.
I think the changes made in #128 and being a fix for compatibility issues with Elixir.DynamicSupervisor
broke the way of defining custom distribution strategies based on a specific identifier (or at least making it very cumbersome).
@sleipnir, I'm in the same boat. Currently looking for a way to start my processes on a specific node. My app require a specific node based on volume id (disk storage). Did you find a way to accomplish your goal?
@arjan, it seems that the
identifier
given tochoose_node/2
is the hash of thechild_spec
(without the:id
) inHorde.DynamicSupervisor.start_child/2
. In my case it's not feasible because the params given to:start
would differ between processes.
@redrabbit Unfortunately I couldn't find a solution and ended up using a singleton process on the cluster. Still trying to find time to send a PR with a proposal for this feature but it's a little difficult
@redrabbit the second argument of choose_node/2
is the list of members. If you filter that list first you can control the set of nodes which get selected. This is how I implemented it:
def choose_node(identifier, members) do
members = Enum.filter(members, fn member -> ... end)
Horde.UniformDistribution.choose_node(identifier, members)
end
@arjan like I stated in my previous comment, the identifier
passed to choose_node/2
is not very usable because it's the hash of child_spec without :id
. So how do I filter my members based on the identifier?
I'm sorry, I did not read it carefully enough.
I think it would be a nice addition to add the original child_spec
as a third argument to the choose_node callback function.
¿Any updates on this issue? I'm having the same problem, I need some of the child's info to filter out members from the list. ¿Any new ideas on how to work around this?
It seems easy enough to create a branch add this third argument, and then create a PR for it?
AFAICT you only need to change these lines
choose_node/2 receives a child_spec. Since child_spec is an ordinary map, you could add a :preferred_node into it, and choose_node would have something to decide where to start your process.
Closing this because PR https://github.com/derekkraan/horde/pull/239 can solve the problem.
Hello recently I had the need to start a process on a specific Node and still make this process managed by Horde.DynamicSupervisor and Horde.Registry, unfortunately it is not currently possible to register a process on a specific Node via Horde. It might be possible to accomplish this by creating a customized Horde.DistributionStrategy strategy, but the signature of choose_node did not seem flexible to me so that I could provide the correct topology information expected to start the process at a specific Node. Would it be possible to accomplish this in any way?
Thanks!