clock

package
v0.0.0-...-d13d30b Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package clock provides a testable clock interface for TTL calculations.

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 is an interface for getting the current time.

type Mock

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

Mock is a controllable clock for tests.

func NewMock

func NewMock(t time.Time) *Mock

NewMock creates a Mock clock set to the given time.

func (*Mock) Advance

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

Advance moves the clock forward by the given duration.

func (*Mock) Now

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

Now returns the mock clock's current time.

func (*Mock) Set

func (m *Mock) Set(t time.Time)

Set sets the mock clock to an absolute time.

type Real

type Real struct{}

Real is the production clock -- uses system time.

func (Real) Now

func (Real) Now() time.Time

Now returns the current system time.

Jump to

Keyboard shortcuts

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