Перенесите реализацию ЛР 4 на стенд ЛР 5
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package chat
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// ChatRepository stores chats and their membership. Membership is answered
|
||||
// by queries; the projection with members is assembled by the store in one
|
||||
// query, never by loading a member list into the entity. Members are always
|
||||
// returned ordered by id.
|
||||
type ChatRepository interface {
|
||||
// Create stores the chat row and its members atomically.
|
||||
Create(ctx context.Context, chat Chat, memberIDs []uuid.UUID) error
|
||||
// GetForMember returns the chat with members, or ErrNotFound when the
|
||||
// chat does not exist or the user is not a member.
|
||||
GetForMember(ctx context.Context, chatID, userID uuid.UUID) (ChatWithMembers, error)
|
||||
IsMember(ctx context.Context, chatID, userID uuid.UUID) (bool, error)
|
||||
// ListByMember returns up to limit chats of the user ordered by
|
||||
// (created_at, id), strictly after the chat identified by after when set.
|
||||
ListByMember(ctx context.Context, userID uuid.UUID, after *uuid.UUID, limit int) ([]ChatWithMembers, error)
|
||||
}
|
||||
|
||||
type MessageRepository interface {
|
||||
// AppendOnce stores message under the sender's key unless the key was
|
||||
// used in this chat within ttl, and returns the message the key is bound
|
||||
// to: the given one or the earlier one.
|
||||
AppendOnce(ctx context.Context, message Message, key string, ttl time.Duration) (Message, error)
|
||||
DeleteExpiredKeys(ctx context.Context, olderThan time.Duration, limit int) (int64, error)
|
||||
// ListByChat returns up to limit messages ordered by (created_at, id),
|
||||
// strictly after the message identified by after when set. An unknown
|
||||
// chat yields an empty history.
|
||||
ListByChat(ctx context.Context, chatID uuid.UUID, after *uuid.UUID, limit int) ([]Message, error)
|
||||
}
|
||||
Reference in New Issue
Block a user