Closed rlipscombe closed 3 years ago
The need to specify the node names for the epmd strategy is annoying when all the nodes are running on the same host.
So I wrote this, which uses erl_epmd.names() to find local nodes:
erl_epmd.names()
defmodule Cluster.Strategy.LocalEpmd do use Cluster.Strategy alias Cluster.Strategy.State def start_link([%State{} = state]) do suffix = get_host_suffix(Node.self()) {:ok, nodes} = :erl_epmd.names() nodes = for {n, _} <- nodes, do: List.to_atom(n ++ suffix) Cluster.Strategy.connect_nodes(state.topology, state.connect, state.list_nodes, nodes) :ignore end defp get_host_suffix(self) do self = Atom.to_charlist(self) [_, suffix] = :string.split(self, '@') '@' ++ suffix end end
...useful?
I'd be happy to merge this as a PR when you have the time to put one together :)
Done.
The need to specify the node names for the epmd strategy is annoying when all the nodes are running on the same host.
So I wrote this, which uses
erl_epmd.names()
to find local nodes:...useful?