Atlas › Test
TestClockedRateLimiter_Allow_RPS_TooHigh
Exact test identity: go.temporal.io/server/common/quotas/TestClockedRateLimiter_Allow_RPS_TooHigh
- Package
go.temporal.io/server/common/quotas
- Suite / test hierarchy
TestClockedRateLimiter_Allow_RPS_TooHigh
- Test
TestClockedRateLimiter_Allow_RPS_TooHigh
- Introduced at
- TestClockedRateLimiter_Allow_RPS_Ok, TestClockedRateLimiter_Allow_RPS_TooHigh Frontier kind: Test frontier
- Covered ranges
- 8
- Covered lines
- 35
- Covered files
- 2
Co-introduced tests
1 other test enter at the same concept.
Covered source
Expand a file to inspect source; the > gutter marks covered lines.
go.temporal.io/server/common/clock/event_time_source.go 22 covered LOC · 5 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
64
func (ts *EventTimeSource) Since(t time.Time) time.Duration {
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
go.temporal.io/server/common/quotas/clocked_rate_limiter.go 13 covered LOC · 3 ranges
Open complete file
25
)
26
27
>
func NewClockedRateLimiter(rateLimiter *rate.Limiter, timeSource clock.TimeSource) ClockedRateLimiter {
clocked_rate_limiter.go
28
>
return ClockedRateLimiter{
29
>
rateLimiter: rateLimiter,
30
>
timeSource: timeSource,
31
>
recycleCh: make(chan struct{}),
32
>
}
33
>
}
34
36
>
return l.AllowN(l.timeSource.Now(), 1)
37
>
}
38
40
>
return l.rateLimiter.AllowN(now, token)
41
>
}
42
43
// ClockedReservation wraps a rate.Reservation with a clockwork.Clock. It is used to ensure that the reservation