// 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 PipelineMetrics(context.Context) (model.PipelineMetrics, error) } 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) }