docs(agents): 补充消费循环与停泊链路的说明
Workers 一节说明 ConsumeLoop 是唯一决定 Ack、retry、park 的地方。 同时说明按 body 的 action 分派,因为重试跳会改写 routing key。 迁移实体列表补上 FailedEvent。
This commit is contained in:
@@ -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`.
|
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 `<queue>.retry` delay queue until `MaxAttempts` is spent. Parking publishes to `dlx.events` with routing key `parked.<source queue>`, 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)
|
### Frontend (Vue 3 + TypeScript on rolldown-vite)
|
||||||
|
|
||||||
- **Language**: Chinese UI (matching README and documentation)
|
- **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)
|
### 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
|
### Chunked Upload
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user