mirror of
https://github.com/compute-blade-community/compute-blade-agent.git
synced 2026-04-16 15:35:42 +02:00
25 lines
511 B
Go
25 lines
511 B
Go
package util
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// Clock is an interface for the time package
|
|
type Clock interface {
|
|
// Now returns the current time.
|
|
Now() time.Time
|
|
// After waits for the duration to elapse and then sends the current time
|
|
After(d time.Duration) <-chan time.Time
|
|
}
|
|
|
|
// RealClock implements the Clock interface using the real time package.
|
|
type RealClock struct{}
|
|
|
|
func (RealClock) Now() time.Time {
|
|
return time.Now()
|
|
}
|
|
|
|
func (RealClock) After(d time.Duration) <-chan time.Time {
|
|
return time.After(d)
|
|
}
|