convergent 0.1.0

Lightweight, composable CRDTs for decentralized systems
Documentation
  • Coverage
  • 62.5%
    5 out of 8 items documented4 out of 4 items with examples
  • Size
  • Source code size: 33.1 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 3.35 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 50s Average build duration of successful builds.
  • all releases: 50s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • MaloWinrhy/convergent
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • MaloWinrhy

convergent

CI License: MIT

Lightweight, composable CRDTs (Conflict-Free Replicated Data Types) for decentralized systems.

CRDTs are data structures that can be replicated across nodes, modified independently, and merged with a mathematically guaranteed consistent result — no central coordination required.

Types

Type Description Use case
GCounter Grow-only counter View counts, event tracking
PNCounter Positive-Negative counter Likes/dislikes, stock levels
LWWRegister Last-Writer-Wins register User profile fields, settings
ORSet Observed-Remove set Shopping carts, tag lists

Usage

[dependencies]
convergent = "0.1"
use convergent::{GCounter, Merge};

let mut node_a = GCounter::new("a");
let mut node_b = GCounter::new("b");

node_a.increment(3);
node_b.increment(5);

node_a.merge(&node_b);
assert_eq!(node_a.value(), 8);

Design

Every type implements the Merge trait, which guarantees:

  • Commutativea.merge(b) == b.merge(a)
  • Associativea.merge(b).merge(c) == a.merge(b.merge(c))
  • Idempotenta.merge(a) == a

The LWWRegister uses hlc_id for causally-ordered timestamps, connecting this crate to the broader problem of time in distributed systems.

Related

License

MIT