You can create a worker on a single thread so that no other processes are blocked.
Note that runtime data is not updated automatically. Threads
A worker can be used to execute something regularly independent of a request/call (e.g. synchronization, ...).
Wenn mehrere Worker benötigt werden, kann man mehrere erstellen die alle in einem einzelnen (oder gemeinsamen Thread um Ressourcen zu sparen) aufgerufen werden. For example:
// create WorkerState best in global-package -> since you need access to it from everywhere to finish it
// WorkerState this chan is needed, because you need to quit the timer before you quit the application otherwise data can be lost (in cases of exclusion)
WorkerState = make(chan bool)
oneHourTicker := time.NewTicker(1 * time.Hour)
go func() {
for {
select {
case <-global.WorkerState:
fmt.Println("The 1 hour worker was canceled")
fiveMinutesTicker.Stop()
case <-oneHourTicker.C:
// add here all the scripts, where need to run every hour
fmt.Println(fmt.Sprintf("1 hour-worker has been executed -> %s", time.Now()))
}
}
}()