|
|
|
@ -143,15 +143,30 @@ func NewTracker(bus *eventbus.Bus) *Tracker {
|
|
|
|
panic("no eventbus set")
|
|
|
|
panic("no eventbus set")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
cli := bus.Client("health.Tracker")
|
|
|
|
ec := bus.Client("health.Tracker")
|
|
|
|
t := &Tracker{
|
|
|
|
t := &Tracker{
|
|
|
|
eventClient: cli,
|
|
|
|
eventClient: ec,
|
|
|
|
changePub: eventbus.Publish[Change](cli),
|
|
|
|
changePub: eventbus.Publish[Change](ec),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
t.timer = t.clock().AfterFunc(time.Minute, t.timerSelfCheck)
|
|
|
|
t.timer = t.clock().AfterFunc(time.Minute, t.timerSelfCheck)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ec.Monitor(t.awaitEventClientDone)
|
|
|
|
|
|
|
|
|
|
|
|
return t
|
|
|
|
return t
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (t *Tracker) awaitEventClientDone(ec *eventbus.Client) {
|
|
|
|
|
|
|
|
<-ec.Done()
|
|
|
|
|
|
|
|
t.mu.Lock()
|
|
|
|
|
|
|
|
defer t.mu.Unlock()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for _, timer := range t.pendingVisibleTimers {
|
|
|
|
|
|
|
|
timer.Stop()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
t.timer.Stop()
|
|
|
|
|
|
|
|
clear(t.pendingVisibleTimers)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (t *Tracker) now() time.Time {
|
|
|
|
func (t *Tracker) now() time.Time {
|
|
|
|
if t.testClock != nil {
|
|
|
|
if t.testClock != nil {
|
|
|
|
return t.testClock.Now()
|
|
|
|
return t.testClock.Now()
|
|
|
|
|