Documentation
¶
Overview ¶
Forked from github.com/StefanKopieczek/gossip by @StefanKopieczek
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var MockMode = false
Controls whether library calls should be mocked, or whether we should use the standard Go time library. If we're in Mock Mode, then time does not pass as normal, but only progresses when Elapse is called. False by default, indicating that we just call through to standard Go functions.
Functions ¶
func Elapse ¶
Increment the current time by the given Duration. This function can only be called in Mock Mode, otherwise we will panic.
Types ¶
type Timer ¶
type Timer interface { // Returns a channel which sends the current time immediately when the timer expires. // Equivalent to time.Timer.C; however, we have to use a method here instead of a member since this is an interface. C() <-chan time.Time // Resets the timer such that it will expire in duration 'd' after the current time. // Returns true if the timer had been active, and false if it had expired or been stopped. Reset(d time.Duration) bool // Stops the timer, preventing it from firing. // Returns true if the timer had been active, and false if it had expired or been stopped. Stop() bool }
Interface over Golang's built-in Timers, allowing them to be swapped out for mocked timers.
Click to show internal directories.
Click to hide internal directories.