253
254
// updateRatelimitLocked checks and updates the overall queue rate limit if changed.
256
>
newRPS := r.effectiveRPS
257
>
// If the effective RPS is zero, we set the burst to zero as well.
258
>
// This prevents any initial tasks from executing immediately.
259
>
// Allows pausing of the task queue by setting the RPS to zero.
260
>
var burst int
261
>
if newRPS != 0 {
262
>
// If the effective RPS is non-zero, we can set a burst based on the effective RPS.
263
>
burst = max(int(math.Ceil(newRPS)), r.config.MinTaskThrottlingBurstSize())
264
>
}
265
>
r.dynamicRateBurst.SetRPS(newRPS)
266
>
r.dynamicRateBurst.SetBurst(burst)
267
>
// updateRatelimitLocked is invoked whenever the effective RPS value changes.
268
>
// At this point, the dynamicRateLimiter is always updated with the latest rate and burst values,
269
>
// ensuring that the new rate limit takes effect immediately.
270
>
r.dynamicRateLimiter.Refresh()
271
}
272