style(backend): 精简 P1-1 期间的说明性注释

代码只留一行不变量。进程分工的动机、退避与重连的细节、测试可验证性的理由,都已在 docs/solutions/P1-1-async-workers-out-of-api.md 里写过,注释不再复述。

保留的是读代码看不出来的约束:超时派生自 poller 的 ctx、坏消息不能打断订阅、SSE 响应永不结束、订阅存活够久要重置退避。

文档补一句退避重置规则。这是删掉的注释里唯一没有落在文档上的细节。

验证:go test -count=1 ./... 全绿。
This commit is contained in:
2026-11-08 15:47:10 +08:00
parent 06e001a151
commit 5d05c147ed
10 changed files with 26 additions and 67 deletions

View File

@@ -25,9 +25,7 @@ type SSEHub struct {
done <-chan struct{}
}
// NewSSEHub 的 ctx 是进程生命周期。ctx 结束时 SSEHandler 会主动断开连接:
// http.Server.Shutdown 只关空闲连接,不取消在途请求,而 SSE 响应永不结束,
// 少了这条退出路径,每次停机都要把 Shutdown 的超时耗满。
// ctx 结束时 SSEHandler 主动断开:Shutdown 不取消在途请求,而 SSE 响应永不结束。
func NewSSEHub(ctx context.Context, db *gorm.DB) *SSEHub {
h := &SSEHub{clients: make(map[uint][]chan *notification.Notification), db: db}
if ctx != nil {