<!-- Code generated by gomarkdoc. DO NOT EDIT -->

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

## Index

- [Constants](<#constants>)
- [type Global](<#Global>)
  - [func New\(opt ...HybridLogicalClockOption\) \*Global](<#New>)
  - [func \(g \*Global\) Get\(\) \(HybridLogicalClock, error\)](<#Global.Get>)
  - [func \(g \*Global\) Parse\(name, value string\) \(HybridLogicalClock, error\)](<#Global.Parse>)
  - [func \(g \*Global\) Set\(hlc HybridLogicalClock\) error](<#Global.Set>)
- [type HybridLogicalClock](<#HybridLogicalClock>)
  - [func \(hlc HybridLogicalClock\) Compare\(other HybridLogicalClock\) int](<#HybridLogicalClock.Compare>)
  - [func \(hlc HybridLogicalClock\) IsZero\(\) bool](<#HybridLogicalClock.IsZero>)
  - [func \(hlc HybridLogicalClock\) String\(\) string](<#HybridLogicalClock.String>)
  - [func \(hlc HybridLogicalClock\) UTC\(\) time.Time](<#HybridLogicalClock.UTC>)
  - [func \(hlc HybridLogicalClock\) Update\(other HybridLogicalClock\) \(HybridLogicalClock, error\)](<#HybridLogicalClock.Update>)
- [type HybridLogicalClockOption](<#HybridLogicalClockOption>)
- [type HybridLogicalClockOptions](<#HybridLogicalClockOptions>)
  - [func \(o \*HybridLogicalClockOptions\) Apply\(opts \[\]HybridLogicalClockOption, rest ...HybridLogicalClockOption\)](<#HybridLogicalClockOptions.Apply>)
- [type WithMaxClockDrift](<#WithMaxClockDrift>)


## Constants

<a name="DefaultMaxClockDrift"></a>DefaultMaxClockDrift is the default maximum HLC clock drift if none is otherwise specified \(one minute\).

```go
const DefaultMaxClockDrift = time.Minute
```

<a name="Global"></a>
## type [Global](<https://github.com/Azure/iot-operations-sdks/blob/main/go/protocol/hlc/hlc.go#L30-L34>)

Global provides a shared instance of an HLC. Only one of these should typically be created per application.

```go
type Global struct {
    // contains filtered or unexported fields
}
```

<a name="New"></a>
### func [New](<https://github.com/Azure/iot-operations-sdks/blob/main/go/protocol/hlc/hlc.go#L57>)

```go
func New(opt ...HybridLogicalClockOption) *Global
```

New creates a new shared instance of an HLC. Only one of these should typically be created per application.

<a name="Global.Get"></a>
### func \(\*Global\) [Get](<https://github.com/Azure/iot-operations-sdks/blob/main/go/protocol/hlc/hlc.go#L75>)

```go
func (g *Global) Get() (HybridLogicalClock, error)
```

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

<a name="Global.Parse"></a>
### func \(\*Global\) [Parse](<https://github.com/Azure/iot-operations-sdks/blob/main/go/protocol/hlc/hlc.go#L203>)

```go
func (g *Global) Parse(name, value string) (HybridLogicalClock, error)
```

Parse the HLC from a string.

<a name="Global.Set"></a>
### func \(\*Global\) [Set](<https://github.com/Azure/iot-operations-sdks/blob/main/go/protocol/hlc/hlc.go#L89>)

```go
func (g *Global) Set(hlc HybridLogicalClock) error
```

Set syncs the shared HLC instance to the given HLC.

<a name="HybridLogicalClock"></a>
## type [HybridLogicalClock](<https://github.com/Azure/iot-operations-sdks/blob/main/go/protocol/hlc/hlc.go#L21-L26>)

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

```go
type HybridLogicalClock struct {
    // contains filtered or unexported fields
}
```

<a name="HybridLogicalClock.Compare"></a>
### func \(HybridLogicalClock\) [Compare](<https://github.com/Azure/iot-operations-sdks/blob/main/go/protocol/hlc/hlc.go#L166>)

```go
func (hlc HybridLogicalClock) Compare(other HybridLogicalClock) int
```

Compare this HLC value with another one.

<a name="HybridLogicalClock.IsZero"></a>
### func \(HybridLogicalClock\) [IsZero](<https://github.com/Azure/iot-operations-sdks/blob/main/go/protocol/hlc/hlc.go#L181>)

```go
func (hlc HybridLogicalClock) IsZero() bool
```

IsZero returns whether this HLC matches its zero value.

<a name="HybridLogicalClock.String"></a>
### func \(HybridLogicalClock\) [String](<https://github.com/Azure/iot-operations-sdks/blob/main/go/protocol/hlc/hlc.go#L188>)

```go
func (hlc HybridLogicalClock) String() string
```

String retrieves a serialized form of the HLC.

<a name="HybridLogicalClock.UTC"></a>
### func \(HybridLogicalClock\) [UTC](<https://github.com/Azure/iot-operations-sdks/blob/main/go/protocol/hlc/hlc.go#L103>)

```go
func (hlc HybridLogicalClock) UTC() time.Time
```

UTC returns the physical clock component of the HTC in UTC.

<a name="HybridLogicalClock.Update"></a>
### func \(HybridLogicalClock\) [Update](<https://github.com/Azure/iot-operations-sdks/blob/main/go/protocol/hlc/hlc.go#L109-L111>)

```go
func (hlc HybridLogicalClock) Update(other HybridLogicalClock) (HybridLogicalClock, error)
```

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

<a name="HybridLogicalClockOption"></a>
## type [HybridLogicalClockOption](<https://github.com/Azure/iot-operations-sdks/blob/main/go/protocol/hlc/hlc.go#L37-L39>)

HybridLogicalClockOption represents a single HLC option.

```go
type HybridLogicalClockOption interface {
    // contains filtered or unexported methods
}
```

<a name="HybridLogicalClockOptions"></a>
## type [HybridLogicalClockOptions](<https://github.com/Azure/iot-operations-sdks/blob/main/go/protocol/hlc/hlc.go#L42-L44>)

HybridLogicalClockOptions are the resolved HLC options.

```go
type HybridLogicalClockOptions struct {
    MaxClockDrift time.Duration
}
```

<a name="HybridLogicalClockOptions.Apply"></a>
### func \(\*HybridLogicalClockOptions\) [Apply](<https://github.com/Azure/iot-operations-sdks/blob/main/go/protocol/hlc/hlc.go#L248-L251>)

```go
func (o *HybridLogicalClockOptions) Apply(opts []HybridLogicalClockOption, rest ...HybridLogicalClockOption)
```

Apply resolves the provided list of options.

<a name="WithMaxClockDrift"></a>
## type [WithMaxClockDrift](<https://github.com/Azure/iot-operations-sdks/blob/main/go/protocol/hlc/hlc.go#L48>)

WithMaxClockDrift specifies how long HLCs are allowed to drift from the wall clock before they are considered no longer valid.

```go
type WithMaxClockDrift time.Duration
```

Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)
