Сделать отправку сообщения идемпотентной по Idempotency-Key с общей таблицей ключей и их чисткой
This commit is contained in:
@@ -2,6 +2,7 @@ package chat
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
@@ -23,7 +24,13 @@ type ChatRepository interface {
|
||||
}
|
||||
|
||||
type MessageRepository interface {
|
||||
Append(ctx context.Context, message Message) error
|
||||
// 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(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)
|
||||
// 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.
|
||||
|
||||
Reference in New Issue
Block a user