github.com/livekit/protocol@v1.16.1-0.20240517185851-47e4c6bba773/utils/clock.go (about) 1 package utils 2 3 import ( 4 "time" 5 6 "github.com/benbjohnson/clock" 7 ) 8 9 type Clock interface { 10 Now() time.Time 11 Sleep(time.Duration) 12 } 13 14 type SystemClock struct{} 15 16 var _ Clock = &SystemClock{} 17 18 func (SystemClock) Now() time.Time { 19 return time.Now() 20 } 21 22 func (SystemClock) Sleep(d time.Duration) { 23 time.Sleep(d) 24 } 25 26 type SimulatedClock struct { 27 clock.Mock 28 } 29 30 var _ Clock = &SimulatedClock{}