ash-time 1.0.0

Hybrid Logical Clocks for causality tracking with approximate wall-clock ordering across distributed nodes
Documentation
  • Coverage
  • 81.82%
    18 out of 22 items documented1 out of 13 items with examples
  • Size
  • Source code size: 41.55 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 497.82 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 7s Average build duration of successful builds.
  • all releases: 7s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • ashforge-rs/ash-time
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • gntem

ash-time

Distributed time primitives for Rust. ash-time is a toolkit for reasoning about order and causality across nodes — answering "did A happen before B?" without a central coordinator.

  Node A  ── stamp(write) → ts=(103ms, 0) ──────────────────────────▶
                                   │  message carries ts
                                   ▼
  Node B  ── recv(ts) → ts=(103ms, 1) ── stamp(read) → ts=(103ms, 2) ──▶

  (103ms, 0) < (103ms, 2): the read is provably after the write.

Algorithms

Hybrid Logical Clock (ash_time::hlc)

Tracks causality while staying anchored to wall time. The clock ticks with the system clock when it can, and falls back to a logical counter to break ties within the same nanosecond.

use ash_time::HlcClock;

let clock = HlcClock::new();

// stamp an outgoing message
let send_ts = clock.now().unwrap();

// advance on an incoming message — recv_ts is provably after send_ts
let recv_ts = clock.recv(send_ts).unwrap();
assert!(send_ts.happened_before(recv_ts));

See the crate docs for the full API.

Installation

cargo add ash-time

License

Licensed under the Apache License, Version 2.0.