bamzi / jobrunner

Framework for performing work asynchronously, outside of the request flow
MIT License
1.04k stars 99 forks source link

features: add support in seconds #33

Open igzhang opened 3 years ago

igzhang commented 3 years ago

With the example

jobrunner.Schedule("* */5 * * * *", DoSomething{}) // every 5min do something

But log report err: expected exactly 5 fields, found 6.

The github.com/robfig/cron/v3 package already support it. So I support add this feature.

Code change suggest:

// runjob.go
func Schedule(spec string, job cron.Job) error {
    sched, err := cron.ParseStandard(spec)
        // change to 
       // sched, err := cron.Parse(spec)
    if err != nil {
        return err
    }
    MainCron.Schedule(sched, New(job))
    return nil
}

Thanks.