clock

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package clock provides a swap-able clock for tests. The conformance suite uses a fake clock for disconnect/reconnect/timeout scenarios so PR-gating tests don't depend on wall-clock waits.

Package clock is part of the GoFastr harness.

See docs/harness-architecture.md for the architecture this package implements.

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
	Sleep(d time.Duration)
}

Clock is the interface anything that needs time-of-day or Sleep uses. System returns the wall-clock implementation; Fake returns a manually-advanced one for tests.

func System

func System() Clock

System returns the wall-clock implementation.

type Fake

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

Fake is a manually-advanced clock for deterministic tests.

func NewFake

func NewFake(start time.Time) *Fake

NewFake returns a Fake clock starting at the given time.

func (*Fake) Advance

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

Advance moves the fake clock forward by d.

func (*Fake) Now

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

Now returns the current fake time.

func (*Fake) Sleep

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

Sleep advances the fake clock by d (returns immediately).

Jump to

Keyboard shortcuts

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