lattice_core

Core causal infrastructure for Lattice CRDT packages: replica IDs, version vectors, and dot contexts.

Use this package when you are building CRDTs directly or need to track causality for a custom replicated data type. Most application code can install higher-level packages such as lattice_counters, lattice_sets, or the umbrella lattice_crdt package instead.

Installation

gleam add lattice_core

Quick example

import lattice_core/replica_id
import lattice_core/version_vector

pub fn main() {
  let node_a = replica_id.new("node-a")
  let node_b = replica_id.new("node-b")

  let local =
    version_vector.new()
    |> version_vector.increment(node_a)

  let remote =
    version_vector.new()
    |> version_vector.increment(node_b)

  version_vector.compare(local, remote)
  // -> version_vector.Concurrent
}

Modules

ModulePurpose
lattice_core/replica_idOpaque replica identifiers with ordering and JSON helpers.
lattice_core/version_vectorLogical clocks for comparing, merging, and serializing causal state.
lattice_core/dot_contextDot sets for observed-remove data structures.

Notes

Links

License

MIT

Search Document