feat: update cronjob

This commit is contained in:
Rogee
2025-03-15 21:23:41 +08:00
parent b7fcf2c3e6
commit aeae94a7d2
4 changed files with 30 additions and 71 deletions

View File

@@ -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
}