1
0

feat: add max timeout for mr/metasnap api

This commit is contained in:
dump_stack() 2023-05-28 12:16:05 +00:00
parent 88bfa867fd
commit 9df0880e3e
Signed by: dump_stack
GPG Key ID: BE44DA8C062D87DC
2 changed files with 8 additions and 0 deletions

View File

@ -20,6 +20,7 @@ const apiURL = "http://metasnap.debian.net/cgi-bin/api?"
var (
limiterTimeout time.Duration = time.Second / 20
limiterMaxTimeout time.Duration = time.Second * 3
limiterBurst int = 3
limiterUpdateDelay time.Duration = time.Second * 10
@ -28,6 +29,9 @@ var (
func lowerLimit() {
limiterTimeout = limiterTimeout * 2
if limiterTimeout > limiterMaxTimeout {
limiterTimeout = limiterMaxTimeout
}
log.Info().Msgf("limiter timeout set to %v", limiterTimeout)
Limiter.SetLimitAt(
time.Now().Add(limiterUpdateDelay),

View File

@ -17,6 +17,7 @@ const apiURL = "https://snapshot.debian.org/mr"
var (
limiterTimeout time.Duration = time.Second / 20
limiterMaxTimeout time.Duration = time.Second * 3
limiterBurst int = 3
limiterUpdateDelay time.Duration = time.Second * 10
@ -25,6 +26,9 @@ var (
func lowerLimit() {
limiterTimeout = limiterTimeout * 2
if limiterTimeout > limiterMaxTimeout {
limiterTimeout = limiterMaxTimeout
}
log.Info().Msgf("limiter timeout set to %v", limiterTimeout)
Limiter.SetLimitAt(
time.Now().Add(limiterUpdateDelay),