# `SuperPi.Cluster`
[🔗](https://github.com/oleksandr/super-pi-beam/blob/v0.1.0/lib/super_pi/cluster.ex#L1)

The distributed BEAM cluster: nodes connected by `libcluster`, one shared PostgreSQL, one machine
per conversation (`SuperPi.Conversation.Locator`).

## Configuration

`config :super_pi, :cluster` is set from the environment (`config/runtime.exs`):

| Variable | Meaning |
|---|---|
| `SUPER_PI_CLUSTER_STRATEGY` | `none` (default), `epmd`, `dnspoll`, `kubernetes_dns`, `gossip` |
| `SUPER_PI_CLUSTER_HOSTS` | `epmd`: node names, comma separated (`super_pi@10.0.0.1,super_pi@10.0.0.2`) |
| `SUPER_PI_CLUSTER_DNS_QUERY` | `dnspoll`: a name that resolves to every node (A records) |
| `SUPER_PI_CLUSTER_NODE_BASENAME` | `dnspoll`, `kubernetes_dns`: the node name before `@` (default `super_pi`) |
| `SUPER_PI_CLUSTER_K8S_SERVICE` | `kubernetes_dns`: the headless Service name |
| `SUPER_PI_CLUSTER_POLL_MS` | polling interval for `dnspoll` and `kubernetes_dns` (default 5000) |
| `SUPER_PI_CLUSTER_GOSSIP_SECRET` | `gossip`: shared secret for the multicast packets |
| `SUPER_PI_CLUSTER_GOSSIP_PORT` | `gossip`: UDP port (default 45892) |

Nodes also need a distribution name and a shared cookie (`RELEASE_NODE`, `RELEASE_COOKIE` with
a release; `--name` and `--cookie` otherwise). A cluster requires PostgreSQL: with SQLite the
application refuses to start.

# `children`

Child specs for the application: the libcluster supervisor when a strategy is configured.

# `enabled?`

True when a cluster strategy is configured.

# `status`

A summary of the cluster: this node, the connected nodes, the registry and supervisor members,
and how many conversation machines run on each node.

# `strategy`

# `topologies`

The libcluster topologies from configuration. Empty when clustering is off.

# `validate!`

Raises when the configuration cannot work: a cluster over SQLite. Called at application start.

---

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