mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-13 17:47:51 +00:00
feat(stats): add usage stats and quota reset
This commit is contained in:
@@ -16,6 +16,7 @@ type Config struct {
|
||||
Log LogConfig
|
||||
Auth AuthConfig
|
||||
ModelRegistry ModelRegistryConfig
|
||||
Quota QuotaConfig
|
||||
}
|
||||
|
||||
type ServerConfig struct {
|
||||
@@ -52,6 +53,10 @@ type ModelRegistryConfig struct {
|
||||
TimeoutSeconds int
|
||||
}
|
||||
|
||||
type QuotaConfig struct {
|
||||
ResetIntervalSeconds int
|
||||
}
|
||||
|
||||
func Load() (*Config, error) {
|
||||
v := viper.New()
|
||||
|
||||
@@ -71,6 +76,7 @@ func Load() (*Config, error) {
|
||||
v.SetDefault("model_registry.models_dev_ref", "dev")
|
||||
v.SetDefault("model_registry.cache_dir", "./data/model-registry")
|
||||
v.SetDefault("model_registry.timeout_seconds", 30)
|
||||
v.SetDefault("quota.reset_interval_seconds", 300)
|
||||
|
||||
v.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
|
||||
v.AutomaticEnv()
|
||||
@@ -91,6 +97,7 @@ func Load() (*Config, error) {
|
||||
_ = v.BindEnv("model_registry.models_dev_ref", "EZ_MODEL_REGISTRY_MODELS_DEV_REF")
|
||||
_ = 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")
|
||||
|
||||
if configFile := os.Getenv("EZ_CONFIG_FILE"); configFile != "" {
|
||||
v.SetConfigFile(configFile)
|
||||
@@ -136,6 +143,9 @@ func Load() (*Config, error) {
|
||||
CacheDir: v.GetString("model_registry.cache_dir"),
|
||||
TimeoutSeconds: v.GetInt("model_registry.timeout_seconds"),
|
||||
},
|
||||
Quota: QuotaConfig{
|
||||
ResetIntervalSeconds: v.GetInt("quota.reset_interval_seconds"),
|
||||
},
|
||||
}
|
||||
|
||||
return cfg, nil
|
||||
|
||||
Reference in New Issue
Block a user