Исправить замечания ревью кода: убрать повтор в AppendOnce за счёт запаса у чистки ключей, вынести MessagePayload и SameContent, принять X-Request-Id от балансировщика, упростить фоновые задачи сервера, сократить комментарии

This commit is contained in:
2026-11-04 12:19:49 +03:00
parent c9d0f73221
commit 7fbd781ca3
25 changed files with 207 additions and 247 deletions
+4 -6
View File
@@ -24,13 +24,11 @@ type ChatRepository interface {
}
type MessageRepository interface {
// AppendOnce stores message under the sender's key in its chat, unless
// the key was used there within ttl; it returns the message the key is
// bound to: the given one or the earlier one.
// 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 removes up to limit keys older than ttl and reports
// how many it removed.
DeleteExpiredKeys(ctx context.Context, ttl time.Duration, limit int) (int64, 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.