internal/chat: мультиканальный Router (UserID-сессии, routing, pending Ask/ответ) + Channel интерфейс
All checks were successful
build-test / build (push) Successful in 41s

This commit is contained in:
Hermes
2026-08-14 20:33:04 +05:00
parent 4ebafc48d0
commit c9d69594cc
6 changed files with 452 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
package chat
import (
"crypto/rand"
"encoding/hex"
"time"
)
// newQuestionID генерирует уникальный идентификатор вопроса (блок 4:
// идентификатор в каждом Message, чтобы связать ответ с вопросом).
func newQuestionID() string {
b := make([]byte, 8)
if _, err := rand.Read(b); err != nil {
// крипто-rand недоступен — fallback по времени (уникален на практике)
return "q_" + hex.EncodeToString([]byte(time.Now().Format("150405.000000000")))
}
return "q_" + hex.EncodeToString(b)
}