# `PaxosKV.Cluster`

Manages the cluster state and node membership.

This module tracks which nodes are part of the distributed cluster, monitors
node connections, and maintains the configured cluster size. It provides
functions to query the current cluster state and check if a quorum is present.

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `cluster_size`

Returns the configured cluster size.

This is the total number of nodes expected to participate in the cluster,
not necessarily the number of currently connected nodes.

## Examples

    iex> PaxosKV.Cluster.cluster_size()
    3

# `nodes`

Returns the list of currently connected nodes in the cluster.

## Examples

    iex> PaxosKV.Cluster.nodes()
    [:node1@localhost, :node2@localhost]

# `nodes_and_cluster_size`

Returns both the connected nodes list and the cluster size as a tuple.

## Examples

    iex> PaxosKV.Cluster.nodes_and_cluster_size()
    {[:node1@localhost, :node2@localhost], 3}

# `ping`

# `quorum?`

Checks if the cluster currently has a quorum.

A quorum exists when more than half of the configured cluster size nodes
are connected.

## Examples

    iex> PaxosKV.Cluster.quorum?()
    true

# `resize_cluster`

Dynamically resizes the cluster to a new size.

Attempts to update the cluster size on all nodes. Returns `:ok` if all
nodes successfully updated to the new size, `:not_in_sync` if nodes
disagreed, or `{:error, reason}` if the operation failed.

## Examples

    iex> PaxosKV.Cluster.resize_cluster(5)
    :ok

# `start_link`

# `subscribe`

Subscribes the caller process or the spcified pid for `:quorum_reached` and
`:quorum_lost` cluster events. The events are delivered as standard erlang
messages.

# `sync_with_node`

# `unsubscribe`

The opposite of `subscribe/0,1`. It removes the given pid from
the list of subscribed processes.

---

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