service backend
This commit is contained in:
21
api/pkg/clock/clock.go
Normal file
21
api/pkg/clock/clock.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package clock
|
||||
|
||||
import "time"
|
||||
|
||||
// Clock exposes basic time operations, primarily for test overrides.
|
||||
type Clock interface {
|
||||
Now() time.Time
|
||||
}
|
||||
|
||||
// System implements Clock using the system wall clock.
|
||||
type System struct{}
|
||||
|
||||
// Now returns the current UTC time.
|
||||
func (System) Now() time.Time {
|
||||
return time.Now().UTC()
|
||||
}
|
||||
|
||||
// NewSystem returns a system-backed clock instance.
|
||||
func NewSystem() Clock {
|
||||
return System{}
|
||||
}
|
||||
Reference in New Issue
Block a user