[VOL-4290] Voltha go library updates for gRPC migration
Change-Id: I1aa2774beb6b7ed7419bc45aeb53fcae8a8ecda0
diff --git a/vendor/github.com/jonboulle/clockwork/clockwork.go b/vendor/github.com/jonboulle/clockwork/clockwork.go
index 9ec96ed..1018051 100644
--- a/vendor/github.com/jonboulle/clockwork/clockwork.go
+++ b/vendor/github.com/jonboulle/clockwork/clockwork.go
@@ -11,6 +11,8 @@
After(d time.Duration) <-chan time.Time
Sleep(d time.Duration)
Now() time.Time
+ Since(t time.Time) time.Duration
+ NewTicker(d time.Duration) Ticker
}
// FakeClock provides an interface for a clock which can be
@@ -60,6 +62,14 @@
return time.Now()
}
+func (rc *realClock) Since(t time.Time) time.Duration {
+ return rc.Now().Sub(t)
+}
+
+func (rc *realClock) NewTicker(d time.Duration) Ticker {
+ return &realTicker{time.NewTicker(d)}
+}
+
type fakeClock struct {
sleepers []*sleeper
blockers []*blocker
@@ -87,7 +97,7 @@
defer fc.l.Unlock()
now := fc.time
done := make(chan time.Time, 1)
- if d.Nanoseconds() == 0 {
+ if d.Nanoseconds() <= 0 {
// special case - trigger immediately
done <- now
} else {
@@ -130,6 +140,22 @@
return t
}
+// Since returns the duration that has passed since the given time on the fakeClock
+func (fc *fakeClock) Since(t time.Time) time.Duration {
+ return fc.Now().Sub(t)
+}
+
+func (fc *fakeClock) NewTicker(d time.Duration) Ticker {
+ ft := &fakeTicker{
+ c: make(chan time.Time, 1),
+ stop: make(chan bool, 1),
+ clock: fc,
+ period: d,
+ }
+ ft.runTickThread()
+ return ft
+}
+
// Advance advances fakeClock to a new point in time, ensuring channels from any
// previous invocations of After are notified appropriately before returning
func (fc *fakeClock) Advance(d time.Duration) {