refactor(api): TOML 配置 SSOT、统一错误契约、Auth/事务加固与可观测性 (#33)

配置 SSOT(TOML + .env)
统一错误契约
Auth 与事务边界
Redis / Celery 可靠性:业务 Redis(DB/0)与 Celery broker/backend(DB/1)显式拆分;连接池、sync client
可观测性(OpenTelemetry + LGTM)
This commit is contained in:
Sully
2026-05-22 13:44:50 +08:00
committed by GitHub
parent f09ae248f9
commit 53e0065e3e
298 changed files with 15247 additions and 4344 deletions

View File

@@ -66,9 +66,9 @@ DEEPSEEK_BASE_URL=https://api.deepseek.com
# LLM_MODEL=gpt-4
# LLM_BASE_URL=https://api.openai.com
# Redis 配置(宿主 48307见 docker-compose.dev.yml
# Redis 配置(宿主 48307见 docker-compose.dev.yml;业务 DB/0Celery 自动 DB/1
REDIS_URL=redis://localhost:48307/0
REDIS_SESSION_TTL=86400 # 会话过期时间(秒),默认 24 小时
# 会话 TTL 见 config/default.toml [misc] redis_session_ttl默认 86400 秒),非 .env 项
# 数据库配置(宿主 48291见 docker-compose.dev.yml
DATABASE_URL=postgresql://postgres:postgres@localhost:48291/life_echo
@@ -163,11 +163,11 @@ docker compose up -d --scale celery-worker=3
### 监控(可选)
启用 Flower 监控面板
生产 `docker-compose.yml` 已包含 Flower仅绑定 `127.0.0.1:5555`,需设置 `FLOWER_USER` / `FLOWER_PASSWORD`
1. 编辑 `docker-compose.yml`,取消 `flower` 服务的注释
2. 重启服务`docker compose up -d`
3. 访问 http://localhost:5555 查看 Celery 任务监控
1. `.env` 中设置 `FLOWER_PASSWORD`(及可选 `FLOWER_USER`
2. 启动`docker compose up -d flower`
3. 访问 http://127.0.0.1:5555 查看 Celery 任务监控
## 常见问题
@@ -214,8 +214,8 @@ Redis 连接失败: Error connecting to redis://localhost:48307/0
# Celery 并发数(根据 CPU 核心数调整)
# 在启动命令中配置:--concurrency=4
# 会话 TTL(根据业务需求调整
REDIS_SESSION_TTL=86400
# 会话 TTLconfig/default.toml [misc] redis_session_ttl默认 86400
# TaskTracker TTLconfig/default.toml [redis] task_tracker_ttl_seconds
```
## API 端点