Files
compute-blade-agent/pkg/util/clock.go
2023-07-17 07:01:54 +02:00

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)
}