Loom.RWORSet
A remove-wins (optimized) oberserved-remove set (without tombstones).
This CRDT breaks ties (concurrency) in favor of removing an element from a set. This CRDT isn’t as “natural” as the add-wins set, which usually matches user expectations a bit more closely.
Summary
add(set, actor, value) | Add a term to the set |
join(rworset, rworset) | Joins 2 sets together |
member?(rworset, value) | Tests if a value is an element of the set |
new() | Creates a new RWORSet |
remove(set, actor, value) | Removes a term from the set |
value(rworset) | Returns a list of set members |
Functions
Specs:
Add a term to the set.
iex> alias Loom.RWORSet, as: Set
iex> Set.new |> Set.add(:a, "test1") |> Set.add(:a, "test2") |> Set.value |> Enum.sort
["test1", "test2"]
Specs:
Joins 2 sets together.
iex> alias Loom.RWORSet, as: Set
iex> {setA, _} = Set.new |> Set.add(:a, 1)
iex> {setB, _} = Set.new |> Set.add(:b, 2)
iex> Set.join(setA, setB) |> Set.value
[1,2]
Specs:
Tests if a value is an element of the set.
iex> alias Loom.RWORSet, as: Set
iex> Set.new |> Set.add(:a, "test1") |> Set.member?("test1")
true
Specs:
- new :: t
Creates a new RWORSet.
The identity value is []
, an empty list.
iex> alias Loom.RWORSet, as: Set
iex> Set.new |> Set.value
[]
Specs:
Removes a term from the set.
iex> alias Loom.RWORSet, as: Set
iex> Set.new |> Set.add(:a, "test1") |> Set.remove(:a, "test1") |> Set.member?("test1")
false