Documentation ¶
Overview ¶
Package clock defines interfaces for interacting with the passage of time.
For testing, it is sometimes appropriate to inject a mock clock into a function to control it, for example, when it uses a timer to make a decision.
This package's interface mirrors that of the Kubernetes API machinery clock interface. We encourage you to use their mocks when possible. You can find an easy-to-use adapter in the package clock/k8sext.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Clock ¶
type Clock interface { PassiveClock After(time.Duration) <-chan time.Time NewTimer(time.Duration) Timer Sleep(time.Duration) NewTicker(time.Duration) Ticker }
Clock is a clock that provides both timing information and the ability to schedule.
var RealClock Clock = &realClock{}
RealClock is the system clock. It delegates to the time package.
func NewTimerCallbackClock ¶
func NewTimerCallbackClock(delegate Clock, fn TimerCallbackFunc) Clock
NewTimerCallbackClock makes a clock that calls a particular function just after NewTimer() or a timer's Reset() is called.
type PassiveClock ¶
PassiveClock is a clock that provides timing information but not the ability to schedule events for the future.
type TimerCallbackFunc ¶
TimerCallbackFunc is the callback function for a timer.