feat: update cronjob
This commit is contained in:
@@ -3,6 +3,7 @@ package jobs
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/riverqueue/river"
|
||||
. "github.com/riverqueue/river"
|
||||
"github.com/sirupsen/logrus"
|
||||
_ "go.ipao.vip/atom"
|
||||
@@ -16,35 +17,17 @@ type CronJob struct {
|
||||
log *logrus.Entry `inject:"false"`
|
||||
}
|
||||
|
||||
func (j *CronJob) Prepare() error {
|
||||
j.log = logrus.WithField("module", "cron")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (CronJob) Kind() string {
|
||||
return "cron_job"
|
||||
}
|
||||
|
||||
// InsertOpts implements contracts.CronJob.
|
||||
func (CronJob) InsertOpts() InsertOpts {
|
||||
return InsertOpts{
|
||||
MaxAttempts: 1,
|
||||
}
|
||||
}
|
||||
|
||||
// JobArgs implements contracts.CronJob.
|
||||
func (CronJob) JobArgs() JobArgs {
|
||||
return SortArgs{
|
||||
Strings: []string{"a", "c", "b", "d"},
|
||||
func (CronJob) Args() []contracts.CronJobArg {
|
||||
return []contracts.CronJobArg{
|
||||
{
|
||||
Arg: SortArgs{
|
||||
Strings: []string{"a", "b", "c", "d"},
|
||||
},
|
||||
|
||||
Kind: "cron_job",
|
||||
PeriodicInterval: river.PeriodicInterval(time.Second * 10),
|
||||
RunOnStart: false,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// Periodic implements contracts.CronJob.
|
||||
func (cron *CronJob) Periodic() PeriodicSchedule {
|
||||
return PeriodicInterval(time.Minute)
|
||||
}
|
||||
|
||||
// RunOnStart implements contracts.CronJob.
|
||||
func (CronJob) RunOnStart() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user