Documentation
¶
Index ¶
- type Clock
- type FakeClock
- func (c FakeClock) Advance(d time.Duration)
- func (c FakeClock) After(d time.Duration) <-chan time.Time
- func (c FakeClock) AfterFunc(d time.Duration, f func()) Timer
- func (c FakeClock) BlockUntil(n int)
- func (c FakeClock) NewTicker(d time.Duration) Ticker
- func (c FakeClock) NewTimer(d time.Duration) Timer
- func (c FakeClock) Now() time.Time
- func (c FakeClock) Since(t time.Time) time.Duration
- func (c FakeClock) Sleep(d time.Duration)
- func (c FakeClock) Tick(d time.Duration) <-chan time.Time
- func (c FakeClock) Until(t time.Time) time.Duration
- func (c FakeClock) WaitersCount() int
- type Ticker
- type Timer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Clock ¶
type Clock interface {
Now() time.Time
After(d time.Duration) <-chan time.Time
AfterFunc(d time.Duration, f func()) Timer
Since(t time.Time) time.Duration
Until(t time.Time) time.Duration
Sleep(d time.Duration)
Tick(d time.Duration) <-chan time.Time
NewTicker(d time.Duration) Ticker
NewTimer(d time.Duration) Timer
}
Clock contains various time's functions that can be mocked.
func NewRealClock ¶
func NewRealClock() Clock
NewRealClock returns a new instance of the real clock.
type FakeClock ¶
type FakeClock struct {
// contains filtered or unexported fields
}
FakeClock is an internalClock's shallow wrapper. It provides special mock methods such Advance or WaitersCount.
func NewFakeClock ¶
func NewFakeClock() FakeClock
NewFakeClock returns a new instance of the fake clock.
func NewFakeClockAt ¶
NewFakeClockAt returns a new instance of the fake clock. Specified time will be used as a current clock's time.
func (FakeClock) Advance ¶
Advance moves current clock's time forward. It affects all active timers/tickers/sleepers.
func (FakeClock) BlockUntil ¶
BlockUntil waits for the specified count of active timers/tickers/sleepers.
func (FakeClock) NewTicker ¶
NewTicker implements Clock. It returns a new instance of the mock ticker.
func (FakeClock) WaitersCount ¶
WaitersCount returns current active timers/tickers/sleepers count.
