Files
mtusi2026lab3/internal/application/ports.go
T
2026-10-21 13:51:35 +03:00

49 lines
1.5 KiB
Go

package application
import (
"context"
"time"
"mtusi2026lab3/internal/domain"
)
type UserRepository interface {
CreateUser(ctx context.Context, username, displayName, passwordHash string) (domain.User, error)
GetUserByUsername(ctx context.Context, username string) (domain.User, string, error)
}
type SessionRepository interface {
CreateSession(ctx context.Context, tokenHash []byte, userID string, expiresAt time.Time) error
GetUserBySession(ctx context.Context, tokenHash []byte) (domain.User, error)
DeleteSession(ctx context.Context, tokenHash []byte) error
}
type ChatRepository interface {
CreateChat(ctx context.Context, title string, memberIDs []string) (domain.Chat, error)
GetChatByID(ctx context.Context, chatID, callerID string) (domain.Chat, error)
GetChatsForUser(ctx context.Context, userID string, limit int, cursor *domain.ChatCursor) ([]domain.Chat, bool, error)
}
type IdempotentMessageWrite struct {
ActorID string
ChatID string
Text string
Method string
CanonicalPath string
Key string
RequestHash [32]byte
TTL time.Duration
}
type MessageRepository interface {
CreateMessageIdempotently(ctx context.Context, write IdempotentMessageWrite) (domain.Message, error)
GetMessages(ctx context.Context, chatID, callerID string, limit int, cursor *domain.MessageCursor) ([]domain.Message, bool, error)
}
type Repository interface {
UserRepository
SessionRepository
ChatRepository
MessageRepository
}