clock

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 2 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 clock abstracts time for deterministic tests (governor yield latency, backoff, rolling stats).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clock

type Clock interface {
	Now() time.Time
	After(d time.Duration) <-chan time.Time
}

Clock is the minimal surface the daemon needs.

type Fake

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

Fake is a manually advanced clock for tests.

func NewFake

func NewFake() *Fake

NewFake starts at a fixed, arbitrary epoch.

func NewFakeAt

func NewFakeAt(t time.Time) *Fake

NewFakeAt starts at t.

func (*Fake) Advance

func (f *Fake) Advance(d time.Duration)

Advance moves time forward and fires due waiters.

func (*Fake) After

func (f *Fake) After(d time.Duration) <-chan time.Time

func (*Fake) BlockUntilWaiters

func (f *Fake) BlockUntilWaiters(n int, timeout time.Duration) bool

BlockUntilWaiters polls (real time) until at least n waiters are pending or the timeout elapses; returns whether the condition was met.

func (*Fake) Now

func (f *Fake) Now() time.Time

func (*Fake) Set

func (f *Fake) Set(t time.Time)

Set jumps the clock to an absolute time and fires due waiters.

func (*Fake) WaiterCount

func (f *Fake) WaiterCount() int

WaiterCount reports pending After() waiters (test synchronization).

type Real

type Real struct{}

Real is the wall clock.

func (Real) After

func (Real) After(d time.Duration) <-chan time.Time

func (Real) Now

func (Real) Now() time.Time

Jump to

Keyboard shortcuts

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