2
0

clock.go 495 B

12345678910111213141516171819202122232425262728293031
  1. package sentio
  2. import "time"
  3. type Clock interface {
  4. Now() time.Time
  5. After(d time.Duration) <-chan time.Time
  6. }
  7. type ClockUTC struct {
  8. }
  9. func (t ClockUTC) Now() time.Time {
  10. return time.Now().In(time.UTC)
  11. }
  12. func (t ClockUTC) After(d time.Duration) <-chan time.Time {
  13. return time.After(d)
  14. }
  15. type StubClock struct {
  16. Clock time.Time
  17. }
  18. func (t StubClock) Now() time.Time {
  19. return t.Clock.In(time.UTC)
  20. }
  21. func (t StubClock) After(d time.Duration) <-chan time.Time {
  22. return time.After(d)
  23. }