MCPcopy Create free account
hub / github.com/PasarGuard/node / keepAliveTracker

Method keepAliveTracker

controller/controller.go:150–168  ·  view source on GitHub ↗
(ctx context.Context, keepAlive time.Duration)

Source from the content-addressed store, hash-verified

148}
149
150func (c *Controller) keepAliveTracker(ctx context.Context, keepAlive time.Duration) {
151 ticker := time.NewTicker(5 * time.Second)
152 defer ticker.Stop()
153
154 for {
155 select {
156 case <-ctx.Done():
157 return
158 case <-ticker.C:
159 c.mu.RLock()
160 lastRequest := c.lastRequest
161 c.mu.RUnlock()
162 if time.Since(lastRequest) >= keepAlive {
163 log.Println("disconnect automatically due to keep alive timeout")
164 c.Disconnect()
165 }
166 }
167 }
168}
169
170func (c *Controller) recordSystemStats(ctx context.Context) {
171 interval := 1500 * time.Millisecond

Callers 1

ConnectMethod · 0.95

Calls 2

DisconnectMethod · 0.95
StopMethod · 0.65

Tested by

no test coverage detected