Raft v0.1.0 Raft

Link to this section Summary

Functions

Gets an entry from the log. This should only be used for testing purposes

Returns the leader according to the given peer

Reads state that has been applied to the state machine

Sets peers configuration. The new configuration will be merged with any existing configuration

Starts a new peer with a given Config.t

Returns the current status for a peer. This is used for debugging and testing purposes only

Gracefully stops the node

Creates a test cluster for running on a single. Should only be used for development and testing

Used to apply a new change to the application fsm. This is done in consistent manner. This operation blocks until the log has been replicated to a majority of servers

Link to this section Types

Link to this type peer()
peer() :: atom() | {atom(), atom()}

Link to this section Functions

Link to this function get_entry(to, index)
get_entry(peer(), non_neg_integer()) ::
  {:ok, Raft.Log.Entry.t()} | {:error, term()}

Gets an entry from the log. This should only be used for testing purposes.

Link to this function leader(name)
leader(peer()) :: peer() | :none

Returns the leader according to the given peer.

Link to this function read(leader, cmd, timeout \\ 3000)
read(peer(), term(), any()) ::
  {:ok, term()} | {:error, :timeout} | {:error, :not_leader}

Reads state that has been applied to the state machine.

Link to this function set_configuration(peer, configuration)
set_configuration(peer(), [peer()]) ::
  {:ok, Raft.Configuration.t()} | {:error, term()}

Sets peers configuration. The new configuration will be merged with any existing configuration.

Link to this function start_node(name, config)
start_node(peer(), Raft.Config.t()) :: {:ok, pid()} | {:error, term()}

Starts a new peer with a given Config.t.

Link to this function status(name)
status(peer()) :: {:ok, %{}} | {:error, :no_node}

Returns the current status for a peer. This is used for debugging and testing purposes only.

Link to this function stop_node(name)

Gracefully stops the node.

Link to this function test_cluster()
test_cluster() :: {peer(), peer(), peer()}

Creates a test cluster for running on a single. Should only be used for development and testing.

Link to this function write(leader, cmd, timeout \\ 3000)
write(peer(), term(), any()) ::
  {:ok, term()} | {:error, :timeout} | {:error, :not_leader}

Used to apply a new change to the application fsm. This is done in consistent manner. This operation blocks until the log has been replicated to a majority of servers.