Current section

Files

Jump to
libcluster lib strategy epmd.ex
Raw

lib/strategy/epmd.ex

defmodule Cluster.Strategy.Epmd do
@moduledoc """
This clustering strategy relies on Erlang's built-in distribution protocol.
You can have libcluster automatically connect nodes on startup for you by configuring
the strategy like below:
config :libcluster,
topologies: [
epmd_example: [
strategy: #{__MODULE__},
config: [
hosts: [:"a@127.0.0.1", :"b@127.0.0.1"]]]]
"""
use Cluster.Strategy
def start_link(opts) do
topology = Keyword.fetch!(opts, :topology)
config = Keyword.get(opts, :config, [])
connect = Keyword.get(opts, :connect)
case Keyword.get(config, :hosts, []) do
[] ->
:ignore
nodes when is_list(nodes) ->
Cluster.Strategy.connect_nodes(topology, connect, nodes)
:ignore
end
end
end