clock.go 367 B

1234567891011121314151617181920
  1. package congestion
  2. import "time"
  3. // A Clock returns the current time
  4. type Clock interface {
  5. Now() time.Time
  6. }
  7. // DefaultClock implements the Clock interface using the Go stdlib clock.
  8. type DefaultClock struct {
  9. TimeFunc func() time.Time
  10. }
  11. var _ Clock = DefaultClock{}
  12. // Now gets the current time
  13. func (c DefaultClock) Now() time.Time {
  14. return c.TimeFunc()
  15. }