Malla.Cluster (malla v0.0.1-rc.1)

Copy Markdown View Source

Provides utilities to connect Erlang nodes in a cluster.

This module is designed to simplify node connection, especially in orchestrated environments like Kubernetes, by using DNS-based discovery.

While Malla can work with any node connection method, this module provides a convenient, automated way to form a cluster.

See the Cluster Setup guide for more details.

This node also starts a GenServer that will monitor :malla application env variable :malla_connect_nodes, calling connect/1 automatically each 5000 milliseconds.

Summary

Functions

Tries to connect local node to one or serveral other nodes, trying different approaches.

Functions

connect(nodes)

@spec connect(String.t() | [String.t()]) :: :ok

Tries to connect local node to one or serveral other nodes, trying different approaches.

Entries are expected to be in either of the two following forms:

  • name@domain_or_ip
  • domain

For each entry, we will try to identify the remote node and connect to it, unless already connected.

In the first form, we first try to find if domain_or_ip is a DNS SRV record. If we find none, we try to resolve it as an A record, and for each found ip, we try to connect to node :'name@ip'. If we found a SRV record, we ignore name and use names and ips from SRV info.

In the second form, we only try to find SRV, and use names and ips from it.