5 Commits

Author SHA1 Message Date
rogeecn
f9e82eba02 feat: support later funcs 2025-03-21 19:13:42 +08:00
rogeecn
661ebaf6c9 feat: add unique id to cron job 2025-03-21 16:54:26 +08:00
rogeecn
885c99ea66 feat: job cancel 2025-03-17 11:42:13 +08:00
rogeecn
24b3de2c38 feat: remove kind 2025-03-17 10:32:11 +08:00
Rogee
4bc900f387 feat: support cronjob initers 2025-03-15 21:17:12 +08:00
2 changed files with 30 additions and 5 deletions

View File

@@ -75,3 +75,18 @@ func (p Providers) Provide(config *viper.Viper) error {
} }
return nil return nil
} }
// laters for run later funcs
var later []func() error
func Later(f func() error) {
later = append(later, f)
}
func RunLaterFuncs() {
for _, f := range later {
if err := f(); err != nil {
log.Fatal(err)
}
}
}

View File

@@ -5,9 +5,19 @@ import (
) )
type CronJob interface { type CronJob interface {
Kind() string Args() []CronJobArg
Periodic() river.PeriodicSchedule }
JobArgs() river.JobArgs
InsertOpts() river.InsertOpts type JobArgs interface {
RunOnStart() bool river.JobArgs
river.JobArgsWithInsertOpts
UniqueID() string
}
type CronJobArg struct {
RunOnStart bool
PeriodicInterval river.PeriodicSchedule
Arg JobArgs
} }