Prepare verified laboratory 5 implementation and evidence

This commit is contained in:
rey
2026-11-17 17:32:06 +03:00
parent 276dbdad8a
commit 57a253e0b4
122 changed files with 13404 additions and 72 deletions
@@ -0,0 +1,64 @@
// Package repository — порт персистентности. В lab1 его реализует хранилище
// в памяти процесса, с lab2 — PostgreSQL; ядро от этой замены не меняется.
package repository
import (
"context"
"backend/internal/domain/model"
"backend/internal/domain/port"
"github.com/google/uuid"
)
// Repository assigns IDs and database timestamps. Keyset order is (created_at, id);
// concurrent commits do not provide insertion order or a traversal snapshot.
// Каждый метод атомарен сам по себе.
type Repository interface {
UserRepository
ChatRepository
MessageRepository
AttachmentRepository
}
type AttachmentRepository interface {
ReserveAttachment(context.Context, model.Attachment) (model.Attachment, error)
GetAttachment(context.Context, uuid.UUID) (model.Attachment, error)
SetAttachmentStatus(context.Context, uuid.UUID, string, string) (bool, error)
ReconcileAttachments(context.Context, uuid.UUID) ([]model.Attachment, bool, error)
}
type Persistent interface {
Repository
port.Sessions
AsyncAttachments
port.PipelineStore
}
type AsyncAttachments interface {
AttachmentRepository
QueueAttachment(context.Context, model.Attachment, string, string) (model.Attachment, error)
}
type UserRepository interface {
// CreateUser: model.ErrUsernameTaken, model.ErrStorageFull.
CreateUser(ctx context.Context, draft model.UserDraft) (model.User, error)
// GetUser: model.ErrNotFound.
GetUser(ctx context.Context, id uuid.UUID) (model.User, error)
}
type ChatRepository interface {
// CreateChat: model.ErrUnknownMember, model.ErrStorageFull.
CreateChat(ctx context.Context, draft model.ChatDraft) (model.Chat, error)
// GetChat: model.ErrNotFound.
GetChat(ctx context.Context, id uuid.UUID) (model.Chat, error)
// ListChats возвращает чаты участника и признак, что есть следующая страница.
ListChats(ctx context.Context, memberID uuid.UUID, q model.PageQuery) ([]model.Chat, bool, error)
}
type MessageRepository interface {
// CreateMessage: model.ErrNotFound (нет чата), model.ErrStorageFull.
CreateMessage(ctx context.Context, draft model.MessageDraft) (model.Message, error)
// ListMessages возвращает страницу истории и признак следующей страницы.
ListMessages(ctx context.Context, chatID uuid.UUID, q model.PageQuery) ([]model.Message, bool, error)
}