remove one field from internal/cron.Config (Opts)
This commit is contained in:
parent
849ee6ae36
commit
818ee39bd7
|
@ -4,14 +4,12 @@ import (
|
|||
"github.com/go-pg/pg/v10"
|
||||
"github.com/go-redis/redis/v8"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/robfig/cron/v3"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
DB *pg.DB
|
||||
Redis redis.UniversalClient
|
||||
RunOnInit bool
|
||||
Opts []cron.Option
|
||||
WorkerLimit int
|
||||
}
|
||||
|
||||
|
|
|
@ -30,12 +30,17 @@ func New(cfg *Config) (*Cron, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log := logrus.WithField("package", "internal/cron")
|
||||
c := &Cron{
|
||||
Cron: cron.New(cfg.Opts...),
|
||||
Cron: cron.New(cron.WithChain(
|
||||
cron.SkipIfStillRunning(
|
||||
cron.PrintfLogger(log),
|
||||
),
|
||||
)),
|
||||
queue: q,
|
||||
db: cfg.DB,
|
||||
runOnInit: cfg.RunOnInit,
|
||||
log: logrus.WithField("package", "internal/cron"),
|
||||
log: log,
|
||||
}
|
||||
if err := c.init(); err != nil {
|
||||
return nil, err
|
||||
|
|
8
main.go
8
main.go
|
@ -17,7 +17,6 @@ import (
|
|||
"github.com/tribalwarshelp/cron/internal/postgres"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/robfig/cron/v3"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -53,13 +52,6 @@ func main() {
|
|||
RunOnInit: envutil.GetenvBool("RUN_ON_INIT"),
|
||||
Redis: redisClient,
|
||||
WorkerLimit: envutil.GetenvInt("WORKER_LIMIT"),
|
||||
Opts: []cron.Option{
|
||||
cron.WithChain(
|
||||
cron.SkipIfStillRunning(
|
||||
cron.PrintfLogger(logrus.WithField("package", "cron")),
|
||||
),
|
||||
),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
|
|
Reference in New Issue