docs(gateway): gateway 剩余文件注释改中文(逐行 1:1,代码零字节改动)
主人 2026-10-03 拍板「注释一律中文」;gateway 至此整包注释中文化完成(本会话共 3 批: 已推库 16 个文件 + 本批剩余文件)。 校验:机械校验(非注释改动行)= 空;剥注释后代码文本逐行比对全等(不一致文件数 0); 全树 go test ./... 58 包 ok / 0 FAIL;交叉编译绿。
This commit is contained in:
1 parent
91e8d7a029
commit
074ffc4ebf
73 files changed
+2529
-2529
No files matched your search
@@ -10,14 +10,14 @@ import (
|
||||
"git.yeij.top/AskaEth/Cyrene_v2/internal/channel/adapter"
|
||||
)
|
||||
|
||||
// wsProactiveMessage is the WS event type for an autonomous proactive push
|
||||
// (design/12 §3): a message Cyrene decided to send without a recent user input.
|
||||
// wsProactiveMessage 是自主主动推送的 WS 事件类型
|
||||
// (design/12 §3):Cyrene 在没有近期用户输入时决定发送的消息。
|
||||
const wsProactiveMessage = "proactive_message"
|
||||
|
||||
// proactivePayload is the sanitized wire shape of a proactive message. It carries
|
||||
// only the fields a client needs to render a bubble (content, platform, channel,
|
||||
// sender label); it deliberately omits RawData / media bytes / tokens so a
|
||||
// proactive push can never leak a credential or payload into the frontend.
|
||||
// proactivePayload 是主动消息消毒后的线上结构。它只
|
||||
// 携带客户端渲染气泡所需的字段(content、platform、channel、
|
||||
// 发送者标签);它刻意省略 RawData / 媒体字节 / token,使
|
||||
// 主动推送绝不可能把凭据或载荷泄露进前端。
|
||||
type proactivePayload struct {
|
||||
Platform string `json:"platform,omitempty"`
|
||||
ChannelID string `json:"channelId,omitempty"`
|
||||
@@ -29,12 +29,12 @@ type proactivePayload struct {
|
||||
MessageID string `json:"messageId,omitempty"`
|
||||
}
|
||||
|
||||
// SendProactive delivers msg to every live owner/admin connection and returns how
|
||||
// many accepted it. A zero count means no owner/admin client is online, so the
|
||||
// caller falls back to the IM bridge. Only owner/admin connections are targeted
|
||||
// (red line: proactive is owner-only); a viewer or unauthenticated connection is
|
||||
// never reached. It never blocks: a full send buffer drops the frame for that
|
||||
// slow client rather than stalling the backthink push.
|
||||
// SendProactive 把 msg 投递给每个存活的 owner/admin 连接,并返回
|
||||
// 有多少个接受了它。计数为零意味着没有 owner/admin 客户端在线,
|
||||
// 因此调用方回退到 IM bridge。只有 owner/admin 连接会被作为
|
||||
// 目标(红线:主动推送仅 owner);viewer 或未认证连接
|
||||
// 绝不被触达。它绝不阻塞:发送缓冲满时对该
|
||||
// 慢客户端丢弃该帧,而不是卡住后台思考推送。
|
||||
func (h *hub) SendProactive(ctx context.Context, msg adapter.UnifiedMessage) (int, error) {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return 0, err
|
||||
@@ -59,13 +59,13 @@ func (h *hub) SendProactive(ctx context.Context, msg adapter.UnifiedMessage) (in
|
||||
return n, nil
|
||||
}
|
||||
|
||||
// Server.SendProactive satisfies the backthink ActiveClient seam by delegating to
|
||||
// the hub, so the composition root can hand the gateway itself to the sink setter.
|
||||
// Server.SendProactive 通过委托给 hub 满足后台思考的 ActiveClient
|
||||
// 接缝,因此组合根能把网关自身交给汇聚点设置器。
|
||||
func (s *Server) SendProactive(ctx context.Context, msg adapter.UnifiedMessage) (int, error) {
|
||||
return s.hub.SendProactive(ctx, msg)
|
||||
}
|
||||
|
||||
// proactivePayloadFrom projects a UnifiedMessage into the sanitized wire payload.
|
||||
// proactivePayloadFrom 把 UnifiedMessage 投影为消毒后的线上载荷。
|
||||
func proactivePayloadFrom(msg adapter.UnifiedMessage) proactivePayload {
|
||||
return proactivePayload{
|
||||
Platform: msg.Platform,
|
||||
@@ -79,8 +79,8 @@ func proactivePayloadFrom(msg adapter.UnifiedMessage) proactivePayload {
|
||||
}
|
||||
}
|
||||
|
||||
// ownerAdminClaims reports whether claims authorize a proactive push (owner or
|
||||
// admin). Nil claims (unauth / bare test connections) are never targeted.
|
||||
// ownerAdminClaims 报告 claims 是否授权一次主动推送(owner 或
|
||||
// admin)。nil claims(未认证 / 裸测试连接)绝不被作为目标。
|
||||
func ownerAdminClaims(claims *auth.Claims) bool {
|
||||
if claims == nil {
|
||||
return false
|
||||
|
||||
Reference in new issue
Block a user