You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am new to Go. And would like to raise this issue for the question about:
In Take() method in limiter_atomic.go, sleepFor attr represents how much time we should sleep:
So for example we set atelimit.New(1), and last Take() triggered 20 seconds ago. Now newState.sleepFor is calculated as -19.
This attr is used later in t.clock.Sleep(newState.sleepFor). Other than that, it's useless ( Not sure if I am correct). So why sleepFor should >= maxSlack ? I think Sleep(-19) is the same as Sleep(-10) ?
Thank you for your reply in advance :)
The text was updated successfully, but these errors were encountered:
The key is that sleepFor can be used not in just this iteration, but in the following ones - we keep it for future iterations, to keep track how many "slack" requests we have available.
Technically, you're right - if sleepFor is negative, we indeed don't sleep at all - so from that perspective it's the same to have Sleep(-19) and Sleep(-10).
Hi maintainers.
I am new to Go. And would like to raise this issue for the question about:
In
Take()
method inlimiter_atomic.go
,sleepFor
attr represents how much time we should sleep:So for example we set
atelimit.New(1)
, and lastTake()
triggered 20 seconds ago. NownewState.sleepFor
is calculated as-19
.This attr is used later in
t.clock.Sleep(newState.sleepFor)
. Other than that, it's useless ( Not sure if I am correct). So whysleepFor
should >=maxSlack
? I thinkSleep(-19)
is the same asSleep(-10)
?Thank you for your reply in advance :)
The text was updated successfully, but these errors were encountered: