RaftEx.Cluster
(raft_ex v0.1.0)
View Source
High-level API for managing distributed RaftEx clusters.
Summary
Functions
Find the current leader for a given cluster name.
Form a distributed Raft cluster across multiple nodes.
Handle a topology change event from NodeDiscovery.
Join an existing Raft cluster as a new node.
Get the status of all RaftEx servers on this node.
Functions
@spec find_leader(term()) :: {:ok, RaftEx.Types.server_id()} | {:error, term()}
Find the current leader for a given cluster name.
First checks the local Leaderboard, then queries a member server.
@spec form_cluster(term(), RaftEx.Machine.machine(), [node()], keyword()) :: {:ok, [RaftEx.Types.server_id()]} | {:error, term()}
Form a distributed Raft cluster across multiple nodes.
This is the primary entry point for multi-node cluster formation. Each node should call this with the same set of participating nodes.
Parameters
cluster_name- name for this Raft clustermachine- the state machine configuration{:machine, Module, args}nodes- list of participating Erlang nodes (including self)opts- optional keyword list::system- RaftEx system name (default::default):timeout- timeout in ms (default: 10_000):seed_node- node to act as seed (default: first node in sorted list)
Returns {:ok, local_server_ids} or {:error, reason}.
@spec handle_topology_change([node()], term(), RaftEx.Machine.machine()) :: :ok
Handle a topology change event from NodeDiscovery.
When new nodes are detected, attempts to add them as cluster members.
@spec join_cluster(term(), RaftEx.Machine.machine(), [node()], node(), keyword()) :: {:ok, [RaftEx.Types.server_id()]} | {:error, term()}
Join an existing Raft cluster as a new node.
Get the status of all RaftEx servers on this node.