clock

package
v0.0.0-...-a9d0937 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 2 Imported by: 22

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clock

type Clock interface {
	// Return the current time of day. Equivalent to time.Now().
	Now() time.Time

	// Create a Context object that automatically cancels after a
	// certain amount of time has passed. Equivalent to
	// context.WithTimeout().
	NewContextWithTimeout(parent context.Context, timeout time.Duration) (context.Context, context.CancelFunc)

	// Create a channel that publishes the time of day at a point of
	// time in the future. Unlike time.NewTimer(), this function
	// returns the channel directly to allow Timer to be an
	// interface.
	NewTimer(d time.Duration) (Timer, <-chan time.Time)
}

Clock is an interface around some of the standard library functions that provide time handling. It has been added to aid unit testing.

var SystemClock Clock = systemClock{}

SystemClock is a Clock that corresponds to the current time of day, as reported by the operating system.

type Timer

type Timer interface {
	Stop() bool
}

Timer is an interface around time.Timer. It has been added to aid unit testing.

Jump to

Keyboard shortcuts

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