github.com/mailgun/holster/v4@v4.20.0/clock/interface.go (about) 1 package clock 2 3 import "time" 4 5 // Timer see time.Timer. 6 type Timer interface { 7 C() <-chan time.Time 8 Stop() bool 9 Reset(d time.Duration) bool 10 } 11 12 // Ticker see time.Ticker. 13 type Ticker interface { 14 C() <-chan time.Time 15 Stop() 16 } 17 18 // NewStoppedTimer returns a stopped timer. Call Reset to get it ticking. 19 func NewStoppedTimer() Timer { 20 t := NewTimer(42 * time.Hour) 21 t.Stop() 22 return t 23 } 24 25 // Clock is an interface that mimics the one of the SDK time package. 26 type Clock interface { 27 Now() time.Time 28 Sleep(d time.Duration) 29 After(d time.Duration) <-chan time.Time 30 NewTimer(d time.Duration) Timer 31 AfterFunc(d time.Duration, f func()) Timer 32 NewTicker(d time.Duration) Ticker 33 Tick(d time.Duration) <-chan time.Time 34 Wait4Scheduled(n int, timeout time.Duration) bool 35 }