diff --git a/clientapi/routing/rate_limiting.go b/clientapi/routing/rate_limiting.go index 0045c1595..16e3c0565 100644 --- a/clientapi/routing/rate_limiting.go +++ b/clientapi/routing/rate_limiting.go @@ -23,7 +23,7 @@ func newRateLimits(cfg *config.RateLimiting) *rateLimits { limits: make(map[string]chan struct{}), enabled: cfg.Enabled, requestThreshold: cfg.Threshold, - cooloffDuration: time.Duration(cfg.Cooloff) * time.Millisecond, + cooloffDuration: time.Duration(cfg.CooloffMS) * time.Millisecond, } if l.enabled { go l.clean() @@ -33,11 +33,11 @@ func newRateLimits(cfg *config.RateLimiting) *rateLimits { func (l *rateLimits) clean() { for { - // On a ten minute interval, we'll take an exclusive write + // On a 30 second interval, we'll take an exclusive write // lock of the entire map and see if any of the channels are // empty. If they are then we will close and delete them, // freeing up memory. - time.Sleep(time.Second * 10) + time.Sleep(time.Second * 30) l.limitsMutex.Lock() for k, c := range l.limits { if len(c) == 0 { diff --git a/internal/config/config_clientapi.go b/internal/config/config_clientapi.go index 3e21cd31f..521154911 100644 --- a/internal/config/config_clientapi.go +++ b/internal/config/config_clientapi.go @@ -106,18 +106,18 @@ type RateLimiting struct { // The cooloff period in milliseconds after a request before the "slot" // is freed again - Cooloff int64 `yaml:"cooloff_ms"` + CooloffMS int64 `yaml:"cooloff_ms"` } func (r *RateLimiting) Verify(configErrs *ConfigErrors) { if r.Enabled { checkPositive(configErrs, "client_api.rate_limiting.threshold", r.Threshold) - checkPositive(configErrs, "client_api.rate_limiting.cooloff_ms", r.Cooloff) + checkPositive(configErrs, "client_api.rate_limiting.cooloff_ms", r.CooloffMS) } } func (r *RateLimiting) Defaults() { r.Enabled = true r.Threshold = 5 - r.Cooloff = 500 + r.CooloffMS = 500 }