feat: add max timeout for mr/metasnap api
This commit is contained in:
parent
88bfa867fd
commit
9df0880e3e
@ -20,6 +20,7 @@ const apiURL = "http://metasnap.debian.net/cgi-bin/api?"
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
limiterTimeout time.Duration = time.Second / 20
|
limiterTimeout time.Duration = time.Second / 20
|
||||||
|
limiterMaxTimeout time.Duration = time.Second * 3
|
||||||
limiterBurst int = 3
|
limiterBurst int = 3
|
||||||
limiterUpdateDelay time.Duration = time.Second * 10
|
limiterUpdateDelay time.Duration = time.Second * 10
|
||||||
|
|
||||||
@ -28,6 +29,9 @@ var (
|
|||||||
|
|
||||||
func lowerLimit() {
|
func lowerLimit() {
|
||||||
limiterTimeout = limiterTimeout * 2
|
limiterTimeout = limiterTimeout * 2
|
||||||
|
if limiterTimeout > limiterMaxTimeout {
|
||||||
|
limiterTimeout = limiterMaxTimeout
|
||||||
|
}
|
||||||
log.Info().Msgf("limiter timeout set to %v", limiterTimeout)
|
log.Info().Msgf("limiter timeout set to %v", limiterTimeout)
|
||||||
Limiter.SetLimitAt(
|
Limiter.SetLimitAt(
|
||||||
time.Now().Add(limiterUpdateDelay),
|
time.Now().Add(limiterUpdateDelay),
|
||||||
|
@ -17,6 +17,7 @@ const apiURL = "https://snapshot.debian.org/mr"
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
limiterTimeout time.Duration = time.Second / 20
|
limiterTimeout time.Duration = time.Second / 20
|
||||||
|
limiterMaxTimeout time.Duration = time.Second * 3
|
||||||
limiterBurst int = 3
|
limiterBurst int = 3
|
||||||
limiterUpdateDelay time.Duration = time.Second * 10
|
limiterUpdateDelay time.Duration = time.Second * 10
|
||||||
|
|
||||||
@ -25,6 +26,9 @@ var (
|
|||||||
|
|
||||||
func lowerLimit() {
|
func lowerLimit() {
|
||||||
limiterTimeout = limiterTimeout * 2
|
limiterTimeout = limiterTimeout * 2
|
||||||
|
if limiterTimeout > limiterMaxTimeout {
|
||||||
|
limiterTimeout = limiterMaxTimeout
|
||||||
|
}
|
||||||
log.Info().Msgf("limiter timeout set to %v", limiterTimeout)
|
log.Info().Msgf("limiter timeout set to %v", limiterTimeout)
|
||||||
Limiter.SetLimitAt(
|
Limiter.SetLimitAt(
|
||||||
time.Now().Add(limiterUpdateDelay),
|
time.Now().Add(limiterUpdateDelay),
|
||||||
|
Loading…
Reference in New Issue
Block a user