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

@ -18,6 +18,7 @@ const apiURL = "https://snapshot.debian.org/mr"
var (
limiterTimeout time.Duration = time.Second / 20
limiterBurst int = 3
limiterUpdateDelay time.Duration = time.Second * 10
Limiter = rate.NewLimiter(rate.Every(limiterTimeout), limiterBurst)
)
@ -25,7 +26,10 @@ var (
func lowerLimit() {
limiterTimeout = limiterTimeout * 2
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