2024-03-26 11:44:19 +00:00
|
|
|
package background
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"git.fjla.uk/owlboard/timetable-mgr/cif"
|
2024-03-26 22:33:11 +00:00
|
|
|
"git.fjla.uk/owlboard/timetable-mgr/corpus"
|
2024-03-26 11:44:19 +00:00
|
|
|
"git.fjla.uk/owlboard/timetable-mgr/helpers"
|
|
|
|
"git.fjla.uk/owlboard/timetable-mgr/log"
|
|
|
|
)
|
|
|
|
|
2024-03-26 22:33:11 +00:00
|
|
|
const frequency = 3 * time.Second // Figure out a sensible frequency!
|
2024-03-26 11:44:19 +00:00
|
|
|
|
|
|
|
func InitTicker(cfg *helpers.Configuration, stop <-chan struct{}) {
|
|
|
|
go runTicker(cfg, stop)
|
|
|
|
}
|
|
|
|
|
|
|
|
func runTicker(cfg *helpers.Configuration, stop <-chan struct{}) {
|
|
|
|
log.Msg.Sugar().Infof("Starting background ticker, runs every %s", frequency)
|
|
|
|
ticker := time.NewTicker(frequency)
|
|
|
|
defer ticker.Stop()
|
|
|
|
|
|
|
|
for {
|
|
|
|
select {
|
|
|
|
case <-stop:
|
|
|
|
return
|
|
|
|
case <-ticker.C:
|
2024-03-26 22:33:11 +00:00
|
|
|
go cif.CifCheck(cfg)
|
|
|
|
go corpus.CheckCorpus(cfg)
|
2024-03-26 11:44:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|