raft_kv v0.1.0 RaftKV.LeaderHook behaviour View Source

Behaviour module for hooks that are invoked in leader of a consensus group.

Note that there are cases where hooks are invoked multiple times for a single event due to leader change.

Link to this section Summary

Link to this section Callbacks

Link to this callback on_command_committed(value_before, size_before, key, arg, ret, value_after, size_after) View Source
on_command_committed(
  value_before :: nil | RaftKV.ValuePerKey.value(),
  size_before :: RaftKV.ValuePerKey.size(),
  key :: RaftKV.ValuePerKey.key(),
  arg :: RaftKV.ValuePerKey.command_arg(),
  ret :: RaftKV.ValuePerKey.command_ret(),
  value_after :: nil | RaftKV.ValuePerKey.value(),
  size_after :: RaftKV.ValuePerKey.size()
) :: any()

Hook to be called when a command given by RaftKV.command/4 or RaftKV.command_on_all_keys_in_shard/3 is executed.

Link to this callback on_query_answered(value, size, key, arg, ret) View Source

Hook to be called when a query given by RaftKV.query/4 is executed.