Swift implementation of state based CRDT (CvRDT)
Conflict-free Replicated Data types or CRDT for short are data types which support semilattice properties and able to resolve conflicts connected with concurrent changes automatically. They were designed as a solution for data synchonization problem in distibuted systems, that's why they are highly connected with version vector.
More info in CRDT whitepaper (or in medium article if you don't want to read a lot) and Version vector (wiki)
Current implementation contains next data structures:
- counters:
GCounter
,PNCounter
- registers:
LWWRegister
,MVRegister
- sets:
GSet
,2PSet
(called asTPSet
),ORSet
(same asAWSet
) - maps:
ORMap
(same asAWMap
) - flags:
EWFlag
Also it contains next logical timestamps which are used by GCounter
and MVRegister
:
VersionVector
(it is highly possible that it will be deprecated in future, because it is not match dynamic distibuted systems which we have in iOS development)VectorStamp
Only SPM is supported:
dependencies: [
.package(url: "https://github.com/specialfor/CRDT", .branch("develop"))
]
Feel free to look into tests folder. You can also find an example of usage based on client-server app here
- Improve existed implementation:
- Start using
VectorStamp
instead ofVersionVector
insideGCounter
- Rethink timestamp usage in
LWWRegister
- Start using
- Add more CvRDTs:
- POCounter
- PNSet
- LWWSet
- RWSet
- Log
- RWMap
- DWFlag
- DAG
- RGA
- WOOT
- Treedoc
- Lagoot
- Implement gargbage collector
- Introduce delta CRDT
- Create CmRDT analogues