feat(idempotency): purge expired keys
This commit is contained in:
+8
-5
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user