hlc

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2024 License: MIT Imports: 9 Imported by: 2

Documentation

Overview

Copyright (c) Microsoft Corporation. Licensed under the MIT License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Set

func Set(hlc HybridLogicalClock) error

Set syncs the global HLC instance to the given HLC.

Types

type HybridLogicalClock

type HybridLogicalClock struct {
	Timestamp time.Time
	Counter   uint64
	NodeID    string
}

HybridLogicalClock provides a combination of physical and logical clocks used to track timestamps across a distributed system.

func Get

func Get() (HybridLogicalClock, error)

Get syncs the global HLC instance to the current time and returns it.

func Parse

func Parse(name, value string) (HybridLogicalClock, error)

Parse the HLC from a string.

func (HybridLogicalClock) Compare

func (hlc HybridLogicalClock) Compare(other HybridLogicalClock) int

Compare this HLC value with another one.

func (HybridLogicalClock) IsZero

func (hlc HybridLogicalClock) IsZero() bool

IsZero returns whether this HLC matches its zero value.

func (HybridLogicalClock) String

func (hlc HybridLogicalClock) String() string

String retrieves a serialized form of the HLC.

func (HybridLogicalClock) Update

Update an HLC based on another one and return the new value.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL