fix: wait 10 seconds before query with new limit
This commit is contained in:
parent
d70be6a306
commit
f7b9f538b4
@ -18,6 +18,7 @@ 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
|
||||||
|
Loading…
Reference in New Issue
Block a user