timekeeper

package
v0.0.0-...-ba1c585 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2017 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Overview

Package timekeeper defines an interface to allow switching between real time and simulated time.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TimeKeeper

type TimeKeeper interface {
	// After waits for the duration to elapse and then sends the current
	// time on the returned channel.
	After(d time.Duration) <-chan time.Time
	// Sleep pauses the current goroutine for at least the duration d. A
	// negative or zero duration causes Sleep to return immediately.
	Sleep(d time.Duration)
	// Current time.
	Now() time.Time
}

TimeKeeper is meant as a drop-in replacement for using the time package directly, and allows testing code to substitute a suitable implementation. The meaning of duration and current time depends on the implementation (may be a simulated time).

func RealTime

func RealTime() TimeKeeper

RealTime returns a default instance of TimeKeeper.

Jump to

Keyboard shortcuts

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