fakeclock

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package fakeclock is a manual clock for tests of code that schedules with callbacks (healthcheck.Clock): time only moves with Advance.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clock

type Clock struct {
	// contains filtered or unexported fields
}

Clock is a manual clock. The zero value is not usable; use New.

func New

func New(start time.Time) *Clock

New returns a clock that reads start.

func (*Clock) Advance

func (c *Clock) Advance(d time.Duration)

Advance moves the clock forward by d and starts the callbacks of the timers that are due, earliest first.

func (*Clock) AfterFunc

func (c *Clock) AfterFunc(d time.Duration, f func()) (stop func() bool)

AfterFunc arranges for f to run in its own goroutine once the clock has been advanced by d (a delay of 0 or less: at the next Advance). The returned function cancels it and reports whether it was still armed.

func (*Clock) Armed

func (c *Clock) Armed() int

Armed returns the number of timers waiting to fire.

func (*Clock) Delays

func (c *Clock) Delays() []time.Duration

Delays returns the remaining delay of every armed timer, shortest first.

func (*Clock) Now

func (c *Clock) Now() time.Time

Now returns the clock's time.

Jump to

Keyboard shortcuts

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