Documentation
¶
Overview ¶
Copyright (c) Microsoft Corporation. Licensed under the MIT License.
Index ¶
Constants ¶
const DefaultMaxClockDrift = time.Minute
DefaultMaxClockDrift is the default maximum HLC clock drift if none is otherwise specified (one minute).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Global ¶ added in v0.4.0
type Global struct {
// contains filtered or unexported fields
}
Global provides a shared instance of an HLC. Only one of these should typically be created per application.
func New ¶ added in v0.4.0
func New(opt ...HybridLogicalClockOption) *Global
New creates a new shared instance of an HLC. Only one of these should typically be created per application.
func (*Global) Get ¶ added in v0.4.0
func (g *Global) Get() (HybridLogicalClock, error)
Get syncs the shared HLC instance to the current time and returns it.
func (*Global) Parse ¶ added in v0.4.0
func (g *Global) Parse(name, value string) (HybridLogicalClock, error)
Parse the HLC from a string.
func (*Global) Set ¶ added in v0.4.0
func (g *Global) Set(hlc HybridLogicalClock) error
Set syncs the shared HLC instance to the given HLC.
type HybridLogicalClock ¶
type HybridLogicalClock struct {
// contains filtered or unexported fields
}
HybridLogicalClock provides a combination of physical and logical clocks used to track timestamps across a distributed system.
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) UTC ¶ added in v0.4.0
func (hlc HybridLogicalClock) UTC() time.Time
UTC returns the physical clock component of the HTC in UTC.
func (HybridLogicalClock) Update ¶
func (hlc HybridLogicalClock) Update( other HybridLogicalClock, ) (HybridLogicalClock, error)
Update an HLC based on another one and return the new value.
type HybridLogicalClockOption ¶ added in v0.4.0
type HybridLogicalClockOption interface {
// contains filtered or unexported methods
}
HybridLogicalClockOption represents a single HLC option.
type HybridLogicalClockOptions ¶ added in v0.4.0
HybridLogicalClockOptions are the resolved HLC options.
func (*HybridLogicalClockOptions) Apply ¶ added in v0.4.0
func (o *HybridLogicalClockOptions) Apply( opts []HybridLogicalClockOption, rest ...HybridLogicalClockOption, )
Apply resolves the provided list of options.
type WithMaxClockDrift ¶ added in v0.4.0
WithMaxClockDrift specifies how long HLCs are allowed to drift from the wall clock before they are considered no longer valid.