Cluster.Strategy.DNSPoll (libcluster v3.6.0)

Copy Markdown View Source

Assumes you have nodes that respond to the specified DNS query (A record), and which follow the node name pattern of <name>@<ip-address>. If your setup matches those assumptions, this strategy will periodically poll DNS and connect all nodes it finds.

Options

  • polling_interval - How often to poll in milliseconds (optional; default: 5_000)
  • query - DNS query to use (required; e.g. "my-app.example.com")
  • node_basename - The short name of the nodes you wish to connect to (required; e.g. "my-app")
  • prune - Disconnect nodes absent from the latest DNS answer (optional; default: true)

By default, each DNS answer is treated as the complete membership list. Set prune: false when DNS returns partial or rotating subsets so previously discovered peers stay connected. Erlang distribution still detects lost connections; libcluster retries a disconnected peer only when it appears in a subsequent DNS answer, without retaining an unbounded address history.

An empty answer removes previously discovered peers when pruning is enabled. The default resolver also returns an empty list on lookup failure, so it cannot distinguish that failure from an empty answer. With pruning disabled, neither triggers a discovery-driven disconnect.

Usage

config :libcluster,
  topologies: [
    dns_poll_example: [
      strategy: Elixir.Cluster.Strategy.DNSPoll,
      config: [
        polling_interval: 5_000,
        query: "my-app.example.com",
        node_basename: "my-app"]]]

Summary

Functions

Returns a specification to start this module under a supervisor.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

lookup_all_ips(q)

start_link(args)