реализован уровень 3

This commit is contained in:
2026-10-15 15:15:35 +03:00
parent 10b5842be3
commit 158fed100c
39 changed files with 3868 additions and 183 deletions
+11 -9
View File
@@ -11,12 +11,6 @@ import (
"github.com/google/uuid"
)
var (
ErrNotFound = fmt.Errorf("not found")
ErrConflict = fmt.Errorf("conflict")
ErrInvalidCursor = fmt.Errorf("invalid cursor")
)
type MemoryStore struct {
mu sync.RWMutex
@@ -81,7 +75,11 @@ func (s *MemoryStore) CreateChat(title string, memberIDs []string) (domain.Chat,
//все участники рил существуют
for _, memberID := range memberIDs {
if _, exists := s.usersByID[memberID]; !exists {
return domain.Chat{}, fmt.Errorf("member not found: %s", memberID)
return domain.Chat{}, fmt.Errorf(
"%w: member %s",
ErrNotFound,
memberID,
)
}
}
@@ -286,9 +284,13 @@ func (s *MemoryStore) GetMessages(
if cursorStr != "" {
decodedCursor, err := domain.DecodeCursor(cursorStr, chatID)
if err != nil {
return domain.MessagePage{},
fmt.Errorf("invalid cursor: %w", err)
return domain.MessagePage{}, fmt.Errorf(
"%w: %v",
ErrInvalidCursor,
err,
)
}
cursorData = decodedCursor
}