hlc

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2025 License: MIT Imports: 2 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clock

type Clock struct {
	// contains filtered or unexported fields
}

Clock is a thread-safe Hybrid Logical Clock using atomics.

func NewClock

func NewClock() *Clock

NewClock creates a new HLC clock.

func (*Clock) Now

func (c *Clock) Now() Timestamp

Now returns a new Timestamp based on the current time and HLC rules.

type Timestamp

type Timestamp uint64

Timestamp represents a Hybrid Logical Clock timestamp.

func Now

func Now() Timestamp

Now returns a new Timestamp from the default Clock.

func (Timestamp) After

func (ts Timestamp) After(other Timestamp) bool

After returns true if ts is after other.

func (Timestamp) Before

func (ts Timestamp) Before(other Timestamp) bool

Before returns true if ts is before other.

func (Timestamp) Counter

func (ts Timestamp) Counter() uint16

Counter extracts the counter component.

func (Timestamp) Equal

func (ts Timestamp) Equal(other Timestamp) bool

Equal returns true if ts is equal to other.

func (Timestamp) Time

func (ts Timestamp) Time() time.Time

Time extracts the time component as time.Time.

Jump to

Keyboard shortcuts

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