feat: add bounded observability and verified SLO incident alerts

This commit is contained in:
Vladislav Agapov
2026-10-29 18:01:11 +03:00
parent 470d9d6f1e
commit 6c7601802d
325 changed files with 24988 additions and 44 deletions
+47
View File
@@ -0,0 +1,47 @@
package production
import (
"context"
"gitea.privcloud.tech/vlad_marlo/mtusi2026lab6/internal/model/dto"
)
// ChatsCreate resolves the caller, validates the proposed chat and persists it atomically.
func (s *Service) ChatsCreate(ctx context.Context, request dto.ChatsCreateRequestDTO) (dto.ChatDTO, error) {
caller, err := s.requireUserID(ctx, request.UserID)
if err != nil {
return dto.ChatDTO{}, err
}
chat, err := prepareChat(request, caller)
if err != nil {
return dto.ChatDTO{}, err
}
if err := s.requireExistingMembers(ctx, chat.MemberIDs); err != nil {
return dto.ChatDTO{}, err
}
created, err := s.repo.CreateChat(ctx, chat)
return created, normalizeStoreError(err)
}
// ChatsGetByID returns a chat only to a current member, hiding its existence otherwise.
func (s *Service) ChatsGetByID(ctx context.Context, userID, chatID string) (dto.ChatDTO, error) {
_, chat, err := s.requireChatMember(ctx, userID, chatID)
return chat, err
}
// ChatsGetPage authorizes the caller, loads a page and prepares its continuation.
func (s *Service) ChatsGetPage(ctx context.Context, request dto.PageRequestDTO) (dto.ChatPageDTO, error) {
caller, err := s.requireUserID(ctx, request.UserID)
if err != nil {
return dto.ChatPageDTO{}, err
}
page, err := s.parsePage(request, chatListResource(caller))
if err != nil {
return dto.ChatPageDTO{}, err
}
items, err := s.repo.Chats(ctx, caller, page.position, page.fetchLimit())
if err != nil {
return dto.ChatPageDTO{}, normalizeStoreError(err)
}
return s.chatPage(items, page)
}