Explorar o código

Move configuration

Niko Kovacevic %!s(int64=5) %!d(string=hai) anos
pai
achega
8539cd39df
Modificáronse 1 ficheiros con 11 adicións e 0 borrados
  1. 11 0
      pkg/env/costmodelenv.go

+ 11 - 0
pkg/env/costmodelenv.go

@@ -63,6 +63,7 @@ const (
 
 
 	CacheWarmingEnabledEnvVar    = "CACHE_WARMING_ENABLED"
 	CacheWarmingEnabledEnvVar    = "CACHE_WARMING_ENABLED"
 	ETLEnabledEnvVar             = "ETL_ENABLED"
 	ETLEnabledEnvVar             = "ETL_ENABLED"
+	ETLMaxBatchHours             = "ETL_MAX_BATCH_HOURS"
 	LegacyExternalAPIDisabledVar = "LEGACY_EXTERNAL_API_DISABLED"
 	LegacyExternalAPIDisabledVar = "LEGACY_EXTERNAL_API_DISABLED"
 )
 )
 
 
@@ -338,6 +339,16 @@ func IsETLEnabled() bool {
 	return GetBool(ETLEnabledEnvVar, true)
 	return GetBool(ETLEnabledEnvVar, true)
 }
 }
 
 
+// GetETLMaxBatchDuration limits the window duration of the most expensive ETL
+// queries to a maximum batch size, such that queries can be tuned to avoid
+// timeout for large windows; e.g. if a 24h query is expected to timeout, but
+// a 6h query is expected to complete in 1m, then 6h could be a good value.
+func GetETLMaxBatchDuration() time.Duration {
+	// Default to 6h
+	hrs := time.Duration(env.GetInt64(ETLMaxBatchHours, 6))
+	return hrs * time.Hour
+}
+
 func LegacyExternalCostsAPIDisabled() bool {
 func LegacyExternalCostsAPIDisabled() bool {
 	return GetBool(LegacyExternalAPIDisabledVar, false)
 	return GetBool(LegacyExternalAPIDisabledVar, false)
 }
 }