Packages

A distributed, cluster-wide key-value store implemented on the BEAM.

Current section

Files

Jump to
paxos_kv lib paxos_kv bucket.ex
Raw

lib/paxos_kv/bucket.ex

defmodule PaxosKV.Bucket do
use Supervisor
def start_link(opts) do
bucket = Keyword.get(opts, :bucket, PaxosKV)
name = Keyword.get(opts, :name, bucket)
Supervisor.start_link(__MODULE__, bucket, name: name)
end
def child_spec(opts) do
bucket = Keyword.get(opts, :bucket, PaxosKV)
%{
id: bucket,
start: {__MODULE__, :start_link, [opts]},
type: :supervisor
}
end
@impl true
def init(bucket) do
children = [
{PaxosKV.Learner, bucket: bucket},
{PaxosKV.Acceptor, bucket: bucket},
{PaxosKV.Proposer, bucket: bucket}
]
Supervisor.init(children, strategy: :one_for_one)
end
end