Hlc 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(DateTime dateTime, int counter, String nodeId)
- Hlc.fromDate(DateTime dateTime, String nodeId)
-
Instantiates an Hlc at
dateTime
with logical counter zero. - Hlc.now(String nodeId)
- Instantiates an Hlc using the wall clock.
- Hlc.parse(String timestamp)
-
Parse an HLC string in the format
ISO8601 date-counter-node id
.factory - Hlc.zero(String nodeId)
- Instantiates an Hlc at the beginning of time and space: January 1, 1970.
Properties
Methods
-
apply(
{DateTime? dateTime, int? counter, String? nodeId}) → Hlc - Create a copy of this object applying the optional properties.
-
compareTo(
Hlc other) → int -
Compares this object to another object.
override
-
increment(
{DateTime? wallTime}) → Hlc -
Increments the current timestamp for transmission to another system.
The local wall time will be used if
wallTime
isn't supplied. -
merge(
Hlc remote, {DateTime? wallTime}) → Hlc -
Compares and validates a timestamp from a remote system with the local
timestamp to preserve monotonicity.
Local wall time will be used if
wallTime
isn't supplied. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → String - Convenience method for easy json encoding.
-
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