graft v0.1.0 Graft.Machine behaviour
A behaviour module for implementing a replicated machine for the raft consensus
algorithm. Look at the Graft
module docs for examples on how to create such
machines.
Link to this section Summary
Types
The entry request sent by the client.
The reply to be sent back to the client.
The state/data of the replicated machine (similar to the 'state' of GenServer).
Functions
Returns a specification to start this module under a supervisor.
Callbacks
Invoked when a server in the raft cluster is commiting an entry to its log. Should apply the entry to the replicated machine.
Invoked when the server starts and links to the machine.
Link to this section Types
The entry request sent by the client.
The reply to be sent back to the client.
The state/data of the replicated machine (similar to the 'state' of GenServer).
Link to this section Functions
child_spec(init_arg)
Returns a specification to start this module under a supervisor.
See Supervisor
.
Link to this section Callbacks
handle_entry(entry, state)
Invoked when a server in the raft cluster is commiting an entry to its log. Should apply the entry to the replicated machine.
Should return a tuple of the response for the server along with the new state of the replicated machine.
Invoked when the server starts and links to the machine.
args
is a list accepted arguments. Look at Graft.start
to see how to pass
in these optional arguments.
Returning {:ok, state}
, will initialise the state of the machine to state
.