ntp

package
v0.9.0-alpha.5 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2021 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxAllowablePoll is the 'recommended' interval for querying a time server.
	MaxAllowablePoll = 1024
	// MinAllowablePoll is the minimum time allowed for a client to query a time server.
	MinAllowablePoll = 4
	// AdjustTimeLimit is a maximum time drift to compensate via adjtimex().
	AdjustTimeLimit = 128 * time.Millisecond
)

Variables

This section is empty.

Functions

This section is empty.

Types

type NTP

type NTP struct {
	Server  string
	MinPoll time.Duration
	MaxPoll time.Duration
	// contains filtered or unexported fields
}

NTP contains a server address.

func NewNTPClient

func NewNTPClient(opts ...Option) (*NTP, error)

NewNTPClient instantiates a new ntp client for the specified server.

func (*NTP) Daemon

func (n *NTP) Daemon() (err error)

Daemon runs the control loop for query and set time We dont ever want the daemon to stop, so we only log errors.

func (*NTP) GetTime

func (n *NTP) GetTime() time.Time

GetTime returns the current system time.

func (*NTP) Query

func (n *NTP) Query(ctx context.Context) (resp *ntp.Response, err error)

Query polls the ntp server and verifies a successful response.

func (*NTP) QueryAndSetTime

func (n *NTP) QueryAndSetTime(ctx context.Context) (err error)

QueryAndSetTime queries the NTP server and sets the time.

func (*NTP) Ready added in v0.6.0

func (n *NTP) Ready() bool

Ready checks whether initial time sync has already happened.

type Option

type Option func(*NTP) error

Option allows for the configuration of the ntp client.

func WithMaxPoll

func WithMaxPoll(o int) Option

WithMaxPoll configures the ntp client MaxPoll interval.

func WithMinPoll

func WithMinPoll(o int) Option

WithMinPoll configures the ntp client MinPoll interval.

func WithServer

func WithServer(o string) Option

WithServer configures the ntp client to use the specified server.

Jump to

Keyboard shortcuts

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