View Source Cluster.Strategy.ErlangHosts (libcluster v3.4.1)
This clustering strategy relies on Erlang's built-in distribution protocol by
using a .hosts.erlang
file (as used by the :net_adm
module).
Please see the net_adm docs for more details.
In short, the following is the gist of how it works:
File
.hosts.erlang
consists of a number of host names written as Erlang terms. It is looked for in the current work directory, the user's home directory, and $OTP_ROOT (the root directory of Erlang/OTP), in that order.
This looks a bit like the following in practice:
'super.eua.ericsson.se'.
'renat.eua.ericsson.se'.
'grouse.eua.ericsson.se'.
'gauffin1.eua.ericsson.se'.
You can have libcluster
automatically connect nodes on startup for you by configuring
the strategy like below:
config :libcluster,
topologies: [
erlang_hosts_example: [
strategy: Elixir.Cluster.Strategy.ErlangHosts,
config: [timeout: 30_000]
]
]
An optional timeout can be specified in the config. This is the timeout that
will be used in the GenServer to connect the nodes. This defaults to
:infinity
meaning that the connection process will only happen when the
worker is started. Any integer timeout will result in the connection process
being triggered. In the example above, it has been configured for 30 seconds.
Summary
Functions
Returns a specification to start this module under a supervisor.
Callback implementation for Cluster.Strategy.start_link/1
.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
Callback implementation for Cluster.Strategy.start_link/1
.