View Source DNSCluster (dns_cluster v0.1.3)
Simple DNS based cluster discovery.
A DNS query is made every :interval
milliseconds to discover new ips.
Nodes will only be joined if their node basename matches the basename of the
current node. For example if node()
is myapp-123@fdaa:1:36c9:a7b:198:c4b1:73c6:1
,
a Node.connect/1
attempt will be made against every IP returned by the DNS query,
but will only be successful if there is a node running on the remote host with the same
basename, for example myapp-123@fdaa:1:36c9:a7b:198:c4b1:73c6:2
. Nodes running on
remote hosts, but with different basenames will fail to connect and will be ignored.
Examples
To start in your supervision tree, add the child:
children = [
...,
{DNSCluster, query: "myapp.internal"}
]
See the start_link/1
docs for all available options.
If you require more advanced clustering options and strategies, see the libcluster library.
Summary
Functions
Returns a specification to start this module under a supervisor.
Starts DNS based cluster discovery.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
Starts DNS based cluster discovery.
Options
:name
- the name of the cluster. Defaults toDNSCluster
.:query
- the required DNS query for node discovery, for example:"myapp.internal"
. The value:ignore
can be used to ignore starting the DNSCluster.:interval
- the millisec interval between DNS queries. Defaults to5000
.:connect_timeout
- the millisec timeout to allow discovered nodes to connect. Defaults to10_000
.
Examples
iex> DNSCluster.start_link(query: "myapp.internal")
{:ok, pid}
iex> DNSCluster.start_link(query: :ignore)
:ignore