Documentation
¶
Overview ¶
Package clock is the source of the current time for muster's timers that measure elapsed time: the reconnect backoff of a remote MCPServer and the orchestrator's retry and health-probe ticks, and the age of the aggregator's core catalogue.
In production Now is time.Now. When MUSTER_TEST_CLOCK names a Unix socket, the process serves a control endpoint on it (StartControl) through which the integration test harness advances the clock: Now jumps forward by the offset and every Ticker whose next tick has become due fires at once. A scenario about a two-minute backoff cap or a five-minute catalogue age then runs on the production schedule in milliseconds, instead of on intervals shortened through environment knobs. The offset is process-wide and only ever grows, as wall time does.
Index ¶
- Constants
- func Advance(d time.Duration) (time.Duration, error)
- func Now() time.Time
- func Offset() time.Duration
- func RemoteAdvance(path string, d time.Duration) (time.Duration, error)
- func RemoteOffset(path string) (time.Duration, error)
- func Since(t time.Time) time.Duration
- func StartControl() (stop func(), err error)
- func Until(t time.Time) time.Duration
- type Ticker
Constants ¶
const EnvControlSocket = "MUSTER_TEST_CLOCK"
EnvControlSocket is the environment variable that selects the clock's control socket. Set by the integration test harness for every instance it runs; unset in production, where nothing can move the clock.
Variables ¶
This section is empty.
Functions ¶
func Advance ¶
Advance moves the clock forward by d and returns the total offset. Every Ticker is woken, so a tick that has become due fires at once. A negative d is refused: the clock only moves forward.
func Now ¶
Now returns the current time as muster sees it: the system time plus the offset the clock has been advanced by.
func RemoteAdvance ¶
RemoteAdvance advances the clock of the process serving its control endpoint on path by d and returns that process's total offset.
func RemoteOffset ¶
RemoteOffset returns the total offset of the process serving its control endpoint on path.
func StartControl ¶
func StartControl() (stop func(), err error)
StartControl serves the clock's control endpoint on the Unix socket named by MUSTER_TEST_CLOCK and returns the function that stops it and removes the socket file. With the variable unset it serves nothing and returns a no-op. A socket file a previous life of the process left behind is replaced.
Types ¶
type Ticker ¶
type Ticker struct {
// C is the channel on which the ticks are delivered.
C <-chan time.Time
// contains filtered or unexported fields
}
Ticker delivers ticks at intervals of d on this clock, like time.Ticker, and also when Advance moves the clock past its next tick. A receiver that has not taken the previous tick is not sent a second one.