# `Malla.Cluster`
[🔗](https://github.com/netkubes/malla/blob/main/lib/malla/cluster.ex#L21)

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](guides/08-distribution/01-cluster-setup.md) 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.

# `connect`

```elixir
@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.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
