feat: port backend implementation from lab1

This commit is contained in:
Голиков Maximillian Антон
2026-09-30 22:32:04 +03:00
parent 65003b6119
commit 380d0ef710
34 changed files with 1795 additions and 0 deletions
@@ -0,0 +1,34 @@
package memory
import (
"sync"
"high-loud-apps-labs/internal/domain"
)
type Storage struct {
mu sync.RWMutex
users map[string]*domain.User
chats map[string]*domain.Chat
messages map[string][]domain.Message
}
func New() *Storage {
return &Storage{
users: make(map[string]*domain.User),
chats: make(map[string]*domain.Chat),
messages: make(map[string][]domain.Message),
}
}
func (s *Storage) Users() *UserRepo { return &UserRepo{s} }
func (s *Storage) Chats() *ChatRepo { return &ChatRepo{s} }
func (s *Storage) Messages() *MessageRepo { return &MessageRepo{s} }
type UserRepo struct{ *Storage }
type ChatRepo struct{ *Storage }
type MessageRepo struct{ *Storage }
var _ domain.UserRepository = (*UserRepo)(nil)
var _ domain.ChatRepository = (*ChatRepo)(nil)
var _ domain.MessageRepository = (*MessageRepo)(nil)