Documentation
¶
Overview ¶
Package clock provides the injectable time source used by app and adapter code: Real for production and Fake for tests and simulations driven by a manually advanced clock.
fc := clock.NewFake(time.Date(2026, 1, 1, 0, 0, 0, 0, time.UTC)) ch := fc.After(time.Second) fc.Advance(time.Second) // ch now has a value
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Clock ¶
type Clock interface {
// Now returns the current time.
Now() time.Time
// After returns a channel that receives the time once d has elapsed.
After(d time.Duration) <-chan time.Time
// NewTicker returns a ticker that fires every d.
NewTicker(d time.Duration) Ticker
}
Clock is the source of time for every client-side time value and every time comparison Foreman sends to Postgres.
type Fake ¶
type Fake struct {
// contains filtered or unexported fields
}
Fake is a manually advanced clock for tests and simulations. Timers and tickers created from it fire only when Advance or Set moves time past their deadline. It is safe for concurrent use.
Click to show internal directories.
Click to hide internal directories.