Files
junhong_cmp_fiber/configs/config.prod.yaml
huang 984ccccc63 docs(constitution): 新增数据库设计原则(v2.4.0)
在项目宪章中新增第九条原则"数据库设计原则",明确禁止使用数据库外键约束和ORM关联标签。

主要变更:
- 新增原则IX:数据库设计原则(Database Design Principles)
- 强制要求:数据库表不得使用外键约束
- 强制要求:GORM模型不得使用ORM关联标签(foreignKey、hasMany等)
- 强制要求:表关系必须通过ID字段手动维护
- 强制要求:关联数据查询必须显式编写,避免ORM魔法
- 强制要求:时间字段由GORM处理,不使用数据库触发器

设计理念:
- 提升业务逻辑灵活性(无数据库约束限制)
- 优化高并发性能(无外键检查开销)
- 增强代码可读性(显式查询,无隐式预加载)
- 简化数据库架构和迁移流程
- 支持分布式和微服务场景

版本升级:2.3.0 → 2.4.0(MINOR)
2025-11-13 13:40:19 +08:00

76 lines
1.7 KiB
YAML
Raw Permalink 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_auth: true
# 生产环境启用限流,保护服务免受滥用
enable_rate_limiter: true
# 限流器配置(生产环境)
rate_limiter:
# 生产环境限制每分钟5000请求
# 根据实际业务需求调整
max: 5000
# 1分钟窗口标准配置
expiration: "1m"
# 生产环境使用 Redis 分布式限流
# 优势:
# 1. 多服务器实例共享限流计数器
# 2. 限流状态持久化,服务重启不丢失
# 3. 精确的全局限流控制
storage: "redis"