2017-10-25 18:58:54 +02:00
|
|
|
package file
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
2023-10-23 21:40:10 +02:00
|
|
|
"codeberg.org/genofire/golang-lib/worker"
|
2017-10-25 18:58:54 +02:00
|
|
|
)
|
|
|
|
|
2018-08-23 21:02:51 +02:00
|
|
|
// NewSaveJSONWorker Starts a worker, which save periodly data to json file
|
2017-10-25 18:58:54 +02:00
|
|
|
func NewSaveJSONWorker(repeat time.Duration, path string, data interface{}) *worker.Worker {
|
|
|
|
saveWorker := worker.NewWorker(repeat, func() {
|
|
|
|
SaveJSON(path, data)
|
|
|
|
})
|
2018-03-22 22:10:05 +01:00
|
|
|
saveWorker.Start()
|
2017-10-25 18:58:54 +02:00
|
|
|
return saveWorker
|
|
|
|
}
|