(ctx context.Context, keepAlive time.Duration)
| 148 | } |
| 149 | |
| 150 | func (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 | |
| 170 | func (c *Controller) recordSystemStats(ctx context.Context) { |
| 171 | interval := 1500 * time.Millisecond |
no test coverage detected