clock

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2021 License: Apache-2.0 Imports: 4 Imported by: 59

Documentation

Overview

Package clock implements facilities for working with wall clock time.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WaitUntil

func WaitUntil(fn ConditionFn, timeout time.Duration) bool

WaitUntil returns true if the condition specified evaluated to true before the timeout, false otherwise.

Types

type ConditionFn

type ConditionFn func() bool

ConditionFn specifies a predicate to check.

type Configuration

type Configuration struct {
	// MaxPositiveSkew is the maximum positive clock skew
	// with regard to a reference clock.
	MaxPositiveSkew time.Duration `yaml:"maxPositiveSkew"`

	// MaxNegativeSkew is the maximum negative clock skew
	// with regard to a reference clock.
	MaxNegativeSkew time.Duration `yaml:"maxNegativeSkew"`
}

Configuration configures clock options.

func (Configuration) NewOptions

func (c Configuration) NewOptions() Options

NewOptions creates a new set of options.

type NowFn

type NowFn func() time.Time

NowFn is the function supplied to determine "now".

type OffsetClock added in v1.2.0

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

OffsetClock represents offset clock which returns current time from the initial seed time value.

func NewOffsetClock added in v1.2.0

func NewOffsetClock(offsetTime time.Time, nowFn NowFn) OffsetClock

NewOffsetClock returns new offset clock.

func NewOffsetClockFromTimeDelta added in v1.2.0

func NewOffsetClockFromTimeDelta(timeDelta time.Duration, nowFn NowFn) OffsetClock

NewOffsetClockFromTimeDelta returns new offset clock that has time shifted by timeDelta duration.

func (OffsetClock) Now added in v1.2.0

func (c OffsetClock) Now() time.Time

Now returns current time with time offset taken into account.

type Options

type Options interface {
	// SetNowFn sets the NowFn.
	SetNowFn(value NowFn) Options

	// NowFn returns the NowFn.
	NowFn() NowFn

	// SetMaxPositiveSkew sets the maximum positive clock skew
	// with regard to a reference clock.
	SetMaxPositiveSkew(value time.Duration) Options

	// MaxPositiveSkew returns the maximum positive clock skew
	// with regard to a reference clock.
	MaxPositiveSkew() time.Duration

	// SetMaxNegativeSkew sets the maximum negative clock skew
	// with regard to a reference clock.
	SetMaxNegativeSkew(value time.Duration) Options

	// MaxNegativeSkew returns the maximum negative clock skew
	// with regard to a reference clock.
	MaxNegativeSkew() time.Duration
}

Options represents the options for the clock.

func NewOptions

func NewOptions() Options

NewOptions creates new clock options.

Jump to

Keyboard shortcuts

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