PaxosKV.Acceptor (paxos_kv v0.6.0)

Copy Markdown

Implements the Acceptor role in the Paxos consensus algorithm.

The Acceptor responds to prepare and accept requests from Proposers. It maintains the state of accepted proposals and enforces the protocol rules that ensure safety (agreement on a single value per key).

Summary

Functions

Sends an accept request to Acceptors on the specified nodes.

Returns a specification to start this module under a supervisor.

Collects a list of accepted {id, value} pairs from the acceptors.

Returns a list of all keys stored across Acceptors on the specified nodes.

Sends a prepare request to Acceptors on the specified nodes.

Functions

accept(nodes, bucket, id, key, value)

Sends an accept request to Acceptors on the specified nodes.

This is the second phase of the Paxos protocol. The Acceptor will accept the proposed value if it hasn't promised to reject it.

Returns a list of responses from the Acceptors.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

info(key, bucket)

Collects a list of accepted {id, value} pairs from the acceptors.

keys(nodes, bucket)

Returns a list of all keys stored across Acceptors on the specified nodes.

The results are flattened and deduplicated.

Examples

iex> PaxosKV.Acceptor.keys([:node1@localhost, :node2@localhost], PaxosKV)
[:key1, :key2, :key3]

prepare(nodes, bucket, id, key)

Sends a prepare request to Acceptors on the specified nodes.

This is the first phase of the Paxos protocol. The Acceptor will promise not to accept proposals with IDs lower than the given id.

Returns a list of responses from the Acceptors.

start_link(opts)