Atlas › Test

TestTimerSetCurrentTime_NoUpdate

Exact test identity: go.temporal.io/server/common/timer/TestRemoteTimerGateSuite/TestTimerSetCurrentTime_NoUpdate

Package
go.temporal.io/server/common/timer
Suite / test hierarchy
TestRemoteTimerGateSuite/TestTimerSetCurrentTime_NoUpdate
Test
TestTimerSetCurrentTime_NoUpdate
Introduced at
remote_gate.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/timer/remote_gate.go 25 covered LOC · 6 ranges

Open complete file

29
30 // NewRemoteGate create a new timer gate instance
31 > func NewRemoteGate() RemoteGate { remote_gate.go
32 > rg := &RemoteGateImpl{
33 > currentTime: time.Time{},
34 > nextWakeupTime: time.Time{},
35 > fireCh: make(chan struct{}, 1),
36 > }
37 > return rg
38 > }
39
40 // FireCh return the channel which will be fired when time is up
41 > func (rg *RemoteGateImpl) FireCh() <-chan struct{} { remote_gate.go
42 > return rg.fireCh
43 > }
44
45 // FireAfter check will the timer get fired after a certain time
97 // if new "current" time is after the next wake-up time, return true if
98 // "current" is actually updated
99 > func (rg *RemoteGateImpl) SetCurrentTime(currentTime time.Time) bool { remote_gate.go
100 > rg.Lock()
101 > defer rg.Unlock()
102 >
103 > if !rg.currentTime.Before(currentTime) {
104 > // new current time is <= current time remote_gate.go
105 > return false
106 > }
107
108 // NOTE: do not update the current time now
109 > if !rg.currentTime.Before(rg.nextWakeupTime) { remote_gate.go
110 > // current time already >= next wakeup time remote_gate.go
111 > // avoid duplicate fire
112 > rg.currentTime = currentTime
113 > return true
114 > }
115
116 rg.currentTime = currentTime