Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Override ¶
func Override(implementation Implementation) func()
Override replaces the global implementation used for timex The returned function should be called to restore the default implementation
Types ¶
type Implementation ¶
type Implementation interface {
Now() time.Time
Since(t time.Time) time.Duration
Until(t time.Time) time.Duration
Sleep(d time.Duration)
After(d time.Duration) <-chan time.Time
AfterFunc(d time.Duration, f func()) Timer
NewTicker(d time.Duration) Ticker
NewTimer(d time.Duration) Timer
}
Implementation defines the methods we delegate
type Ticker ¶
type Ticker interface {
// C returns the channel where each tick will be signaled, like Ticker.C in time package
C() <-chan time.Time
// Stop stops the ticker, no more ticks will be received in `C()`
Stop()
}
Ticker is an interface similar to what time.Ticker provides, but with C as a function returning the channel instead of accessing a plain struct property, so we can mock it. See time.Ticker docs for more details
type Timer ¶
type Timer interface {
// C returns the channel where the tick will be signaled, like Timer.C in time package
C() <-chan time.Time
// Stop stops the timer, see exact docs on time.Timer for information about channel draining when Stop returns false
Stop() bool
}
Timer is an interface similar to what time.Timer provides, but with C as a function returning the channel instead of accessing a plain struct property, so we can mock it. See time.Timer docs for more details
Click to show internal directories.
Click to hide internal directories.