feat(idempotency): purge expired keys

This commit is contained in:
kk10
2026-10-17 11:50:31 +03:00
parent 17ad9b691f
commit 59b06f5ec7
5 changed files with 61 additions and 5 deletions
+8 -5
View File
@@ -5,6 +5,7 @@ import (
"net/http"
"os"
"os/signal"
"sync"
"syscall"
"time"
@@ -63,14 +64,16 @@ func Run() error {
log.Info("session store configured", "store", cfg.SessionStore)
cleanupCtx, stopCleanup := context.WithCancel(context.Background())
cleanupDone := make(chan struct{})
go func() {
defer close(cleanupDone)
var cleanupWG sync.WaitGroup
cleanupWG.Go(func() {
runSessionCleanup(cleanupCtx, log, queries, sessionCleanupInterval)
}()
})
cleanupWG.Go(func() {
runIdempotencyCleanup(cleanupCtx, log, queries, cfg.Server.IdempotencyTTL, idempotencyCleanupInterval)
})
defer func() {
stopCleanup()
<-cleanupDone
cleanupWG.Wait()
}()
authService := service.NewAuthService(queries, rdb, cfg.Server.SessionTTL, log)