mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-13 17:47:51 +00:00
feat: add internal stats flush API
This commit is contained in:
@@ -17,6 +17,7 @@ type Config struct {
|
||||
Auth AuthConfig
|
||||
ModelRegistry ModelRegistryConfig
|
||||
Quota QuotaConfig
|
||||
Internal InternalConfig
|
||||
}
|
||||
|
||||
type ServerConfig struct {
|
||||
@@ -57,6 +58,10 @@ type QuotaConfig struct {
|
||||
ResetIntervalSeconds int
|
||||
}
|
||||
|
||||
type InternalConfig struct {
|
||||
StatsToken string
|
||||
}
|
||||
|
||||
func Load() (*Config, error) {
|
||||
v := viper.New()
|
||||
|
||||
@@ -77,6 +82,7 @@ func Load() (*Config, error) {
|
||||
v.SetDefault("model_registry.cache_dir", "./data/model-registry")
|
||||
v.SetDefault("model_registry.timeout_seconds", 30)
|
||||
v.SetDefault("quota.reset_interval_seconds", 300)
|
||||
v.SetDefault("internal.stats_token", "")
|
||||
|
||||
v.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
|
||||
v.AutomaticEnv()
|
||||
@@ -98,6 +104,7 @@ func Load() (*Config, error) {
|
||||
_ = v.BindEnv("model_registry.cache_dir", "EZ_MODEL_REGISTRY_CACHE_DIR")
|
||||
_ = v.BindEnv("model_registry.timeout_seconds", "EZ_MODEL_REGISTRY_TIMEOUT_SECONDS")
|
||||
_ = v.BindEnv("quota.reset_interval_seconds", "EZ_QUOTA_RESET_INTERVAL_SECONDS")
|
||||
_ = v.BindEnv("internal.stats_token", "EZ_INTERNAL_STATS_TOKEN")
|
||||
|
||||
if configFile := os.Getenv("EZ_CONFIG_FILE"); configFile != "" {
|
||||
v.SetConfigFile(configFile)
|
||||
@@ -146,6 +153,9 @@ func Load() (*Config, error) {
|
||||
Quota: QuotaConfig{
|
||||
ResetIntervalSeconds: v.GetInt("quota.reset_interval_seconds"),
|
||||
},
|
||||
Internal: InternalConfig{
|
||||
StatsToken: v.GetString("internal.stats_token"),
|
||||
},
|
||||
}
|
||||
|
||||
return cfg, nil
|
||||
|
||||
Reference in New Issue
Block a user