registerHeartbeat enrolls a chat in the centralized batch heartbeat loop. Must be called after chatCtx is created.
(entry *heartbeatEntry)
| 4810 | // registerHeartbeat enrolls a chat in the centralized batch |
| 4811 | // heartbeat loop. Must be called after chatCtx is created. |
| 4812 | func (p *Server) registerHeartbeat(entry *heartbeatEntry) { |
| 4813 | p.heartbeatMu.Lock() |
| 4814 | defer p.heartbeatMu.Unlock() |
| 4815 | if _, exists := p.heartbeatRegistry[entry.chatID]; exists { |
| 4816 | p.logger.Warn(context.Background(), |
| 4817 | "duplicate heartbeat registration, skipping", |
| 4818 | slog.F("chat_id", entry.chatID)) |
| 4819 | return |
| 4820 | } |
| 4821 | p.heartbeatRegistry[entry.chatID] = entry |
| 4822 | } |
| 4823 | |
| 4824 | // unregisterHeartbeat removes a chat from the centralized |
| 4825 | // heartbeat loop when chat processing finishes. |