MCPcopy Create free account
hub / github.com/0xUnixIO/pulse / RunReaper

Method RunReaper

internal/nodehub/hub.go:156–167  ·  view source on GitHub ↗

RunReaper 阻塞运行死连接清理:每 ReaperInterval 扫描一次注册表, 关闭超过 DeadConnectionTimeout 没收到任何帧的连接。ctx 取消时返回。 一般由 ListenAndServe 在 goroutine 中调用;外部直接持有 Hub 时也可手动调。

(ctx context.Context)

Source from the content-addressed store, hash-verified

154// 关闭超过 DeadConnectionTimeout 没收到任何帧的连接。ctx 取消时返回。
155// 一般由 ListenAndServe 在 goroutine 中调用;外部直接持有 Hub 时也可手动调。
156func (h *Hub) RunReaper(ctx context.Context) {
157 t := time.NewTicker(h.reaperInterval)
158 defer t.Stop()
159 for {
160 select {
161 case <-ctx.Done():
162 return
163 case now := <-t.C:
164 h.reapOnce(now)
165 }
166 }
167}
168
169func (h *Hub) reapOnce(now time.Time) {
170 threshold := now.Add(-h.deadConnTimeout)

Callers 4

TestLoad_ConcurrentNodesFunction · 0.80
startNodeHubFunction · 0.80

Calls 3

reapOnceMethod · 0.95
StopMethod · 0.65
DoneMethod · 0.65

Tested by 3

TestLoad_ConcurrentNodesFunction · 0.64