Skip to content

CRDT primitives to enable remote data synchronization with Isar DB

Notifications You must be signed in to change notification settings

kerero/isar-crdt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Isar CRDT

ci

⚠️ WIP ⚠️

This project aims to extend the functionality of the Isar database to allow remote synchronization (isar/isar#2).

The remote synchronization is achieved by generating HLC (Hybrid Logical Clock) per field that act as a version number for the current value. This allows two versions of an object to be merged consistently while also retaining the newer version of each field.

Synchronization types support

  • collection classes
  • embedded classes
  • primitive types
  • Lists

Usage

import 'package:isar_crdt/isar_crdt.dart'; //  <-- 
import 'package:isar/isar.dart';

part 'test_class.isar_crdt.g.dart'; //  <-- 
part 'test_class.isar.g.dart'; // <-- instead of test_class.g.dart

@crdtCollection //  <-- 
@collection
class TestClass extends _TestClassCrdt {
    ...
}

...

// Create/update object
await isar.writeTxn(() {
    return isar.testClass.put(obj);
});

// Merge object from a remote node
await isar.writeTxn(() {
    return isar.testClass.merge(obj);
});

isar.testClass return IsarCrdtCollection (instead of IsarCollection) that abstract all the HLC handling logic.

Limitations

to generate globally unique IDs for isar objects the following limitations are recommended to avoid ID collisions.

  1. 4,294,967,295 objects per Isar collection.
  2. 4,294,967,295 nodes or users.

About

CRDT primitives to enable remote data synchronization with Isar DB

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages