This repository has been archived on 2022-09-04. You can view files and clone it, but cannot push or open issues or pull requests.
2021-04-27 16:30:12 +00:00
|
|
|
package cron
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/go-pg/pg/v10"
|
|
|
|
"github.com/pkg/errors"
|
2021-07-11 07:25:12 +00:00
|
|
|
|
2021-07-11 09:37:39 +00:00
|
|
|
"github.com/tribalwarshelp/dataupdater/pkg/queue"
|
2021-04-27 16:30:12 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type Config struct {
|
2021-07-11 07:25:12 +00:00
|
|
|
DB *pg.DB
|
|
|
|
Queue *queue.Queue
|
|
|
|
RunOnInit bool
|
2021-04-27 16:30:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func validateConfig(cfg *Config) error {
|
|
|
|
if cfg == nil || cfg.DB == nil {
|
2021-05-14 12:57:05 +00:00
|
|
|
return errors.New("cfg.DB is required")
|
2021-04-27 16:30:12 +00:00
|
|
|
}
|
2021-07-11 07:25:12 +00:00
|
|
|
if cfg.Queue == nil {
|
|
|
|
return errors.New("cfg.Queue is required")
|
2021-04-27 16:30:12 +00:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|