Skip to content

DistributedData

Defined in: src/crdt/DistributedData.ts:252

Cluster-wide replicated key-value store of CRDTs. Each node hosts one local replica. update(key, ...) mutates the local replica (idempotent, conflict-free), and gossip fans the state out so every replica eventually agrees on merge(...) of all updates.

Lifecycle: call extension(DistributedDataId).start(cluster) once per process to spawn the internal gossip actor. Subsequent calls return the same handle.

const dd = system.extension(DistributedDataId).start(cluster); dd.update(‘cart-42’, () => ORSet.empty(), (cart) => cart.add(cluster.selfAddress.toString(), ‘apple’)); const cart = dd.get<ORSet>(‘cart-42’);

Limits / non-goals (v1):

  • Full-state push on every gossip tick — fine for small stores.
  • No durable persistence: the store lives in memory.
  • No tombstone delete; delete(key) is best-effort and can be undone by an in-flight gossip from a peer who still has the key. Plan a workload-specific tombstone pattern (typically embed deletion in the CRDT — e.g. ORSet.remove).

new DistributedData(system): DistributedData

Defined in: src/crdt/DistributedData.ts:256

ActorSystem

DistributedData

get(): DistributedDataHandle

Defined in: src/crdt/DistributedData.ts:303

DistributedDataHandle


isStarted(): boolean

Defined in: src/crdt/DistributedData.ts:310

boolean


start(cluster, settings?): DistributedDataHandle

Defined in: src/crdt/DistributedData.ts:258

Cluster

DistributedDataSettings = {}

DistributedDataHandle


stop(): void

Defined in: src/crdt/DistributedData.ts:297

Tear down the wire-handler subscriptions (test/shutdown only).

void