package config import "time" // LogConfig 日志配置 type LogConfig struct { Level string `mapstructure:"level"` Format string `mapstructure:"format"` ServiceName string `mapstructure:"service_name"` Environment string `mapstructure:"env"` Caller bool `mapstructure:"caller"` StacktraceLevel string `mapstructure:"stacktrace_level"` Output LogOutputConfig `mapstructure:"output"` Rotation LogRotationConfig `mapstructure:"rotation"` Sampling LogSamplingConfig `mapstructure:"sampling"` } type LogOutputConfig struct { ToStdout bool `mapstructure:"to_stdout"` ToFile bool `mapstructure:"to_file"` FilePath string `mapstructure:"file_path"` } type LogRotationConfig struct { MaxSizeMB int `mapstructure:"max_size_mb"` MaxBackups int `mapstructure:"max_backups"` MaxAgeDays int `mapstructure:"max_age_days"` Compress bool `mapstructure:"compress"` LocalTime bool `mapstructure:"local_time"` } type LogSamplingConfig struct { Enabled bool `mapstructure:"enabled"` Initial int `mapstructure:"initial"` Thereafter int `mapstructure:"thereafter"` } // OpsConfig 运维监控配置 type OpsConfig struct { Enabled bool `mapstructure:"enabled"` UsePreaggregatedTables bool `mapstructure:"use_preaggregated_tables"` Cleanup OpsCleanupConfig `mapstructure:"cleanup"` MetricsCollectorCache OpsMetricsCollectorCacheConfig `mapstructure:"metrics_collector_cache"` Aggregation OpsAggregationConfig `mapstructure:"aggregation"` } type OpsCleanupConfig struct { Enabled bool `mapstructure:"enabled"` Schedule string `mapstructure:"schedule"` ErrorLogRetentionDays int `mapstructure:"error_log_retention_days"` MinuteMetricsRetentionDays int `mapstructure:"minute_metrics_retention_days"` HourlyMetricsRetentionDays int `mapstructure:"hourly_metrics_retention_days"` } type OpsAggregationConfig struct { Enabled bool `mapstructure:"enabled"` } type OpsMetricsCollectorCacheConfig struct { Enabled bool `mapstructure:"enabled"` TTL time.Duration `mapstructure:"ttl"` } // APIKeyAuthCacheConfig API Key 认证缓存配置 type APIKeyAuthCacheConfig struct { L1Size int `mapstructure:"l1_size"` L1TTLSeconds int `mapstructure:"l1_ttl_seconds"` L2TTLSeconds int `mapstructure:"l2_ttl_seconds"` NegativeTTLSeconds int `mapstructure:"negative_ttl_seconds"` JitterPercent int `mapstructure:"jitter_percent"` Singleflight bool `mapstructure:"singleflight"` } // SubscriptionCacheConfig 订阅认证 L1 缓存配置 type SubscriptionCacheConfig struct { L1Size int `mapstructure:"l1_size"` L1TTLSeconds int `mapstructure:"l1_ttl_seconds"` JitterPercent int `mapstructure:"jitter_percent"` } // SubscriptionMaintenanceConfig 订阅窗口维护后台任务配置 type SubscriptionMaintenanceConfig struct { WorkerCount int `mapstructure:"worker_count"` QueueSize int `mapstructure:"queue_size"` } // DashboardCacheConfig 仪表盘统计缓存配置 type DashboardCacheConfig struct { Enabled bool `mapstructure:"enabled"` KeyPrefix string `mapstructure:"key_prefix"` StatsFreshTTLSeconds int `mapstructure:"stats_fresh_ttl_seconds"` StatsTTLSeconds int `mapstructure:"stats_ttl_seconds"` StatsRefreshTimeoutSeconds int `mapstructure:"stats_refresh_timeout_seconds"` } // DashboardAggregationConfig 仪表盘预聚合配置 type DashboardAggregationConfig struct { Enabled bool `mapstructure:"enabled"` IntervalSeconds int `mapstructure:"interval_seconds"` LookbackSeconds int `mapstructure:"lookback_seconds"` BackfillEnabled bool `mapstructure:"backfill_enabled"` BackfillMaxDays int `mapstructure:"backfill_max_days"` Retention DashboardAggregationRetentionConfig `mapstructure:"retention"` RecomputeDays int `mapstructure:"recompute_days"` } // DashboardAggregationRetentionConfig 预聚合保留窗口 type DashboardAggregationRetentionConfig struct { UsageLogsDays int `mapstructure:"usage_logs_days"` UsageBillingDedupDays int `mapstructure:"usage_billing_dedup_days"` HourlyDays int `mapstructure:"hourly_days"` DailyDays int `mapstructure:"daily_days"` } // UsageCleanupConfig 使用记录清理任务配置 type UsageCleanupConfig struct { Enabled bool `mapstructure:"enabled"` MaxRangeDays int `mapstructure:"max_range_days"` BatchSize int `mapstructure:"batch_size"` WorkerIntervalSeconds int `mapstructure:"worker_interval_seconds"` TaskTimeoutSeconds int `mapstructure:"task_timeout_seconds"` }