feat(log): wire log db, metrics, and body toggle

This commit is contained in:
zenfun
2025-12-21 16:18:22 +08:00
parent 4c1e03f83d
commit c2c65e774b
9 changed files with 305 additions and 40 deletions

View File

@@ -44,6 +44,7 @@ type LogConfig struct {
QueueCapacity int
RetentionDays int
MaxRecords int
DSN string
}
type ModelRegistryConfig struct {
@@ -77,6 +78,7 @@ func Load() (*Config, error) {
v.SetDefault("log.queue_capacity", 10000)
v.SetDefault("log.retention_days", 30)
v.SetDefault("log.max_records", 1000000)
v.SetDefault("log.dsn", "")
v.SetDefault("auth.jwt_secret", "change_me_in_production")
v.SetDefault("model_registry.enabled", false)
v.SetDefault("model_registry.refresh_seconds", 1800)
@@ -101,6 +103,7 @@ func Load() (*Config, error) {
_ = v.BindEnv("log.queue_capacity", "EZ_LOG_QUEUE")
_ = v.BindEnv("log.retention_days", "EZ_LOG_RETENTION_DAYS")
_ = v.BindEnv("log.max_records", "EZ_LOG_MAX_RECORDS")
_ = v.BindEnv("log.dsn", "EZ_LOG_PG_DSN")
_ = v.BindEnv("auth.jwt_secret", "EZ_JWT_SECRET")
_ = v.BindEnv("model_registry.enabled", "EZ_MODEL_REGISTRY_ENABLED")
_ = v.BindEnv("model_registry.refresh_seconds", "EZ_MODEL_REGISTRY_REFRESH_SECONDS")
@@ -145,6 +148,7 @@ func Load() (*Config, error) {
QueueCapacity: v.GetInt("log.queue_capacity"),
RetentionDays: v.GetInt("log.retention_days"),
MaxRecords: v.GetInt("log.max_records"),
DSN: strings.TrimSpace(v.GetString("log.dsn")),
},
Auth: AuthConfig{
JWTSecret: v.GetString("auth.jwt_secret"),