runStatsLoop emits a one-line health summary every statsInterval until ctx is canceled. Cheap (atomic Loads + one log line) so it's safe to keep always-on.
(ctx context.Context)
| 15 | // ctx is canceled. Cheap (atomic Loads + one log line) so it's safe to keep |
| 16 | // always-on. |
| 17 | func (s *Server) runStatsLoop(ctx context.Context) { |
| 18 | t := time.NewTicker(statsInterval) |
| 19 | defer t.Stop() |
| 20 | for { |
| 21 | select { |
| 22 | case <-ctx.Done(): |
| 23 | return |
| 24 | case <-t.C: |
| 25 | s.logStats() |
| 26 | } |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | func (s *Server) logStats() { |
| 31 | s.mu.Lock() |
no test coverage detected