package station import "time" // Clock is the time source for heartbeats and the retry wait. type Clock interface { Now() time.Time NewTimer(d time.Duration) Timer } // Timer is a single deadline. Stop prevents the channel from firing. type Timer interface { C() <-chan time.Time Stop() bool } type wallClock struct{} func (wallClock) Now() time.Time { return time.Now() } func (wallClock) NewTimer(d time.Duration) Timer { if d < 0 { d = 0 } return wallTimer{t: time.NewTimer(d)} } type wallTimer struct{ t *time.Timer } func (w wallTimer) C() <-chan time.Time { return w.t.C } func (w wallTimer) Stop() bool { return w.t.Stop() }