From 90a14abb0c693287d10c5b2b8a6e5515f3ed4c37 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Wed, 4 Jan 2023 11:57:59 +0100 Subject: [feature] HTTP request throttling middleware (#1297) * [feature] Add throttling middleware to AP endpoints * refactor a lil bit * use config setting, start updating docs * doc updates * use relative links in faq doc * small docs fixes * return code 503 instead of 429 when throttled * throttle other endpoints too * simplify token channel prefills --- internal/config/helpers.gen.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'internal/config/helpers.gen.go') diff --git a/internal/config/helpers.gen.go b/internal/config/helpers.gen.go index 62894b4d5..de5b93762 100644 --- a/internal/config/helpers.gen.go +++ b/internal/config/helpers.gen.go @@ -1824,6 +1824,31 @@ func GetAdvancedRateLimitRequests() int { return global.GetAdvancedRateLimitRequ // SetAdvancedRateLimitRequests safely sets the value for global configuration 'AdvancedRateLimitRequests' field func SetAdvancedRateLimitRequests(v int) { global.SetAdvancedRateLimitRequests(v) } +// GetAdvancedThrottlingMultiplier safely fetches the Configuration value for state's 'AdvancedThrottlingMultiplier' field +func (st *ConfigState) GetAdvancedThrottlingMultiplier() (v int) { + st.mutex.Lock() + v = st.config.AdvancedThrottlingMultiplier + st.mutex.Unlock() + return +} + +// SetAdvancedThrottlingMultiplier safely sets the Configuration value for state's 'AdvancedThrottlingMultiplier' field +func (st *ConfigState) SetAdvancedThrottlingMultiplier(v int) { + st.mutex.Lock() + defer st.mutex.Unlock() + st.config.AdvancedThrottlingMultiplier = v + st.reloadToViper() +} + +// AdvancedThrottlingMultiplierFlag returns the flag name for the 'AdvancedThrottlingMultiplier' field +func AdvancedThrottlingMultiplierFlag() string { return "advanced-throttling-multiplier" } + +// GetAdvancedThrottlingMultiplier safely fetches the value for global configuration 'AdvancedThrottlingMultiplier' field +func GetAdvancedThrottlingMultiplier() int { return global.GetAdvancedThrottlingMultiplier() } + +// SetAdvancedThrottlingMultiplier safely sets the value for global configuration 'AdvancedThrottlingMultiplier' field +func SetAdvancedThrottlingMultiplier(v int) { global.SetAdvancedThrottlingMultiplier(v) } + // GetCacheGTSAccountMaxSize safely fetches the Configuration value for state's 'Cache.GTS.AccountMaxSize' field func (st *ConfigState) GetCacheGTSAccountMaxSize() (v int) { st.mutex.Lock() -- cgit v1.2.3