v.io: v.io/x/ref/lib/timekeeper Index | Files

package timekeeper

import "v.io/x/ref/lib/timekeeper"

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


Package Files


type TimeKeeper Uses

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 Uses

func RealTime() TimeKeeper

RealTime returns a default instance of TimeKeeper.

Package timekeeper imports 1 packages (graph) and is imported by 12 packages. Updated 2020-06-09. Refresh now. Tools for package owners.