Socket
Book a DemoInstallSign in
Socket

github.com/avatar29a/hlc

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/avatar29a/hlc

v1.0.0
Source
Go
Version published
Created
Source

hlc

Build Status Go Programming Language MIT License

Hybrid Logical Clock

Original Paper: Logical Physical Clocksand Consistent Snapshots in Globally Distributed Databases

Logical Clock is an important family of algorithms for ordering events into distributed system.

HLC presents enhanced Logic Clock's Lamport, which eliminates the gap between practical and theory of synchronised time.

How use it

Init HLC per Node

lc := hlc.New(&NTPClock{})

For every local event or sending, generate logical timestamp

ts := lc.Now() // 1605806872706744321

Notes: Timestamp compatible with NTP-format. First 48bit presents physical time and other 16bit logical time (see chapter "6.2 Compact Timestamping using l and c" of paper).

For every received event you should to update a local HLC instance

receivedHlc := hlc.FromTimestamp(receivedTC)
_ = lc.Update(receivedHlc) // skip a new timestamp

FAQs

Package last updated on 20 Nov 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.