rafted_value v0.1.10 RaftedValue.Data behaviour

A behaviour that defines data to be replicated by RaftedValue servers.

It is required to implement a callback module of this behaviour to run a consensus group. Concrete implementations of all callback functions of this behaviour must be pure.

Summary

Callbacks

Generic read/write operation on the stored value

Creates an initial value to be stored

Read-only operation on the stored value

Types

command_arg()
command_arg() :: any
command_ret()
command_ret() :: any
data()
data() :: any
query_arg()
query_arg() :: any
query_ret()
query_ret() :: any

Callbacks

command(data, command_arg)
command(data, command_arg) :: {command_ret, data}

Generic read/write operation on the stored value.

This callback function is invoked by RaftedValue.command/4. Commands are replicated across members of the consensus group and executed in all members in order to reproduce the same history of stored value. This function should return a pair of “return value to client” and “next version of stored data”.

new()
new() :: data

Creates an initial value to be stored.

Whenever a new consensus group is started by RaftedValue.start_link/2 (called with :create_new_consensus_group), this function is called to initialize the stored value.

query(data, query_arg)
query(data, query_arg) :: query_ret

Read-only operation on the stored value.

This callback function is invoked by RaftedValue.query/3. This function should return “return value to client”.