lattice_sets

Grow-only, two-phase, and observed-remove CRDT sets for Gleam.

Use this package when replicas need set membership that can be merged without coordination. Choose the set type based on whether elements can be removed and later re-added.

Installation

gleam add lattice_sets

Quick example

import lattice_core/replica_id
import lattice_sets/or_set

pub fn main() {
  let node_a =
    or_set.new(replica_id.new("node-a"))
    |> or_set.add("alice")

  let node_b =
    or_set.new(replica_id.new("node-b"))
    |> or_set.add("bob")

  let merged = or_set.merge(node_a, node_b)

  or_set.contains(merged, "alice")
  // -> True
}

Modules

ModulePurpose
lattice_sets/g_setGrow-only set. Elements can be added but never removed.
lattice_sets/two_p_setTwo-phase set. Elements can be removed once and cannot be re-added.
lattice_sets/or_setObserved-remove set. Elements can be added, removed, and re-added.

Notes

Links

License

MIT

Search Document