chore: 统一本地服务器与远程仓库源码
- 合并 main 与 master 历史并以服务器结构为基线 - 保留迁移、数据保留、AWS 账单与部署安全能力 - 建立 SDD 规格和 CI 验证闭环
This commit is contained in:
commit
fd60361d93
460 files changed
+37492
-23871
No files matched your search
@@ -9,15 +9,24 @@ import (
|
||||
|
||||
// Config 应用配置
|
||||
type Config struct {
|
||||
Mode string `mapstructure:"mode"`
|
||||
Port string `mapstructure:"port"`
|
||||
LogLevel string `mapstructure:"log_level"`
|
||||
Database DatabaseConfig `mapstructure:"database"`
|
||||
JWT JWTConfig `mapstructure:"jwt"`
|
||||
Redis RedisConfig `mapstructure:"redis"`
|
||||
Mode string `mapstructure:"mode"`
|
||||
Port string `mapstructure:"port"`
|
||||
LogLevel string `mapstructure:"log_level"`
|
||||
Database DatabaseConfig `mapstructure:"database"`
|
||||
JWT JWTConfig `mapstructure:"jwt"`
|
||||
Agent AgentConfig `mapstructure:"agent"`
|
||||
Retention RetentionConfig `mapstructure:"retention"`
|
||||
Billing BillingConfig `mapstructure:"billing"`
|
||||
Redis RedisConfig `mapstructure:"redis"`
|
||||
Websocket WebsocketConfig `mapstructure:"websocket"`
|
||||
}
|
||||
|
||||
// BillingConfig 定义云账单报告本位币及各原币种折算到 CNY 的汇率。 // Logan.Li
|
||||
type BillingConfig struct {
|
||||
BaseCurrency string `mapstructure:"base_currency"`
|
||||
ExchangeRates map[string]float64 `mapstructure:"exchange_rates"`
|
||||
}
|
||||
|
||||
// DatabaseConfig 数据库配置
|
||||
type DatabaseConfig struct {
|
||||
Driver string `mapstructure:"driver"`
|
||||
@@ -37,9 +46,25 @@ type JWTConfig struct {
|
||||
ExpireHour int `mapstructure:"expire_hour"`
|
||||
}
|
||||
|
||||
// AgentConfig Agent 接入安全配置。 // Logan.Li
|
||||
type AgentConfig struct {
|
||||
EnforceAuth bool `mapstructure:"enforce_auth"`
|
||||
}
|
||||
|
||||
// RetentionConfig 高频数据保留期配置,单位为天。 // Logan.Li
|
||||
type RetentionConfig struct {
|
||||
AgentReportsDays int `mapstructure:"agent_reports_days"`
|
||||
MetricHistoryDays int `mapstructure:"metric_history_days"`
|
||||
MetricAggregateDays int `mapstructure:"metric_aggregate_days"`
|
||||
SNMPSamplesDays int `mapstructure:"snmp_samples_days"`
|
||||
SiteResultsDays int `mapstructure:"site_results_days"`
|
||||
LogEntriesDays int `mapstructure:"log_entries_days"`
|
||||
CleanupBatchSize int `mapstructure:"cleanup_batch_size"`
|
||||
}
|
||||
|
||||
// RedisConfig Redis配置
|
||||
type RedisConfig struct {
|
||||
Driver string `mapstructure:"driver"` // redka (内嵌) / redis (外部)
|
||||
Driver string `mapstructure:"driver"` // redka (内嵌) / redis (外部)
|
||||
Host string `mapstructure:"host"`
|
||||
Port int `mapstructure:"port"`
|
||||
Password string `mapstructure:"password"`
|
||||
@@ -71,6 +96,17 @@ func Load() *Config {
|
||||
viper.SetDefault("database.max_conn", 100)
|
||||
viper.SetDefault("database.max_idle", 10)
|
||||
viper.SetDefault("jwt.expire_hour", 24)
|
||||
viper.SetDefault("agent.enforce_auth", false)
|
||||
viper.SetDefault("retention.agent_reports_days", 7)
|
||||
viper.SetDefault("retention.metric_history_days", 30)
|
||||
viper.SetDefault("retention.metric_aggregate_days", 365)
|
||||
viper.SetDefault("retention.snmp_samples_days", 30)
|
||||
viper.SetDefault("retention.site_results_days", 30)
|
||||
viper.SetDefault("retention.log_entries_days", 30)
|
||||
viper.SetDefault("retention.cleanup_batch_size", 10000)
|
||||
viper.SetDefault("billing.base_currency", "CNY")
|
||||
viper.SetDefault("billing.exchange_rates.CNY", 1.0)
|
||||
viper.SetDefault("billing.exchange_rates.USD", 7.2)
|
||||
viper.SetDefault("redis.host", "localhost")
|
||||
viper.SetDefault("redis.port", 6379)
|
||||
viper.SetDefault("redis.driver", "redka")
|
||||
|
||||
Reference in new issue
Block a user