|
|
c210e75996
|
style(backend): 清理幂等写入路径的注释
注释只保留一行级约束。
长段理由移入设计文档。
验证:go test -count=1 ./... 全绿。
|
2026-10-31 00:03:53 +08:00 |
|
|
|
151faf25fa
|
refactor(notification): 通知实体抽成独立包
`video` 与 `worker` 各有一份 `notifications` 表的实体。
两份定义会漂移,所以合并到 `internal/notification`。
新增 `entity.go` 保存唯一一份列标签。
`worker`、`ssehub`、`comment_repo`、`db` 与两个集成测试改为引用新包。
`db` 包不再 import `worker`。
去重键仍是 `*string`,因此 NULL 才能共存。
验证:go test -count=1 ./... 全绿;集成测试三包全绿。
|
2026-10-30 23:48:43 +08:00 |
|
|
|
a9c0340733
|
feat(video): 评论幂等写入与提及通知去重
P0-4 的写层基础:给每次"用户想发一条评论"一个稳定的意图键,并让判重
与写入成为同一条 SQL 的同一个事务。
- comments 加 idempotency_key,与 author_id 组成唯一索引
uk_comments_author_key。用 *string 而不是 string:MySQL 不约束 NULL,
多条无键评论才能共存;空串会互相撞键。
- CreateIdempotentWithPopularity 在一个事务里完成"插入评论 + 首次插入时
视频热度 +1"。重复写入静默返回 created=false,不报错、不覆盖、不再加
热度。判重交给数据库唯一索引,因此不存在"先 SELECT 再 INSERT"的窗口
——那个窗口正是 MQ 假失败后兜底直写与 worker 稍后消费的交错点。
- DeleteByID 汇报是否真的删掉了一行,作为删除侧热度回退的门控点
(P2-20)。删除事件的重复投递与新增同样会把热度减两次。
- CreateMentions 按 dedupe_key 幂等写入提及通知,并显式写 CreatedAt
(P2-16 ①);FindAccountIDs 用一次 username IN (?) 替换逐个查询。
- CommentStore 接口把"判重与写入必须同事务"这条约束变成显式的名字。
集成测试(-tags integration,需要 MYSQL_TEST_DSN)覆盖:重复插入报告 0
行且热度只加一次、8 并发只有 1 个 created、多条 NULL 键共存、提及通知
去重且 CreatedAt 非零、用户名批量解析。
|
2026-10-30 13:21:09 +08:00 |
|
leonincs
|
732e284369
|
style: 统一代码格式和行尾
|
2026-05-20 16:34:19 +08:00 |
|
Sisyphus
|
48a7eea0f9
|
fix: Worker 队列补充 DLX args + GetAllComments 加排序和分页限制
|
2026-04-25 17:10:55 +08:00 |
|
Leon
|
9ba916643e
|
move: 后端
|
2025-12-25 22:40:20 +08:00 |
|