chore: lab import lab4 backend and infrastructure as baseline

This commit is contained in:
Голиков Maximillian Антон
2026-11-06 20:21:23 +03:00
parent 276dbdad8a
commit 4bba40d098
68 changed files with 5315 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
package domain
import (
"context"
"time"
)
type UserRepository interface {
Create(ctx context.Context, user *User) error
GetByID(ctx context.Context, id string) (*User, error)
GetByUsername(ctx context.Context, username string) (*User, error)
}
type ChatRepository interface {
Create(ctx context.Context, chat *Chat) error
GetByID(ctx context.Context, id string) (*Chat, error)
ListByMember(ctx context.Context, userID string, limit int, cursor *string) ([]Chat, *string, error)
}
type MessageRepository interface {
Create(ctx context.Context, message *Message) error
ListByChat(ctx context.Context, chatID string, limit int, cursor *string) ([]Message, *string, error)
CreateIdempotent(
ctx context.Context,
scope IdempotencyScope,
requestHash []byte,
fresh *Message,
freshResponse []byte,
ttl time.Duration,
) (*CreateIdempotentResult, error)
}
type SessionRepository interface {
Create(ctx context.Context, session *Session) error
GetByTokenHash(ctx context.Context, tokenHash []byte) (*Session, error)
DeleteByTokenHash(ctx context.Context, tokenHash []byte) error
}
type AttachmentRepository interface {
Create(ctx context.Context, a *Attachment) error
GetByID(ctx context.Context, id string) (*Attachment, error)
MarkReady(ctx context.Context, id string) error
MarkFailed(ctx context.Context, id string, errorCode string) error
ListStalePending(ctx context.Context, olderThan time.Time, limit int) ([]Attachment, error)
ExistingKeys(ctx context.Context, keys []string) ([]string, error)
DeletePending(ctx context.Context, id string) error
}