hlc

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: MIT Imports: 9 Imported by: 2

README

hlc

import "github.com/Azure/iot-operations-sdks/go/protocol/hlc"

Index

func Set

func Set(hlc HybridLogicalClock) error

Set syncs the global HLC instance to the given HLC.

type HybridLogicalClock

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

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

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
func (hlc HybridLogicalClock) Update(other HybridLogicalClock) (HybridLogicalClock, error)

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

Generated by gomarkdoc

Documentation

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