golang-lib/file/worker.go

17 lines
363 B
Go
Raw Normal View History

2017-10-25 18:58:54 +02:00
package file
import (
"time"
2018-02-07 15:45:41 +01:00
"dev.sum7.eu/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
}