docs(gateway): WS 帧门相关 11 个文件的注释改中文(只改注释,代码零字节改动)
主人 2026-10-03 拍板「注释一律中文」。本次先把本会话动过的文件就地翻; 不做全仓一次性翻译,存量按包分批排期(见 工作小结.md 待办)。 范围:ws_frame_scope.go / ws_frame_scope_test.go / broadcast.go / ws_hub_turn.go / ws_hub_message_event.go / session_read.go / server.go / ws_hub_stream_scope_test.go / history_write_broadcast_test.go / mood_test.go / extra_test.go 含中文的整行注释 18 → 382。 校验(判据 = "只改注释、零代码字节改动"): - `git diff -U0 | 排除 +++/--- | 排除注释行/空行/行尾注释` → 为空 - 独立实现:两侧剥掉注释后逐行比对代码文本 → 11/11 文件全等,不一致数 0 - 行尾注释 7 行逐条列出,代码列与原文逐字节相同(gofmt 未要求重排) - gofmt -l 干净;全树 go build/vet 绿;go test ./... = 58 包 ok / 0 FAIL; linux/amd64 + darwin/arm64 交叉编译绿 语义未删减:部分折行英文长句合并为更少行,故整行注释数 438 → 399。
This commit is contained in:
1 parent
770a83c3fb
commit
fe1ff33115
11 files changed
+392
-431
No files matched your search
@@ -1,31 +1,30 @@
|
||||
package gateway
|
||||
|
||||
// wsMessageEdited / wsMessageDeleted are the downstream event types of the D3
|
||||
// history writes: a message's content was edited, or a message was removed. Both
|
||||
// reuse the wsEvent envelope and the same fan-out as `message_persisted` — and,
|
||||
// like it and every other content frame, they are owner/admin only under the
|
||||
// design/11 §7.1 frame gate. The hub has no per-session subscription, so the frame
|
||||
// carries SessionID and a client filters it by its active session, exactly as it
|
||||
// does for message_persisted.
|
||||
// wsMessageEdited / wsMessageDeleted 是 D3 历史写入的下行事件类型:
|
||||
// 消息内容被编辑,或消息被删除。二者复用 wsEvent 信封与
|
||||
// `message_persisted` 相同的扇出 —— 并且与它以及其他所有内容帧
|
||||
// 一样,在 design/11 §7.1 帧门下只发 owner/admin。hub 没有按会话的
|
||||
// 订阅,因此帧携带 SessionID,由客户端按其活跃会话过滤,与它对
|
||||
// message_persisted 的处理完全一致。
|
||||
const (
|
||||
wsMessageEdited = "message_edited"
|
||||
wsMessageDeleted = "message_deleted"
|
||||
)
|
||||
|
||||
// broadcastMessageEdited fans a content edit out to the owner/admin connections as
|
||||
// a `message_edited` frame whose data is the updated message DTO. The frame is a
|
||||
// render-only sync: the edited content's single source of truth stays the history
|
||||
// store, so a client that missed the frame converges again on its next read. The
|
||||
// caller strips Thinking to match the message_persisted/replay contract.
|
||||
// broadcastMessageEdited 把一次内容编辑作为 `message_edited` 帧扇出到
|
||||
// owner/admin 连接,其 data 是更新后的消息 DTO。该帧只用于渲染同步:
|
||||
// 编辑后内容的唯一事实来源仍是 history store,因此错过该帧的客户端
|
||||
// 会在下次读取时重新收敛。调用方会抹除 Thinking,以匹配
|
||||
// message_persisted/回放契约。
|
||||
func (h *hub) broadcastMessageEdited(msg historyMessage) {
|
||||
h.broadcast(wsEvent{Type: wsMessageEdited, SessionID: msg.SessionID, Data: msg})
|
||||
}
|
||||
|
||||
// broadcastMessageDeleted fans a removal out to the owner/admin connections as a
|
||||
// `message_deleted` frame carrying the removed id (plus the owning sessionId for
|
||||
// client-side session filtering), so every browser of the account drops the row
|
||||
// without a refresh. sessionID may be empty when the store could not report it;
|
||||
// clients then fall back to the globally unique id.
|
||||
// broadcastMessageDeleted 把一次删除作为 `message_deleted` 帧扇出到
|
||||
// owner/admin 连接,携带被删除的 id(外加所属 sessionId,供客户端
|
||||
// 按会话过滤),使该账号的每个浏览器无需刷新即可移除该行。
|
||||
// 当存储无法报告 sessionID 时它可能为空;客户端此时回退到全局
|
||||
// 唯一的 id。
|
||||
func (h *hub) broadcastMessageDeleted(sessionID, id string) {
|
||||
h.broadcast(wsEvent{Type: wsMessageDeleted, SessionID: sessionID, Data: map[string]any{"id": id}})
|
||||
}
|
||||
Reference in new issue
Block a user