52 lines
1.6 KiB
Go
52 lines
1.6 KiB
Go
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
|
|
}
|
|
|
|
type OutboxRepository interface {
|
|
Enqueue(ctx context.Context, tx Tx, e *OutboxEntry) error
|
|
}
|