clock

package
v0.0.0-...-6834a60 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clock

type Clock interface {
	Now() time.Time
	Since(time.Time) time.Duration
	After(d time.Duration) <-chan time.Time
	NewTimer(d time.Duration) Timer
	Sleep(d time.Duration)
	Tick(d time.Duration) <-chan time.Time
}

Clock allows for injecting fake or real clocks into code that needs to do arbitrary things based on time.

type RealClock

type RealClock struct{}

RealClock really calls time.Now()

func (RealClock) After

func (RealClock) After(d time.Duration) <-chan time.Time

After is the same as time.After(d).

func (RealClock) NewTimer

func (RealClock) NewTimer(d time.Duration) Timer

NewTimer is the same as time.NewTimer(d)

func (RealClock) Now

func (RealClock) Now() time.Time

Now returns the current time.

func (RealClock) Since

func (RealClock) Since(ts time.Time) time.Duration

Since returns time since the specified timestamp.

func (RealClock) Sleep

func (RealClock) Sleep(d time.Duration)

Sleep is the same as time.Sleep(d)

func (RealClock) Tick

func (RealClock) Tick(d time.Duration) <-chan time.Time

Tick is the same as time.Tick(d)

type Timer

type Timer interface {
	C() <-chan time.Time
	Stop() bool
	Reset(d time.Duration) bool
}

Timer allows for injecting fake or real timers into code that needs to do arbitrary things based on time.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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