Hlc<T> class

A Hybrid Logical Clock implementation. This class trades time precision for a guaranteed monotonically increasing clock in distributed systems. Inspiration: https://cse.buffalo.edu/tech-reports/2014-04.pdf

Implemented types

Constructors

Hlc(int millis, int counter, T nodeId)
Hlc.fromDate(DateTime dateTime, T nodeId)
Hlc.fromLogicalTime(dynamic logicalTime, T nodeId)
Hlc.now(T nodeId)
Hlc.parse(String timestamp, [T idDecoder(String value)?])
factory
Hlc.recv(Hlc<T> canonical, Hlc<T> remote, {int? millis})
Compares and validates a timestamp from a remote system with the local canonical timestamp to preserve monotonicity. Returns an updated canonical timestamp instance. Local wall time will be used if millis isn't supplied.
factory
Hlc.send(Hlc<T> canonical, {int? millis})
Generates a unique, monotonic timestamp suitable for transmission to another system in string format. Local wall time will be used if millis isn't supplied.
factory
Hlc.zero(T nodeId)

Properties

counter int
final
hashCode int
The hash code for this object.
no setteroverride
logicalTime int
no setter
millis int
final
nodeId → T
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

apply({int? millis, int? counter, T? nodeId}) Hlc
compareTo(Hlc other) int
Compares this object to another object.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() String
toString() String
A string representation of this object.
override

Operators

operator <(dynamic other) bool
operator <=(dynamic other) bool
operator ==(Object other) bool
The equality operator.
override
operator >(dynamic other) bool
operator >=(dynamic other) bool