Proposed repo for juju/clock
Go Makefile
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
clocktest
LICENSE
Makefile
README.md
clock.go
clock_test.go
package_test.go
wall.go

README.md

clock

import "github.com/juju/clock"

The clock package provides an interface that provides the two most common uses of the time package: Now, and After. This allows tests to provide an alternative Clock implementation, particularly one where the test is in control of the time spent waiting.

Variables

var WallClock wallClock

WallClock exposes wall-clock time via the Clock interface.

func Alarm

func Alarm(c Clock, t time.Time) <-chan time.Time

Alarm returns a channel that will have the time sent on it at some point after the supplied time occurs.

This is short for c.After(t.Sub(c.Now())).

type Clock

type Clock interface {

    // Now returns the current clock time.
    Now() time.Time

    // After waits for the duration to elapse and then sends the
    // current time on the returned channel.
    After(time.Duration) <-chan time.Time
}

Clock provides an interface for dealing with clocks.


Generated by godoc2md