DeltaCrdt

DeltaCrdt implements some Delta CRDTs in Elixir.

CRDTs currently offered include:

Please open an issue or a pull request if you'd like to see any additional Delta CRDTs included.

The following papers have been partially implemented in this library:

Usage

Documentation can be found on hexdocs.pm.

Here's a short example to illustrate adding an entry to a map:

alias DeltaCrdt.{CausalCrdt, AWLWWMap}

# start 2 GenServers to wrap a CRDT.
{:ok, crdt} = CausalCrdt.start_link(AWLWWMap)
{:ok, crdt2} = CausalCrdt.start_link(AWLWWMap)

# make them aware of each other
send(crdt, {:add_neighbour, crdt2})
send(crdt2, {:add_neighbour, crdt})

# do an operation on the CRDT
GenServer.cast(crdt, {:operation, {:add, ["CRDT", "is magic"]}})

# force sending intervals to neighbours
send(crdt, :ship_interval_or_state_to_all)

# wait a few ms to give it time to replicate
Process.sleep(50)

# read the CRDT
CausalCrdt.read(crdt2)
#=> %{"CRDT" => "is magic"}

TODOs

Installation

The package can be installed by adding delta_crdt to your list of dependencies in mix.exs:

def deps do
  [
    {:delta_crdt, "~> 0.1.6"}
  ]
end