Documentation
¶
Overview ¶
Package clock is beekeeper's time: Now, Since, Until, After, Sleep, NewTimer, NewTicker and AfterFunc, in place of the time package's, and WithTimeout in place of context.WithTimeout.
A release build uses the system clock and nothing else: every function is the time package's own, and nothing reads the environment.
A scenario build (go build -tags scenario, docs/scenarios.md) reads Env. When it names a socket, every process of the scenario reads the scenario world's time from it: the system clock moved by the world's offset. The world's advance step moves that offset forward and wakes, in every process, the timers, tickers and sleeps then due, so an hour of loop passes takes seconds. Without Env a scenario build uses the system clock too.
The core flows use this package instead of the time package's clock functions; TestMigratedPackagesUseTheClock lists them and fails when one of them calls the time package's clock again.
Index ¶
Constants ¶
const Env = "BEEKEEPER_SCENARIO_CLOCK"
Env names the scenario world's clock socket to a scenario build. A release build never reads it.
const Scenario = false
Scenario says this build reads a scenario world's clock (Env); a release build never does.
Variables ¶
This section is empty.
Functions ¶
func WithTimeout ¶
WithTimeout is context.WithTimeout on the clock: the context ends once d has passed on it, the world's time in a scenario. Deadline and Err answer as context.WithTimeout's do: Err is context.DeadlineExceeded once d has passed.
Types ¶
type Ticker ¶
Ticker is time.Ticker on the clock: C receives the time every period, dropping ticks a slow receiver misses.