clock

package
v0.1.0-proto2a Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: MPL-2.0 Imports: 2 Imported by: 0

Documentation

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
	Since(t time.Time) time.Duration
}

Clock abstracts time measurement to allow for deterministic testing.

type MockClock

type MockClock struct {
	CurrentTime time.Time
	// contains filtered or unexported fields
}

MockClock is a controllable clock for testing. All accessors are guarded by a mutex so Advance and the read methods are safe to call from concurrent goroutines (e.g. a goroutine advancing time while another reads Now under the race detector).

func (*MockClock) Advance

func (m *MockClock) Advance(d time.Duration)

func (*MockClock) After

func (m *MockClock) After(d time.Duration) <-chan time.Time

func (*MockClock) Now

func (m *MockClock) Now() time.Time

func (*MockClock) Since

func (m *MockClock) Since(t time.Time) time.Duration

type RealClock

type RealClock struct{}

RealClock implements Clock using the standard time package.

func (RealClock) After

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

func (RealClock) Now

func (RealClock) Now() time.Time

func (RealClock) Since

func (RealClock) Since(t time.Time) time.Duration

Jump to

Keyboard shortcuts

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