mirror of
https://github.com/gabehf/Koito.git
synced 2026-03-07 21:48:18 -08:00
feat: throttle variable for imports
This commit is contained in:
parent
20cc4ce27a
commit
f7621d0383
3 changed files with 24 additions and 0 deletions
|
|
@ -36,6 +36,7 @@ const (
|
|||
SKIP_IMPORT_ENV = "KOITO_SKIP_IMPORT"
|
||||
ALLOWED_HOSTS_ENV = "KOITO_ALLOWED_HOSTS"
|
||||
DISABLE_RATE_LIMIT_ENV = "KOITO_DISABLE_RATE_LIMIT"
|
||||
THROTTLE_IMPORTS_MS = "KOITO_THROTTLE_IMPORTS_MS"
|
||||
)
|
||||
|
||||
type config struct {
|
||||
|
|
@ -60,6 +61,7 @@ type config struct {
|
|||
allowedHosts []string
|
||||
allowAllHosts bool
|
||||
disableRateLimit bool
|
||||
importThrottleMs int
|
||||
}
|
||||
|
||||
var (
|
||||
|
|
@ -104,6 +106,8 @@ func loadConfig(getenv func(string) string) (*config, error) {
|
|||
cfg.lbzRelayUrl = getenv(LBZ_RELAY_URL_ENV)
|
||||
}
|
||||
|
||||
cfg.importThrottleMs, _ = strconv.Atoi(getenv(THROTTLE_IMPORTS_MS))
|
||||
|
||||
cfg.disableRateLimit = parseBool(getenv(DISABLE_RATE_LIMIT_ENV))
|
||||
|
||||
cfg.structuredLogging = parseBool(getenv(ENABLE_STRUCTURED_LOGGING_ENV))
|
||||
|
|
@ -278,3 +282,9 @@ func RateLimitDisabled() bool {
|
|||
defer lock.RUnlock()
|
||||
return globalConfig.disableRateLimit
|
||||
}
|
||||
|
||||
func ThrottleImportMs() int {
|
||||
lock.RLock()
|
||||
defer lock.RUnlock()
|
||||
return globalConfig.importThrottleMs
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue