Atlas › Test
TestEventTimeSource_Since
Exact test identity: go.temporal.io/server/common/clock/TestEventTimeSource_Since
- Package
go.temporal.io/server/common/clock
- Suite / test hierarchy
TestEventTimeSource_Since
- Test
TestEventTimeSource_Since
- Introduced at
- event_time_source.go ×1 Frontier kind: Joint frontier
- Covered ranges
- 6
- Covered lines
- 25
- Covered files
- 1
Covered source
Expand a file to inspect source; the > gutter marks covered lines.
go.temporal.io/server/common/clock/event_time_source.go 25 covered LOC · 6 ranges
Open complete file
39
40
// NewEventTimeSource returns a EventTimeSource with the current time set to Unix zero: 1970-01-01 00:00:00 +0000 UTC.
42
>
return &EventTimeSource{
43
>
now: time.Unix(0, 0),
44
>
}
45
>
}
46
47
// Some clients depend on the fact that the runtime's timers do _not_ run synchronously.
55
56
// Now return the current time.
58
>
ts.mu.RLock()
59
>
defer ts.mu.RUnlock()
60
>
61
>
return ts.now
62
>
}
63
65
>
return ts.Now().Sub(t)
66
>
}
67
68
// AfterFunc return a timer that will fire after the specified duration. It is important to note that the timeSource is
116
117
// Advance the timer by the specified duration.
119
>
ts.mu.Lock()
120
>
defer ts.mu.Unlock()
121
>
122
>
ts.now = ts.now.Add(d)
123
>
ts.fireTimers()
124
>
}
125
126
// AdvanceNext advances to the next timer.
156
157
// fireTimers fires all timers that are ready.
159
>
n := 0
160
>
for _, t := range ts.timers {
161
if t.deadline.After(ts.now) {
162
ts.timers[n] = t