added Cron.Jobs() method

This commit is contained in:
Gani Georgiev
2024-12-22 16:05:38 +02:00
parent f27d9f1dc9
commit bae5421d62
5 changed files with 163 additions and 22 deletions

25
tools/cron/job.go Normal file
View File

@@ -0,0 +1,25 @@
package cron
// Job defines a single registered cron job.
type Job struct {
fn func()
schedule *Schedule
id string
}
// Id returns the cron job id.
func (j *Job) Id() string {
return j.id
}
// Expr returns the plain cron job schedule expression.
func (j *Job) Expr() string {
return j.schedule.rawExpr
}
// Run runs the cron job function.
func (j *Job) Run() {
if j.fn != nil {
j.fn()
}
}