move worker to seperate package (eventually seperate binary)
This commit is contained in:
19
src/worker/worker.go
Normal file
19
src/worker/worker.go
Normal 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()
|
||||
}
|
||||
}()
|
||||
}
|
||||
Reference in New Issue
Block a user