hlc 1.0.4 copy "hlc: ^1.0.4" to clipboard
hlc: ^1.0.4 copied to clipboard

Dart port of a hybrid logical clock (HLC).

Dart Hybrid Logical Clock (HLC) #

This is a Dart port of the hybrid logical clock implementation described by Jared Forsyth in this article.

HLCs are a useful primitive for CRDT implementations.

Install #

Pub Version

In pubspec.yaml:

dependencies:
  hlc: ^1.0.0

Usage #

Import the library:

import 'package:hlc/hlc.dart';

Initialize a local HLC with the current wall clock:

var hlc = HLC.now();

Perform a local action that requires advancing the local HLC:

hlc = hlc.increment();

Receive a remote HLC, applying it to the local one:

final remoteHlc = HLC.now(); // From somewhere in the network.
hlc = hlc.receive(remoteHlc);

Serialize/deserialize an HLC while maintaining its topological ordering:

final serialized = hlc.pack();
final deserialized = HLC.unpack(serialized);
2
likes
120
points
294
downloads

Publisher

verified publishermisha.jp

Weekly Downloads

Dart port of a hybrid logical clock (HLC).

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

More

Packages that depend on hlc