ntp

package
v0.4.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2020 License: MPL-2.0 Imports: 8 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
)

Variables

This section is empty.

Functions

This section is empty.

Types

type NTP

type NTP struct {
	Server  string
	MinPoll time.Duration
	MaxPoll time.Duration
}

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() (resp *ntp.Response, err error)

Query polls the ntp server and verifies a successful response.

func (*NTP) QueryAndSetTime added in v0.3.0

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

QueryAndSetTime queries the NTP server and sets the time.

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