CRDT module was designed to create collaborative editing applications with CRDT (conflict-free replicated data type) approach. It’s well suitable for some simple solutions (for example, a scalable eventually consistent key-value storage with CRDT conflict resolutions).
You can add the CRDT module to your project by inserting a dependency in
In this example, we have two replicas - two independent nodes that store different information.
First replica stores:
Second replica stores:
Then we merge replicas according to the CRDT approach and receive a result:
In the example
LWWSet (Last Write Wins) is utilized. It implements
Set interface and is basically a
Map<E, Timestamp>. Timestamp allows to merge
LWWSets by choosing the most relevant versions in case of conflicts.