mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-11 13:18:53 +00:00
tstime: add Since method (#8622)
Updates #8463 Signed-off-by: Claire Wang <claire@tailscale.com>
This commit is contained in:
@@ -84,6 +84,9 @@ type Clock interface {
|
||||
// by this Clock. When the ticker expires, it will call the provided func.
|
||||
// It follows the semantics of time.AfterFunc.
|
||||
AfterFunc(d time.Duration, f func()) TimerController
|
||||
// Since returns the time elapsed since t.
|
||||
// It follows the semantics of time.Since.
|
||||
Since(t time.Time) time.Duration
|
||||
}
|
||||
|
||||
// TickerController offers the receivers of a time.Ticker to ensure
|
||||
@@ -135,3 +138,8 @@ func (StdClock) NewTicker(d time.Duration) (TickerController, <-chan time.Time)
|
||||
func (StdClock) AfterFunc(d time.Duration, f func()) TimerController {
|
||||
return time.AfterFunc(d, f)
|
||||
}
|
||||
|
||||
// Since calls time.Since.
|
||||
func (StdClock) Since(t time.Time) time.Duration {
|
||||
return time.Since(t)
|
||||
}
|
||||
|
Reference in New Issue
Block a user