Files
Self-Service-Dashboard/src/worker/worker.go

20 lines
337 B
Go

package worker
import (
"time"
"astraltech.xyz/accountmanager/src/logging"
)
func CreateWorker(interval time.Duration, task func()) {
logging.Debugf("Creating worker that runs on a %s interval", interval.String())
go func() {
ticker := time.NewTicker(interval)
defer ticker.Stop()
for range ticker.C {
task()
}
}()
}