Сделать отправку сообщения идемпотентной по Idempotency-Key с общей таблицей ключей и их чисткой

This commit is contained in:
2026-11-02 17:11:04 +03:00
parent 7fa8881eb3
commit 951fd0d517
19 changed files with 856 additions and 40 deletions
+8 -1
View File
@@ -50,9 +50,16 @@ type Deps struct {
// request that gives up on a dependency can still write its 503.
const defaultRequestTimeout = 5 * time.Second
// defaultIdempotencyTTL is the contract's retention of message keys.
const defaultIdempotencyTTL = 24 * time.Hour
func New(d Deps) *App {
users := user.NewService(userstore.NewUsers(d.DB))
chats := chat.NewService(chatstore.NewChats(d.DB), chatstore.NewMessages(d.DB), users)
keyTTL := d.IdempotencyTTL
if keyTTL == 0 {
keyTTL = defaultIdempotencyTTL
}
chats := chat.NewService(chatstore.NewChats(d.DB), chatstore.NewMessages(d.DB), users, keyTTL)
engine := httpx.NewEngine(d.Log, d.MaxBodyBytes, d.InstanceID)
probes := health.New(