Module ra

The primary module for interacting with ra servers and clusters.

Description

The primary module for interacting with ra servers and clusters.

Data Types

cluster_name()

cluster_name() = ra_cluster_name()

environment_param()

environment_param() = {data_dir, file:filename()} | {wal_data_dir, file:filename()} | {segment_max_entries, non_neg_integer()} | {wal_max_size_bytes, non_neg_integer()} | {wal_compute_checksums, boolean()} | {wal_write_strategy, default | o_sync}

index()

index() = ra_index()

query_fun()

query_fun() = fun((term()) -> term()) | {M::module(), F::atom(), A::list()}

ra_cmd_ret()

ra_cmd_ret() = ra_server_proc:ra_cmd_ret()

server_id()

server_id() = ra_server_id()

Function Index

add_member/2Add a ra server id to a ra cluster's membership configuration.
add_member/3Same as add_member/2 but also accepts a timeout.
aux_command/2Executes (using a call) an auxiliary command that the state machine can handle.
cast_aux_command/2Executes (using a cast) an auxiliary command that the state machine can handle.
consistent_query/2Query the state machine with a consistency guarantee.
consistent_query/3Same as consistent_query/2 but accepts a custom timeout.
delete_cluster/1Deletes a ra cluster in an orderly fashion.
delete_cluster/2Same as delete_cluster/1 but also accepts a timeout.
force_delete_server/2Deletes a ra server The server is forcefully deleted.
initial_members/1Returns a list of initial (seed) cluster members.
initial_members/2
leader_query/2Query the machine state on the current leader node.
leader_query/3Same as leader_query/2 but accepts a custom timeout.
leave_and_delete_server/3A safe way to remove an active server from its cluster.
leave_and_delete_server/4Same as leave_and_delete_server/2 but also accepts a timeout.
leave_and_terminate/3A safe way to remove an active server from its cluster.
leave_and_terminate/4Same as leave_and_terminate/2 but also accepts a timeout.
local_query/2Query the machine state on any available server.
local_query/3Same as local_query/2 but accepts a custom timeout.
members/1Returns a list of cluster members.
members/2Returns a list of cluster members.
new_uid/1generates a random uid using the provided source material for the first 6 characters.
overview/0Returns a map of overview data of the default Ra system on the current Erlang node.
overview/1Returns a map of overview data of the Ra system on the current Erlang node.
ping/2
pipeline_command/2Sends a command to the ra server using a gen_statem:cast without any correlation identifier.
pipeline_command/3Same as pipeline_command/4 but uses a hardcoded priority of low.
pipeline_command/4Submits a command to the ra server using a gen_statem:cast, passing an optional process-scoped term as correlation identifier.
process_command/2Same as process_command/3 with the default timeout of 5000 ms.
process_command/3Submits a command to a ra server.
register_external_log_reader/1Registers an external log reader.
remove_member/2Removes a server from the cluster's membership configuration.
remove_member/3Same as remove_member/2 but also accepts a timeout.
restart_server/1Restarts a previously successfully started ra server in the default system.
restart_server/2Restarts a previously successfully started ra server.
restart_server/3Restarts a previously successfully started ra server.
start/0Starts the ra application.
start/1Starts the ra application.
start_cluster/1Same as start_cluster/2 but uses the default Ra system.
start_cluster/2Starts a new distributed ra cluster.
start_cluster/3Same as start_cluster/2 but accepts a custom timeout.
start_cluster/4Starts a new distributed ra cluster.
start_in/1Starts the ra application with a provided data directory.
start_or_restart_cluster/4Starts or restarts a ra cluster.
start_or_restart_cluster/5Same as start_or_restart_cluster/4 but accepts a custom timeout.
start_server/1Starts a ra server in the default system.
start_server/2Starts a ra server.
start_server/5Starts a new distributed ra cluster.
stop_server/1Stops a ra server in the default system.
stop_server/2Stops a ra server.
transfer_leadership/2Transfers leadership from the leader to a follower.
trigger_election/1Makes the server enter a pre-vote state and attempt to become the leader.
trigger_election/2Same as trigger_election/2 but also accepts a timeout.

Function Details

add_member/2

add_member(ServerLoc::ra_server_id() | [ra_server_id()], ServerId::ra_server_id()) -> ra_cmd_ret() | {error, already_member} | {error, cluster_change_not_permitted}

ServerLoc: the ra server or servers to try to send the command to
ServerId: the ra server id of the new server.

Add a ra server id to a ra cluster's membership configuration. This commits a join command to the leader log. After this has been replicated the leader will start replicating entries to the new server. This function returns after appending the command to the log. New node does not have to be running at the time of addition but it is expected to come online in a reasonable amount of time. A new member that's been announced to its new cluster but taking a long time to start will affect said cluster's availability characteristics (by increasing quorum node count).

add_member/3

add_member(ServerLoc::ra_server_id() | [ra_server_id()], ServerId::ra_server_id(), Timeout::timeout()) -> ra_cmd_ret() | {error, already_member} | {error, cluster_change_not_permitted}

Same as add_member/2 but also accepts a timeout.

See also: add_member/2.

aux_command/2

aux_command(ServerRef::ra_server_id(), Cmd::term()) -> term()

Executes (using a call) an auxiliary command that the state machine can handle.

cast_aux_command/2

cast_aux_command(ServerRef::ra_server_id(), Cmd::term()) -> ok

Executes (using a cast) an auxiliary command that the state machine can handle.

consistent_query/2

consistent_query(ServerId::ra_server_id() | [ra_server_id()], QueryFun::query_fun()) -> ra_server_proc:ra_leader_call_ret(Reply::term())

ServerId: the ra server id(s) to send the query to
QueryFun: the query function to run

Query the state machine with a consistency guarantee. This allows the caller to query the state machine on the leader node with an additional heartbeat to check that the node is still the leader. Consistency guarantee is that the query will return result containing at least all changes, committed before this query is issued. This may include changes which were committed while the query is running.

consistent_query/3

consistent_query(ServerId::ra_server_id() | [ra_server_id()], QueryFun::query_fun(), Timeout::timeout()) -> ra_server_proc:ra_leader_call_ret(Reply::term())

ServerId: the ra server id(s) to send the query to
QueryFun: the query function to run
Timeout: the timeout to use

Same as consistent_query/2 but accepts a custom timeout.

See also: consistent_query/2.

delete_cluster/1

delete_cluster(ServerIds::[ra_server_id()]) -> {ok, ra_server_id()} | {error, term()}

ServerIds: the ra_server_ids of the cluster

returns: {{ok, Leader} | error, nodedown}

Deletes a ra cluster in an orderly fashion. This function commits an end of life command which after each server applies it will cause that server to shut down and delete all its data. The leader will stay up until it has successfully replicated the end of life command to all servers after which it too will shut down and delete all of its data.

delete_cluster/2

delete_cluster(ServerIds::[ra_server_id()], Timeout::timeout()) -> {ok, Leader::ra_server_id()} | {error, term()}

Same as delete_cluster/1 but also accepts a timeout.

See also: delete_cluster/1.

force_delete_server/2

force_delete_server(System::atom(), ServerId::ra_server_id()) -> ok | {error, term()} | {badrpc, term()}

ServerId: the ra_server_id() of the server

returns: ok | {error, nodedown} | {badrpc, Reason}

Deletes a ra server The server is forcefully deleted.

initial_members/1

initial_members(ServerId::ra_server_id() | [ra_server_id()]) -> ra_server_proc:ra_leader_call_ret([ra_server_id()] | error)

ServerId: the Ra server(s) to send the query to

Returns a list of initial (seed) cluster members.

This allows Ra-based systems with dynamic cluster membership discover the original set of members and use them to seed newly joining ones.

initial_members/2

initial_members(ServerId::ra_server_id() | [ra_server_id()], Timeout::timeout()) -> ra_server_proc:ra_leader_call_ret([ra_server_id()] | error)

leader_query/2

leader_query(ServerId::ra_server_id() | [ra_server_id()], QueryFun::query_fun()) -> ra_server_proc:ra_leader_call_ret({ra_idxterm(), Reply::term()}) | {ok, {ra_idxterm(), Reply::term()}, not_known}

ServerId: the ra server id(s) to send the query to
QueryFun: the query function to run

Query the machine state on the current leader node. This function works like local_query, but redirects to the current leader node. The leader state may be more up-to-date compared to local state of some followers. This function may still return stale results as it reads the current state and does not wait for commands to be applied.

leader_query/3

leader_query(ServerId::ra_server_id() | [ra_server_id()], QueryFun::query_fun(), Timeout::timeout()) -> ra_server_proc:ra_leader_call_ret({ra_idxterm(), Reply::term()}) | {ok, {ra_idxterm(), Reply::term()}, not_known}

ServerId: the ra server id(s) to send the query to
QueryFun: the query function to run
Timeout: the timeout to use

Same as leader_query/2 but accepts a custom timeout.

See also: leader_query/2.

leave_and_delete_server/3

leave_and_delete_server(System::atom(), ServerRef::ra_server_id() | [ra_server_id()], ServerId::ra_server_id()) -> ok | timeout | {error, noproc}

System: the system identifier
ServerRef: the ra server to send the command to and to remove
ServerId: the ra server to force remove

A safe way to remove an active server from its cluster. The server will be force removed after a membership transition command was added to the log. The command is added to the log by the ServerRef node. Use this to decommission a node that's unable to start or is permanently lost.

See also: leave_and_delete_server/3.

leave_and_delete_server/4

leave_and_delete_server(System::atom(), ServerRef::ra_server_id() | [ra_server_id()], ServerId::ra_server_id(), Timeout::timeout()) -> ok | timeout | {error, noproc}

ServerRef: the ra server to send the command to and to remove
ServerId: the ra server to force remove
Timeout: timeout to use

Same as leave_and_delete_server/2 but also accepts a timeout.

See also: leave_and_delete_server/2.

leave_and_terminate/3

leave_and_terminate(System::atom(), ServerRef::ra_server_id() | [ra_server_id()], ServerId::ra_server_id()) -> ok | timeout | {error, noproc | system_not_started}

ServerRef: the ra server to send the command to and to remove
ServerId: the ra server to remove

A safe way to remove an active server from its cluster. The command is added to the log by the ServerRef node. Use this to decommission a node that's unable to start or is permanently lost.

See also: leave_and_terminate/3.

leave_and_terminate/4

leave_and_terminate(System::atom(), ServerRef::ra_server_id() | [ra_server_id()], ServerId::ra_server_id(), Timeout::timeout()) -> ok | timeout | {error, noproc | system_not_started}

ServerRef: the ra server to send the command to and to remove
ServerId: the ra server to remove
Timeout: timeout to use

Same as leave_and_terminate/2 but also accepts a timeout.

See also: leave_and_terminate/2.

local_query/2

local_query(ServerId::ra_server_id(), QueryFun::query_fun()) -> ra_server_proc:ra_leader_call_ret({ra_idxterm(), Reply::term()})

ServerId: the ra server id to send the query to
QueryFun: the query function to run

Query the machine state on any available server. This allows you to run the QueryFun over the server machine state and return the result. Any ra server can be addressed and will returns its local state at the time of querying. This can return stale results, including infinitely stale ones.

local_query/3

local_query(ServerId::ra_server_id(), QueryFun::query_fun(), Timeout::timeout()) -> ra_server_proc:ra_leader_call_ret({ra_idxterm(), Reply::term()}) | {ok, {ra_idxterm(), Reply::term()}, not_known}

ServerId: the ra server id to send the query to
QueryFun: the query function to run
Timeout: the timeout to use

Same as local_query/2 but accepts a custom timeout.

See also: local_query/2.

members/1

members(ServerId::ra_server_id() | [ra_server_id()] | {local, ra_server_id()}) -> ra_server_proc:ra_leader_call_ret([ra_server_id()])

ServerId: the Ra server(s) to send the query to

Returns a list of cluster members

Except if {local, ServerId} is passed, the query is sent to the specified server which may redirect it to the leader if it is a follower. It may timeout if there is currently no leader (i.e. an election is in progress).

With {local, ServerId}, the query is always handled by the specified server. It means the returned list might be out-of-date compared to what the leader would have returned.

members/2

members(ServerId::ra_server_id() | [ra_server_id()] | {local, ra_server_id()}, Timeout::timeout()) -> ra_server_proc:ra_leader_call_ret([ra_server_id()])

ServerId: the Ra server(s) to send the query to
Timeout: the timeout to use

Returns a list of cluster members

Except if {local, ServerId} is passed, the query is sent to the specified server which may redirect it to the leader if it is a follower. It may timeout if there is currently no leader (i.e. an election is in progress).

With {local, ServerId}, the query is always handled by the specified server. It means the returned list might be out-of-date compared to what the leader would have returned.

new_uid/1

new_uid(Source) -> any()

generates a random uid using the provided source material for the first 6 characters.

overview/0

overview() -> map() | system_not_started

Returns a map of overview data of the default Ra system on the current Erlang node. DEPRECATED: user overview/1

overview/1

overview(System::atom()) -> map() | system_not_started

Returns a map of overview data of the Ra system on the current Erlang node.

ping/2

ping(ServerId::ra_server_id(), Timeout::timeout()) -> safe_call_ret({pong, states()})

pipeline_command/2

pipeline_command(ServerId::ra_server_id(), Command::term()) -> ok

ServerId: the ra server id to send the command to
Command: an arbitrary term that the state machine can handle

Sends a command to the ra server using a gen_statem:cast without any correlation identifier. Effectively the same as ra:pipeline_command(ServerId, Command, no_correlation, low) This is the least reliable way to interact with a ra system ("fire and forget") and should only be used for commands that are of little importance and/or where waiting for a response is prohibitively slow.

See also: pipeline_command/4.

pipeline_command/3

pipeline_command(ServerId::ra_server_id(), Command::term(), Correlation::ra_server:command_correlation() | no_correlation) -> ok

ServerId: the ra server id to send the command to
Command: an arbitrary term that the state machine can handle
Correlation: a correlation identifier to be included to receive an async notification after the command is applied to the state machine.

Same as pipeline_command/4 but uses a hardcoded priority of low.

See also: pipeline_command/4.

pipeline_command/4

pipeline_command(ServerId::ra_server_id(), Command::term(), Correlation::ra_server:command_correlation() | no_correlation, Priority::ra_server:command_priority()) -> ok

ServerId: the ra server id to send the command to
Command: an arbitrary term that the state machine can handle
Correlation: a correlation identifier to be included to receive an async notification after the command is applied to the state machine. If the Correlation is set to no_correlation then no notifications will be sent.
Priority: command priority. low priority commands will be held back and appended to the Raft log in batches. NB: A normal priority command sent from the same process can overtake a low priority command that was sent before. There is no high priority. Only use priority level of low with commands that do not rely on total execution ordering.

Submits a command to the ra server using a gen_statem:cast, passing an optional process-scoped term as correlation identifier. A correlation id can be included to implement reliable async interactions with the ra system. The calling process can retain a map of commands that have not yet been applied to the state machine successfully and resend them if a notification is not received within some time window. When the submitted command(s) is applied to the state machine, the ra server will send the calling process a ra_event of the following structure:

{ra_event, CurrentLeader, {applied, [{Correlation, Reply}]}}

Ra will batch notification and thus return a list of correlation and result tuples.

If the receiving ra server is not the cluster leader, a ra event of the following structure will be returned informing the caller that it cannot process the message. The message will include the current cluster leader, if one is known:

{ra_event, FromId, {rejected, {not_leader, Leader | undefined, Correlation}}}

The caller must then redirect the command for the correlation identifier to the correct ra server: the leader.

If instead the atom no_correlation is passed for the correlation argument, the calling process will not receive any notification of command processing success or otherwise.

This is the least reliable way to interact with a ra system ("fire and forget") and should only be used if the command is of little importance to the application.

process_command/2

process_command(ServerId::ra_server_id() | [ra_server_id()], Command::term()) -> {ok, Reply::term(), Leader::ra_server_id()} | {error, term()} | {timeout, ra_server_id()}

ServerId: the server id to send the command to
Command: an arbitrary term that the state machine can handle

Same as process_command/3 with the default timeout of 5000 ms.

process_command/3

process_command(ServerId::ra_server_id() | [ra_server_id()], Command::term(), Timeout::timeout()) -> {ok, Reply::term(), Leader::ra_server_id()} | {error, term()} | {timeout, ra_server_id()}

ServerId: the server id to send the command to
Command: an arbitrary term that the state machine can handle
Timeout: the time to wait before returning {timeout, ServerId}

Submits a command to a ra server. Returns after the command has been applied to the Raft state machine. If the state machine returned a response it is included in the second element of the response tuple. If no response was returned the second element is the atom noreply. If the server receiving the command isn't the current leader it will redirect the call to the leader (if known) or hold on to the command until a leader is known. The leader's server id is returned as the 3rd element of the success reply tuple.

If there is no majority of Ra servers online, this function will return a timeout.

register_external_log_reader/1

register_external_log_reader(ServerId::ra_server_id()) -> ra_log_reader:state()

Registers an external log reader. ServerId needs to be local to the node. Returns an initiated ra_log_reader:state() state.

remove_member/2

remove_member(ServerRef::ra_server_id() | [ra_server_id()], ServerId::ra_server_id()) -> ra_cmd_ret() | {error, not_member} | {error, cluster_change_not_permitted}

ServerRef: the ra server to send the command to
ServerId: the ra server id of the server to remove

Removes a server from the cluster's membership configuration. This function returns after appending a cluster membership change command to the log.

After a server is removed from its cluster and the membership change is replicated, it would reject any commands it's asked to process.

See also: add_member/2, leave_and_delete_server/2, leave_and_terminate/2, remove_member/3.

remove_member/3

remove_member(ServerRef::ra_server_id() | [ra_server_id()], ServerId::ra_server_id(), Timeout::timeout()) -> ra_cmd_ret() | {error, not_member} | {error, cluster_change_not_permitted}

Same as remove_member/2 but also accepts a timeout.

See also: remove_member/2.

restart_server/1

restart_server(ServerId::ra_server_id()) -> ok | {error, term()}

ServerId: the ra_server_id() of the server

returns: {ok | error, Error} where error can be not_found, system_not_started or name_not_registered when the ra server has never before been started on the Erlang node. DEPRECATED: use restart_server/2

Restarts a previously successfully started ra server in the default system

restart_server/2

restart_server(System::atom(), ServerId::ra_server_id()) -> ok | {error, term()}

System: the system identifier
ServerId: the ra_server_id() of the server

returns: {ok | error, Error} where error can be not_found or name_not_registered when the ra server has never before been started on the Erlang node.

Restarts a previously successfully started ra server

restart_server/3

restart_server(System::atom(), ServerId::ra_server_id(), AddConfig::ra_server:mutable_config()) -> ok | {error, term()}

System: the system identifier
ServerId: the ra_server_id() of the server
AddConfig: additional config parameters to be merged into the original config.

returns: {ok | error, Error} where error can be not_found or name_not_registered when the ra server has never before been started on the Erlang node.

Restarts a previously successfully started ra server

start/0

start() -> ok

Starts the ra application.

start/1

start(Params::[environment_param()]) -> {ok, [Started]} | {error, term()}

Starts the ra application. If the application is running it will be stopped and restarted.

start_cluster/1

start_cluster(ServerConfigs::[ra_server:ra_server_config()]) -> {ok, [ra_server_id()], [ra_server_id()]} | {error, cluster_not_formed}

ServerConfigs: a list of initial server configurations DEPRECATED: use start_cluster/2

Same as start_cluster/2 but uses the default Ra system.

start_cluster/2

start_cluster(System::atom(), ServerConfigs::[ra_server:ra_server_config()]) -> {ok, [ra_server_id()], [ra_server_id()]} | {error, cluster_not_formed}

System: the system name
ServerConfigs: a list of initial server configurations

returns:

{ok, Started, NotStarted} if a cluster could be successfully started. A cluster can be successfully started if more than half of the servers provided could be started. Servers that could not be started need to be retried periodically using start_server/1

{error, cluster_not_formed} if a cluster could not be started.

If a cluster could not be formed any servers that did manage to start are forcefully deleted.

Starts a new distributed ra cluster.

start_cluster/3

start_cluster(System::atom(), ServerConfigs::[ra_server:ra_server_config()], Timeout::non_neg_integer()) -> {ok, [ra_server_id()], [ra_server_id()]} | {error, cluster_not_formed}

System: the system name
ServerConfigs: a list of initial server configurations
Timeout: the timeout to use

Same as start_cluster/2 but accepts a custom timeout.

start_cluster/4

start_cluster(System::atom(), ClusterName::ra_cluster_name(), Machine::ra_server:machine_conf(), ServerIds::[ra_server_id()]) -> {ok, [ra_server_id()], [ra_server_id()]} | {error, cluster_not_formed}

ClusterName: the name of the cluster.
Machine: The ra_machine:machine/0 configuration.
ServerIds: The list of ra server ids.

returns:

{ok, Started, NotStarted} if a cluster could be successfully started. A cluster can be successfully started if more than half of the servers provided could be started. Servers that could not be started need to be retried periodically using start_server/1

{error, cluster_not_formed} if a cluster could not be started.

If a cluster could not be formed any servers that did manage to start are forcefully deleted.

Starts a new distributed ra cluster.

start_in/1

start_in(DataDir::file:filename()) -> {ok, [Started]} | {error, term()}

Starts the ra application with a provided data directory. The same as ra:start([{data_dir, dir}]) If the application is running it will be stopped and restarted.

start_or_restart_cluster/4

start_or_restart_cluster(System::atom(), ClusterName::ra_cluster_name(), Machine::ra_server:machine_conf(), ServerIds::[ra_server_id()]) -> {ok, [ra_server_id()], [ra_server_id()]} | {error, cluster_not_formed}

ClusterName: the name of the cluster.
Machine: The ra_machine:machine/0 configuration.
ServerIds: The list of ra server ids.

returns:

{ok, Started, NotStarted} if a cluster could be successfully started. A cluster can be successfully started if more than half of the servers provided could be started. Servers that could not be started need to be retried periodically using start_server/1

{error, cluster_not_formed} if a cluster could not be started.

If there was no existing cluster and a new cluster could not be formed any servers that did manage to start are forcefully deleted.

Starts or restarts a ra cluster.

start_or_restart_cluster/5

start_or_restart_cluster(System::atom(), ClusterName::ra_cluster_name(), Machine::ra_server:machine_conf(), RemServers::[ra_server_id()], Timeout::non_neg_integer()) -> {ok, [ra_server_id()], [ra_server_id()]} | {error, cluster_not_formed}

ClusterName: the name of the cluster.
Machine: The ra_machine:machine/0 configuration.
Timeout: The time to wait for any server to restart or start

returns:

{ok, Started, NotStarted} if a cluster could be successfully started. A cluster can be successfully started if more than half of the servers provided could be started. Servers that could not be started need to be retried periodically using start_server/1

{error, cluster_not_formed} if a cluster could not be started.

If there was no existing cluster and a new cluster could not be formed any servers that did manage to start are forcefully deleted.

Same as start_or_restart_cluster/4 but accepts a custom timeout.

See also: start_or_restart_cluster/3.

start_server/1

start_server(Conf::ra_server:ra_server_config()) -> ok | {error, term()}

Conf: a ra_server_config() configuration map.

returns: {ok | error, Error} DEPRECATED: use start_server/2

Starts a ra server in the default system

start_server/2

start_server(System::atom(), Conf::ra_server:ra_server_config()) -> ok | {error, term()}

System: the system name
Conf: a ra_server_config() configuration map.

returns: {ok | error, Error}

Starts a ra server

start_server/5

start_server(System::atom(), ClusterName::ra_cluster_name(), ServerId::ra_server_id(), Machine::ra_server:machine_conf(), ServerIds::[ra_server_id()]) -> ok | {error, term()}

ClusterName: the name of the cluster.
ServerId: the ra_server_id() of the server
Machine: The ra_machine:machine/0 configuration.
ServerIds: a list of initial (seed) server configurations

returns:

{ok, Started, NotStarted} if a cluster could be successfully started. A cluster can be successfully started if more than half of the servers provided could be started. Servers that could not be started need to be retried periodically using start_server/1

{error, cluster_not_formed} if a cluster could not be started.

If a cluster could not be formed any servers that did manage to start are forcefully deleted.

Starts a new distributed ra cluster.

See also: start_server/1.

stop_server/1

stop_server(ServerId::ra_server_id()) -> ok | {error, nodedown | system_not_started}

ServerId: the ra_server_id() of the server

returns: {ok | error, nodedown} DEPRECATED: use stop_server/2

Stops a ra server in the default system

stop_server/2

stop_server(System::atom(), ServerId::ra_server_id()) -> ok | {error, nodedown | system_not_started}

System: the system name
ServerId: the ra_server_id() of the server

returns: {ok | error, nodedown}

Stops a ra server

transfer_leadership/2

transfer_leadership(ServerId::ra_server_id(), TargetServerId::ra_server_id()) -> ok | already_leader | {error, term()} | {timeout, ra_server_id()}

Transfers leadership from the leader to a follower. Returns already_leader if the transfer target is already the leader.

trigger_election/1

trigger_election(ServerId::ra_server_id()) -> ok

ServerId: the ra server id of the server to trigger the election on.

Makes the server enter a pre-vote state and attempt to become the leader. It is necessary to call this function when starting a new cluster as a brand new Ra server (node) will not automatically enter the pre-vote state. This does not apply to recovering (previously started) servers: they will enter the pre-vote state and proceed to participate in an election on boot.

trigger_election/2

trigger_election(ServerId::ra_server_id(), Timeout::timeout()) -> ok

Same as trigger_election/2 but also accepts a timeout.


Generated by EDoc