ntp

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Checker

type Checker struct {
	// contains filtered or unexported fields
}

Checker represents a NTP checker that periodically checks the system time against the network time.

func NewNtpChecker

func NewNtpChecker(opts ...CheckerOption) *Checker

NewNtpChecker creates a new Checker with the provided options. If no options are provided, it uses default values for interval and threshold.

func (*Checker) ClockOffset added in v1.3.0

func (c *Checker) ClockOffset() (time.Duration, error)

func (*Checker) IsOutOfSync added in v1.3.0

func (c *Checker) IsOutOfSync() bool

func (*Checker) Start

func (c *Checker) Start()

func (*Checker) Stop

func (c *Checker) Stop()

type CheckerOption added in v1.3.0

type CheckerOption func(*Checker)

CheckerOption defines the type for functions that configure a Checker.

func WithInterval added in v1.3.0

func WithInterval(interval time.Duration) CheckerOption

WithInterval sets the interval at which the checker will run. Default interval is 1 minute.

func WithQuerier added in v1.3.0

func WithQuerier(querier Querier) CheckerOption

WithQuerier sets the Querier for the Checker.

func WithThreshold added in v1.3.0

func WithThreshold(threshold time.Duration) CheckerOption

WithThreshold sets the threshold for determining if the system time is out of sync. Default threshold is 1 second.

type Querier added in v1.3.0

type Querier interface {
	Query(address string) (*ntp.Response, error)
}

type QueryError added in v1.3.0

type QueryError struct{}

QueryError is returned when a query from all NTP pools encounters an error and we have no valid response from them.

func (QueryError) Error added in v1.3.0

func (QueryError) Error() string

type RemoteQuerier added in v1.3.0

type RemoteQuerier struct{}

func (RemoteQuerier) Query added in v1.3.0

func (RemoteQuerier) Query(address string) (*ntp.Response, error)

Jump to

Keyboard shortcuts

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