• Stars
    star
    137
  • Rank 266,121 (Top 6 %)
  • Language
    Dart
  • License
    Apache License 2.0
  • Created almost 5 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Dart implementation of Conflict-free Replicated Data Types (CRDTs)

Dart implementation of Conflict-free Replicated Data Types (CRDTs).

This project is heavily influenced by James Long's talk CRTDs for Mortals and includes a Dart-native implementation of Hybrid Local Clocks (HLC) based on the paper Logical Physical Clocks and Consistent Snapshots in Globally Distributed Databases.

It has zero external dependencies, so it should run everywhere where Dart runs.

See sql_crdt for an implementation of CRDTs backed by an SQL database.

Usage

The Crdt class works as a layer on top of a map. The simplest way to experiment is to initialise it with an empty map:

import 'package:crdt/crdt.dart';

void main() {
  var crdt = MapCrdt('node_id');

  // Insert a record
  crdt.put('a', 1);
  // Read the record
  print('Record: ${crdt.get('a')}');

  // Export the CRDT as Json
  final json = crdt.toJson();
  // Send to remote node
  final remoteJson = sendToRemote(json);
  // Merge remote CRDT with local
  crdt.mergeJson(remoteJson);
  // Verify updated record
  print('Record after merging: ${crdt.get('a')}');
}

// Mock sending the CRDT to a remote node and getting an updated one back
String sendToRemote(String json) {
  final hlc = Hlc.now('another_nodeId');
  return '{"a":{"hlc":"$hlc","value":2}}';
}

You'll probably want to implement some sort of persistent storage by subclassing the Crdt class. An example using Hive is provided in hive_crdt.

Example

A simple example is provided with this project.

Features and bugs

Please file feature requests and bugs at the issue tracker.

More Repositories

1

ExpandableLayout

An expandable layout container for Android
Java
2,305
star
2

firedart

A dart-native implementation of the Firebase Auth and Firestore SDKs
Dart
174
star
3

AerialDream

A screensaver for Android inspired on the one from the Apple TV
Java
112
star
4

tudo

A simple to-do app
JavaScript
66
star
5

sql_crdt

Dart implementation of Conflict-free Replicated Data Types (CRDTs) using SQL databases
Dart
48
star
6

sqlite_crdt

Dart implementation of Conflict-free Replicated Data Types (CRDTs) using Sqlite
Dart
26
star
7

RemoteGallery

Access your SSH-hosted pictures remotely from your Android device
Java
18
star
8

hive_crdt

A CRDT backed by a Hive store
Dart
16
star
9

BottomNavigation

An implementation of the Material Design Bottom Navigation Drawer for Android
Java
15
star
10

crdt_sync

A dart-native turnkey solution for painless network synchronization
Dart
11
star
11

tudo_server

A simple to-do app server
Dart
10
star
12

crdt_draw

A collaborative real-time local-first global canvas
Dart
10
star
13

postgres_crdt

Dart implementation of Conflict-free Replicated Data Types (CRDTs) using PostgreSQL
Dart
10
star
14

SAM-Java

An example of the SAM (State-Action-Model) pattern in Java/Android
Java
7
star
15

ottobot

A Mattermost bot
Dart
6
star
16

BusinessTime

Simple work time counter, designed for automation
Java
6
star
17

crdt_server

Generic REST server based on Conflict-free Replicated Data Types (CRDTs)
Dart
5
star
18

tonie_shuffle

A command-line utility to shuffle Creative Tonie playlists
Dart
4
star
19

mattermost_dart

A basic implementation of the Mattermost API in dart
Dart
4
star
20

fireutil

Utility to manage Firestore databases
Dart
3
star
21

Protium-Demo

A demonstration of the Protium architecture
Java
2
star