Files
smartmate/backend/config.example.yaml
LoveLosita 1ed558b488 Version: 0.4.8.dev.260308
feat: 🏗️ 实现 Agent 消息可靠异步持久化(Outbox + Kafka)

* 新增 Outbox 数据模型与消息载荷定义,位于 `backend/model/outbox.go`
* 新增 Outbox DAO,支持创建、扫描、发布标记、失败重试与消费落库事务,位于 `backend/dao/outbox.go`
* 新增 Kafka 基础封装,包含配置、生产者、消费者与消息包装,位于 `backend/kafka` 文件夹

  * `config.go`:Kafka 配置文件
  * `producer.go`:Kafka 生产者
  * `consumer.go`:Kafka 消费者
  * `envelope.go`:消息封装处理
* 新增异步管道服务,处理扫描投递与消费落库,位于 `backend/service/agent_async_pipeline.go`
* 接入 Agent 聊天链路的可靠持久化,替换原有 goroutine 直接写库逻辑,位于 `backend/service/agent.go`
* 启动流程接入管道初始化与启动,位于 `backend/cmd/start.go`
* 增加 Kafka 配置项,更新 `backend/config.yaml` 与 `backend/config.example.yaml`
* 引入 Kafka 依赖:`github.com/segmentio/kafka-go`(见 `backend/go.mod`, `backend/go.sum`)

fix: 🐛 修复首启偶发 user 消息重复落库问题

* 解决因 Outbox 状态并发回写竞态,导致 `consumed` 被晚到的 `published` 覆盖的问题
* 在 `MarkPublished` 中增加条件,避免覆盖已标记为 `consumed` 或 `dead` 的消息,修复位置:`backend/dao/outbox.go`

perf:  更新 Docker Compose 配置与 Kafka 相关服务

* 更新 `docker-compose.yml` 文件,新增 Kafka 配置与服务

fix: 🧹 优化缓存删除逻辑

* 在 `cache deleter` 中忽略了 `model.AgentOutboxMessage`、`model.ChatHistory` 与 `model.AgentChat` 这三个结构体
* 防止这些结构体对应的表单删除缓存时,导致控制台消息爆炸
2026-03-08 12:53:54 +08:00

55 lines
1.4 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.
# 应用配置文件示例
# 包含服务器、数据库等基础配置
# 请根据实际情况修改并保存为 config.yaml
server:
port: 8080
mode: debug
timeout: 30s
database:
host: localhost
port: 3306
user: smartflow_user
password: "put_your_database_password_here"
dbname: "put_your_database_name_here"
charset: utf8mb4
parseTime: true
loc: Local
jwt:
accessSecret: "put_your_jwt_access_secret_here"
refreshSecret: "put_your_jwt_refresh_secret_here"
accessTokenExpire: 15min
refreshTokenExpire: 7d
log:
level: info
path: logs/
redis:
host: localhost
port: 6379
password: ""
db: 0
kafka:
enabled: true
brokers:
- "localhost:9092"
topic: "smartflow.agent.outbox"
groupID: "smartflow-agent-outbox-consumer"
retryScanInterval: 1s
retryBatchSize: 100
maxRetry: 20
time:
zone: "Asia/Shanghai"
semesterStartDate: "2026-03-02" #学期开始日期,一定要设定为周一,以便于计算周数
semesterEndDate: "2026-07-19" #学期结束日期,一定要设定为周日,确保最后一周完整
agent:
workerModel: "doubao-seed-1-6-lite-251015" # 智能体使用的Worker模型需根据实际情况调整
strategistModel: "deepseek-v3-2-251201" # 策略师使用的Worker模型需根据实际情况调整
baseURL: "https://ark.cn-beijing.volces.com/api/v3" # Worker服务的基础URL需根据实际情况调整