mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-13 17:47:51 +00:00
feat(cron): add automatic log cleanup with retention policy
Implement LogCleaner cron job to automatically clean up old log records based on configurable retention period and maximum record count. - Add LogCleaner with retention_days and max_records configuration - Add EZ_LOG_RETENTION_DAYS and EZ_LOG_MAX_RECORDS environment variables - Default to 30 days retention and 1,000,000 max records - Include unit tests for log cleaner functionality
This commit is contained in:
@@ -42,6 +42,8 @@ type LogConfig struct {
|
||||
BatchSize int
|
||||
FlushInterval time.Duration
|
||||
QueueCapacity int
|
||||
RetentionDays int
|
||||
MaxRecords int
|
||||
}
|
||||
|
||||
type ModelRegistryConfig struct {
|
||||
@@ -73,6 +75,8 @@ func Load() (*Config, error) {
|
||||
v.SetDefault("log.batch_size", 10)
|
||||
v.SetDefault("log.flush_ms", 1000)
|
||||
v.SetDefault("log.queue_capacity", 10000)
|
||||
v.SetDefault("log.retention_days", 30)
|
||||
v.SetDefault("log.max_records", 1000000)
|
||||
v.SetDefault("auth.jwt_secret", "change_me_in_production")
|
||||
v.SetDefault("model_registry.enabled", false)
|
||||
v.SetDefault("model_registry.refresh_seconds", 1800)
|
||||
@@ -95,6 +99,8 @@ func Load() (*Config, error) {
|
||||
_ = v.BindEnv("log.batch_size", "EZ_LOG_BATCH_SIZE")
|
||||
_ = v.BindEnv("log.flush_ms", "EZ_LOG_FLUSH_MS")
|
||||
_ = 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("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")
|
||||
@@ -137,6 +143,8 @@ func Load() (*Config, error) {
|
||||
BatchSize: v.GetInt("log.batch_size"),
|
||||
FlushInterval: time.Duration(v.GetInt("log.flush_ms")) * time.Millisecond,
|
||||
QueueCapacity: v.GetInt("log.queue_capacity"),
|
||||
RetentionDays: v.GetInt("log.retention_days"),
|
||||
MaxRecords: v.GetInt("log.max_records"),
|
||||
},
|
||||
Auth: AuthConfig{
|
||||
JWTSecret: v.GetString("auth.jwt_secret"),
|
||||
|
||||
Reference in New Issue
Block a user