Abstract the cleanup logic and add helper for cache valid.

This commit is contained in:
2025-02-24 12:02:12 +00:00
parent 2743b0e024
commit 0f8b7f7ab1
3 changed files with 25 additions and 23 deletions
+18
View File
@@ -0,0 +1,18 @@
package traefikoidc
import "time"
// autoCleanupRoutine runs a ticker that calls the provided cleanup function at the specified interval.
// It stops when a value is received on the stop channel.
func autoCleanupRoutine(interval time.Duration, stop <-chan struct{}, cleanup func()) {
ticker := time.NewTicker(interval)
defer ticker.Stop()
for {
select {
case <-ticker.C:
cleanup()
case <-stop:
return
}
}
}