Added context.Context to stop and correctly stop metrics now

This commit is contained in:
Pablu23
2025-10-15 13:27:09 +02:00
parent f4ca559a26
commit e90c211d0f
5 changed files with 26 additions and 12 deletions

View File

@@ -1,6 +1,7 @@
package middleware
import (
"context"
"net/http"
"strings"
"sync"
@@ -37,7 +38,7 @@ func (l *Limiter) UpdateCleanupTime(new time.Duration) {
l.cleanupTicker.Reset(new)
}
func (l *Limiter) Stop() {
func (l *Limiter) Stop(ctx context.Context) {
l.stop <- struct{}{}
log.Info().Msg("Stopped Ratelimits")
}
@@ -79,7 +80,7 @@ func (l *Limiter) Manage() {
l.rwLock.Unlock()
duration := time.Since(start)
log.Debug().Str("duration", duration.String()).Int("deleted_buckets", deletedBuckets).Msg("Cleaned up Buckets")
case <- l.stop:
case <-l.stop:
return
}
}