ntp

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2023 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrIndexOutOfBounds = errors.New("index is out of bounds")

ErrIndexOutOfBounds is raised when an out of bound index is used

Functions

func NewNTPGoogleConfig

func NewNTPGoogleConfig() config.NTPConfig

NewNTPGoogleConfig creates an NTPConfig object that configures NTP to use a predefined list of hosts. This is useful for tests, for example, to avoid loading a configuration file just to have a NTPConfig

func NewSyncTime

func NewSyncTime(
	ntpConfig config.NTPConfig,
	customQueryFunc func(options NTPOptions, hostIndex int) (*ntp.Response, error),
) *syncTime

NewSyncTime creates a syncTime object. The customQueryFunc argument allows the caller to set a different NTP-querying callback, if desired. If set to nil, then the default queryNTP is used

Types

type NTPOptions

type NTPOptions struct {
	Hosts        []string
	Version      int
	LocalAddress string
	Timeout      time.Duration
	Port         int
}

NTPOptions defines configuration options for a NTP query

func NewNTPOptions

func NewNTPOptions(ntpConfig config.NTPConfig) NTPOptions

NewNTPOptions creates a new NTPOptions object

type SyncTimer

type SyncTimer interface {
	Close() error
	StartSyncingTime()
	ClockOffset() time.Duration
	FormattedCurrentTime() string
	CurrentTime() time.Time
	IsInterfaceNil() bool
}

SyncTimer defines an interface for time synchronization

Jump to

Keyboard shortcuts

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