clock

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package clock provides a time abstraction so business logic can be tested deterministically. Production code uses Real; tests use Fake.

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
}

Clock returns the current time. All decay-and-reinforce logic accepts a Clock so tests can fast-forward without sleeping.

type Fake

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

Fake is a controllable Clock for tests.

func NewFake

func NewFake(t time.Time) *Fake

NewFake creates a Fake initialized to the given time.

func (*Fake) Advance

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

Advance moves the fake's clock forward by d.

func (*Fake) Now

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

func (*Fake) Set

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

Set replaces the fake's current time.

type Real

type Real struct{}

Real returns the wall-clock 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