Добавить наблюдаемость и проверки отказов для ЛР 6

This commit is contained in:
2026-11-26 18:20:32 +03:00
parent 1d81159dd3
commit 9db37405fb
46 changed files with 7878 additions and 173 deletions
+5 -1
View File
@@ -1,10 +1,12 @@
package httpapi
import (
"context"
"errors"
"net/http"
"regexp"
"strings"
"time"
"mtusi2026/internal/idgen"
"mtusi2026/internal/model"
@@ -46,7 +48,9 @@ func (a *api) handleCreateMessage(w http.ResponseWriter, r *http.Request, u mode
return
}
m, err := a.store.CreateMessage(r.Context(), chatID, u.ID, key, req.Text, ids)
ctx, cancel := context.WithTimeout(r.Context(), 4*time.Second)
defer cancel()
m, err := a.store.CreateMessage(ctx, chatID, u.ID, key, req.Text, ids)
if err != nil {
switch {
case errors.Is(err, store.ErrChatNotFound), errors.Is(err, store.ErrAttachmentNotFound):