Files
junhong_cmp_fiber/configs/config.prod.yaml
huang 6821e5abcf
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 4m36s
refactor: 统一错误消息数据源,优化错误码与映射表管理
主要改动:
- 改造 errors.New() 和 Wrap() 函数签名为可变参数,优先使用 errorMessages 映射表
- 添加 allErrorCodes 注册表和 init() 启动时校验,确保错误码与映射表一致
- 添加 TestAllCodesHaveMessages 和 TestNoOrphanMessages 测试防止映射表腐化
- 清理 109 处与映射表一致的冗余硬编码(service 层)
- 保留业务特定消息覆盖能力

新增 API 用法:
- errors.New(errors.CodeUnauthorized) // 使用映射表默认消息
- errors.New(errors.CodeNotFound, "提现申请不存在") // 覆盖为自定义消息
2026-01-22 18:27:42 +08:00

73 lines
1.6 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
server:
address: ":8080"
read_timeout: "10s"
write_timeout: "10s"
shutdown_timeout: "30s"
prefork: true # 生产环境启用多进程模式
redis:
address: "redis-prod:6379"
password: "${REDIS_PASSWORD}"
db: 0
pool_size: 50 # 生产环境更大的连接池
min_idle_conns: 20
dial_timeout: "5s"
read_timeout: "3s"
write_timeout: "3s"
database:
host: "postgres-prod"
port: 5432
user: "postgres"
password: "${DB_PASSWORD}" # 从环境变量读取
dbname: "junhong_cmp"
sslmode: "require" # 生产环境必须启用 SSL
max_open_conns: 50 # 生产环境更大的连接池
max_idle_conns: 20
conn_max_lifetime: "5m"
queue:
concurrency: 20 # 生产环境更高并发
queues:
critical: 6
default: 3
low: 1
retry_max: 5
timeout: "10m"
logging:
level: "warn" # 生产环境较少详细日志
development: false
app_log:
filename: "logs/app.log"
max_size: 100
max_backups: 60
max_age: 60
compress: true
access_log:
filename: "logs/access.log"
max_size: 500
max_backups: 180
max_age: 180
compress: true
middleware:
# 生产环境启用限流,保护服务免受滥用
enable_rate_limiter: true
# 限流器配置(生产环境)
rate_limiter:
# 生产环境限制每分钟5000请求
# 根据实际业务需求调整
max: 5000
# 1分钟窗口标准配置
expiration: "1m"
# 生产环境使用 Redis 分布式限流
# 优势:
# 1. 多服务器实例共享限流计数器
# 2. 限流状态持久化,服务重启不丢失
# 3. 精确的全局限流控制
storage: "redis"