CRDT
CRDT: state-based conflict-free replicated data types.
All CRDTs share the same contract: merge(a, b) -- commutative, associative, idempotent join equal(a, b) -- structural equality on the internal state
Sub-modules: CRDT.GCounter -- grow-only counter CRDT.PNCounter -- increment/decrement counter (two GCounters) CRDT.LWWRegister -- last-write-wins register (uses VectorClock) CRDT.ORSet -- observed-remove set (add/remove with UUID tags)
Types
Functions
Add elem with a unique tag (use UUID.v4() for the tag).
Add n to actor_id's slot (n must be >= 0).
Read the vector clock of the last write.
True if elem has at least one surviving tag.
Decrement the counter for actor_id.
All elements currently in the set.
All (actor_id, count) pairs.
True when both ORSets have the same elements (ignoring tag identity).
True when both registers hold the same clock (values may still differ on concurrent writes).
True when both PNCounters have the same net increments and decrements.
True when both counters have identical internal state.
Read the current value.
Increment the counter for actor_id.
Increment actor_id's slot by 1.
Merge: union tags for each element key.
Merge: keep the value with the causally later clock. Concurrent = keep left.
Merge two PNCounters: join both P and N maps independently.
Component-wise maximum — the CRDT join.
An empty set.
Create a new register with an initial value and the clock at write time.
An empty counter with value 0.
An empty counter (all actor counts are 0).
Remove all observed tags for elem (concurrent adds in-flight survive).
Write a new value, advancing the actor's clock slot.
Number of elements with at least one tag.
Current value: sum of increments minus sum of decrements.
Sum of all actor slots.