From c0578988e1802831a9d4773d4bdfca21d71fdf2b Mon Sep 17 00:00:00 2001 From: huanghaosheng <386998068@qq.com> Date: Fri, 30 Oct 2026 15:24:40 +0800 Subject: [PATCH] =?UTF-8?q?docs(agents):=20=E8=A1=A5=E5=85=85=E6=B6=88?= =?UTF-8?q?=E8=B4=B9=E5=BE=AA=E7=8E=AF=E4=B8=8E=E5=81=9C=E6=B3=8A=E9=93=BE?= =?UTF-8?q?=E8=B7=AF=E7=9A=84=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Workers 一节说明 ConsumeLoop 是唯一决定 Ack、retry、park 的地方。 同时说明按 body 的 action 分派,因为重试跳会改写 routing key。 迁移实体列表补上 FailedEvent。 --- AGENTS.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/AGENTS.md b/AGENTS.md index cedf680..d97243d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -104,6 +104,8 @@ Three-tier: L1 in-process `go-cache` (3s) → L2 Redis JSON (1h) → L3 MySQL wi Consumers never touch `*amqp.Connection`. Each one runs `rabbitmq.RunConsumer(ctx, mgr, name, prefetch, fn)` — the single consume loop in the project. It blocks (no polling) while the connection is down, and on recovery rebuilds the channel, re-applies per-channel QoS, and re-runs `Consume`. Channel-level exceptions (queue deleted, 406 conflicts) trigger a topology replay rather than a reconnect. Topology is registered once (`RegisterTopology`) and replayed automatically on every new connection. `SSEHub` is an in-process pub/sub for real-time notification push to connected clients. Notification workers consume from `notification.like`, `notification.comment`, `notification.social` queues. Note: `notification` domain is handler-only — routes in `router.go`, worker-side logic in `worker/notificationworker.go`. +Inside that callback every business worker calls `rabbitmq.ConsumeLoop(ctx, ch, parker, queue, rabbitmq.MaxAttempts, process)`. It is the only place that decides Ack / retry / park: a `nil` error acks, `rabbitmq.Permanent(err)` parks immediately, and any other error goes back through the queue's own `.retry` delay queue until `MaxAttempts` is spent. Parking publishes to `dlx.events` with routing key `parked.`, and `FailedEventWorker` persists those messages into the `failed_events` table. Retry counts come from the broker's `x-death` header, never from process memory. A worker dispatches on the message body (`action`) rather than `d.RoutingKey`: the retry hop rewrites the routing key to the queue name. + ### Frontend (Vue 3 + TypeScript on rolldown-vite) - **Language**: Chinese UI (matching README and documentation) @@ -137,7 +139,7 @@ Consumers never touch `*amqp.Connection`. Each one runs `rabbitmq.RunConsumer(ct ### Database Entities (auto-migrated via GORM) -`Account`, `Video`, `Like`, `Comment`, `Social`, `OutboxMsg`, `Tag`, `VideoTag`, `Message`, `Notification` +`Account`, `Video`, `Like`, `Comment`, `Social`, `OutboxMsg`, `Tag`, `VideoTag`, `Message`, `Notification`, `FailedEvent` ### Chunked Upload