Revert "Update go mod dependencies."

This reverts commit dedbdf63c3.
This commit is contained in:
2024-10-09 09:11:07 +01:00
parent dedbdf63c3
commit 9dabd0e5cf
11 changed files with 86 additions and 45 deletions
+14 -3
View File
@@ -99,9 +99,8 @@ func (lim *Limiter) Tokens() float64 {
// bursts of at most b tokens.
func NewLimiter(r Limit, b int) *Limiter {
return &Limiter{
limit: r,
burst: b,
tokens: float64(b),
limit: r,
burst: b,
}
}
@@ -345,6 +344,18 @@ func (lim *Limiter) reserveN(t time.Time, n int, maxFutureReserve time.Duration)
tokens: n,
timeToAct: t,
}
} else if lim.limit == 0 {
var ok bool
if lim.burst >= n {
ok = true
lim.burst -= n
}
return Reservation{
ok: ok,
lim: lim,
tokens: lim.burst,
timeToAct: t,
}
}
t, tokens := lim.advance(t)