lattice_presence

Distributed presence CRDT with topic/key/pid/meta tracking, add-wins merge semantics, replica visibility, and Phoenix-style diff reporting.

Use this package to track which users, devices, or processes are online across distributed nodes without requiring a central coordinator.

Installation

gleam add lattice_presence

Quick example

import gleam/json
import lattice_presence/presence_state
pub fn main() {
let state =
presence_state.new("node-a")
|> presence_state.join(
pid: "pid-1",
topic: "room:lobby",
key: "alice",
meta: json.object([]),
)
presence_state.get_by_topic(state, "room:lobby")
// -> [#("pid-1", "alice", json.object([]))]
}

Modules

ModulePurpose
lattice_presence/presence_statePresence CRDT state, joins/leaves, merges, diffs, liveness, and queries.
lattice_presence/state_jsonJSON encoding and decoding for presence state.

Notes

License

MIT