MCPcopy Index your code
hub / github.com/ZenNotes/zennotes / backoffDelay

Function backoffDelay

apps/server/internal/httpserver/security.go:188–201  ·  view source on GitHub ↗

backoffDelay returns the minimum time the caller must wait before the (consecutiveFailures+1)-th attempt is allowed: 0, 1, 2, 4, 8, 16, 32, then capped at 60s.

(consecutiveFailures int)

Source from the content-addressed store, hash-verified

186// (consecutiveFailures+1)-th attempt is allowed: 0, 1, 2, 4, 8, 16, 32,
187// then capped at 60s.
188func backoffDelay(consecutiveFailures int) time.Duration {
189 if consecutiveFailures < 1 {
190 return 0
191 }
192 n := consecutiveFailures - 1
193 if n > 6 {
194 n = 6
195 }
196 d := time.Duration(1<<n) * time.Second
197 if d > 60*time.Second {
198 d = 60 * time.Second
199 }
200 return d
201}
202
203func (l *attemptLimiter) reset(key string) {
204 l.mu.Lock()

Callers 2

TestBackoffDelayFunction · 0.85
allowMethod · 0.85

Calls

no outgoing calls

Tested by 1

TestBackoffDelayFunction · 0.68