1
0

fix: wait 10 seconds before query with new limit

This commit is contained in:
dump_stack() 2023-05-17 06:05:37 +00:00
parent d70be6a306
commit f7b9f538b4
Signed by: dump_stack
GPG Key ID: BE44DA8C062D87DC

View File

@ -16,8 +16,9 @@ import (
const apiURL = "https://snapshot.debian.org/mr" const apiURL = "https://snapshot.debian.org/mr"
var ( var (
limiterTimeout time.Duration = time.Second / 20 limiterTimeout time.Duration = time.Second / 20
limiterBurst int = 3 limiterBurst int = 3
limiterUpdateDelay time.Duration = time.Second * 10
Limiter = rate.NewLimiter(rate.Every(limiterTimeout), limiterBurst) Limiter = rate.NewLimiter(rate.Every(limiterTimeout), limiterBurst)
) )
@ -25,7 +26,10 @@ var (
func lowerLimit() { func lowerLimit() {
limiterTimeout = limiterTimeout * 2 limiterTimeout = limiterTimeout * 2
log.Info().Msgf("limiter timeout set to %v", limiterTimeout) log.Info().Msgf("limiter timeout set to %v", limiterTimeout)
Limiter.SetLimit(rate.Every(limiterTimeout)) Limiter.SetLimitAt(
time.Now().Add(limiterUpdateDelay),
rate.Every(limiterTimeout),
)
} }
// Retries in case of 5xx errors // Retries in case of 5xx errors