move worker to seperate package (eventually seperate binary)

This commit is contained in:
2026-04-01 09:28:56 -04:00
parent c9c352204c
commit a058804603
2 changed files with 4 additions and 3 deletions

19
src/worker/worker.go Normal file
View File

@@ -0,0 +1,19 @@
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()
}
}()
}