
Polarity:Mixed/Knife-edge
CRDTs for Distributed Collaboration
May 8, 2025Emma Wilson1 min read
Visual Variations
fast sdxl
stable cascade
CRDTs enable distributed collaboration without central coordination. Used in collaborative docs, distributed databases.
Implementation
class GCounter:
"""Grow-only counter CRDT"""
def __init__(self, node_id):
self.counts = {} # {node_id: count}
self.node_id = node_id
def increment(self):
self.counts[self.node_id] = self.counts.get(self.node_id, 0) + 1
def merge(self, other):
for node, count in other.counts.items():
self.counts[node] = max(self.counts.get(node, 0), count)
def value(self):
return sum(self.counts.values())
Click to examine closelyUse cases: Google Docs, Redis, Riak