bluk/CRDT
Convergent and Commutative Replicated Data Types implementation in Swift
Usage
Swift Package Manager
Add this package to your Package.swift dependencies and target's dependencies:
import PackageDescription
let package = Package(
name: "Example",
dependencies: [
.package(
url: "https://github.com/bluk/CRDT",
from: "0.1.0"
),
],
targets: [
.target(
name: "YourProject",
dependencies: ["CRDT"]
)
]
)Code
import Foundation
import CRDT
// First system
let actorA = UUID()
var a = GCounter<UUID>()
a.incrementCounter(for: actorA)
// a.value == 1
// Second system
let actorB = UUID()
var b = GCounter<UUID>()
b.incrementCounter(for: actorB)
// b.value == 1
try b.merge(a)
// b.value == 2
a.incrementCounter(for: actorA)
a.incrementCounter(for: actorA)
// a.value == 3
try b.merge(a)
// b.value == 4See the tests for more examples.
License
[Apache-2.0 License][license]
[license]: LICENSE [swift]: https://swift.org [crdt]: https://hal.inria.fr/file/index/docid/555588/filename/techreport.pdf [rust_crdt]: https://github.com/rust-crdt/rust-crdt [java_crdt]: https://github.com/ajantis/java-crdt [lseq]: https://hal.archives-ouvertes.fr/hal-00921633/document
Package Metadata
Repository: bluk/CRDT
Stars: 27
Forks: 1
Open issues: 0
Default branch: master
Primary language: swift
License: Apache-2.0
Topics: crdt, crdt-implementations, crdts, lseq, swift
README: README.md