Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ergl/crdt-ml
CRDTs - Conflict-Free Replicated Data Types for OCaml
https://github.com/ergl/crdt-ml
Last synced: 9 days ago
JSON representation
CRDTs - Conflict-Free Replicated Data Types for OCaml
- Host: GitHub
- URL: https://github.com/ergl/crdt-ml
- Owner: ergl
- License: gpl-3.0
- Created: 2016-03-19T02:05:19.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-09-15T18:52:48.000Z (about 8 years ago)
- Last Synced: 2024-10-31T14:35:49.276Z (16 days ago)
- Language: OCaml
- Homepage:
- Size: 135 KB
- Stars: 48
- Watchers: 6
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CRDTs - Conflict-Free Replicated Data Types for OCaml
A CRDT (or Conflict-Free Replicated Data Type) is a data type designed to
satisfy the Strong Eventual Consistency model.In other words, given a set of replicas of the same data type, and a number of
operations independently applied to any replica, all replicas will eventually
reach the same state, no matter the order of the operations.These properties make CRDTs extremely useful for distributed KV stores and
collaborative applications, among others.Further Reading:
- [Conflict-free replicated data types](http://dl.acm.org/citation.cfm?id=2050642)
- [A comprehensive study of Convergent and Commutative Replicated Data Types](https://hal.inria.fr/inria-00555588)## Datatypes
Included data types are:
- _IntVector_ : An Integer Vector.
- _GCounter_ : A grow-only counter.
- _PNCounter_ : A counter implementing both increment and decrement operations.
- _GSet_ : A grow-only set.
- _USet_ : A set supporting both add and remove operations. [1](#usetnote)
- _ORSet_ : A set supporting both add and remove operations.
Unless stated otherwise, all implementations come in mutable (`Crdt.Mutable`)
and immutable (`Crdt.Immutable`) flavours.Please note that the current implementations are designed only for educational
purposes. Don't use them for any serious work.1: Removed elements can never be added again.
Use an `ORSet` if you want to be able to add removed elements again. Read the
reasoning in the [documentation](http://ergl.github.io/crdt-ml/M_USet.html).## Installing
Using [`opam`](https://opam.ocaml.org):
```
opam install crdt-ml
```Or you can install from source:
```
make && make install
```To try the library in a repl, open an ocaml toplevel and `require` it:
```
# #use "topfind";;
# #require "crdt";;
```To link it, compile your files using `ocamlbuild`:
```
ocamlbuild -use-ocamlfind -pkgs crdt
```Run the tests:
```
make test
```The tests depend on [iTeML](https://github.com/vincent-hugot/iTeML). You can install it with `opam install qtest`.
You can also choose to use just a certain part of the library. To do so, link or load the
submodule you want:- `crdt_mutable` - Mutable implementations.
- `crdt_immutable` - Immutable implementations.## Usage
For a simple increment / decrement counter:
```ocaml
open Crdt.Mutable.PNCounterlet a = make () and
b = make ()incr a
incr aquery a
- : int = 2decr b
merge a bquery a
- : int = 1
```Using an `USet`:
```ocaml
module StrSet = Crdt.Mutable.USet.Make (String)open StrSet
let s1 = make () and
s2 = make ()add "I" s1
add "Love" s1add "Pancakes" s2
add "Yeah!" s1merge s1 s2
merge s2 s1value s1
- : bytes list = ["I"; "Love"; "Pancakes"; "Yeah!"]remove "Yeah!" s2
merge s1 s2value s1
- : bytes list = ["I"; "Love"; "Pancakes"]value s2
- : bytes list = ["I"; "Love"; "Pancakes"]
```### Documentation
Check out the online [documentation](http://ergl.github.io/crdt-ml) for more.
The documentation and the API reference are automatically generated by `ocamldoc`
from the interfaces.You can generate your own local documentation running `make doc`.
## License
GPLv3. Check the [License](./LICENSE).