reugn / go-quartz

Minimalist and zero-dependency scheduling library for Go
https://pkg.go.dev/github.com/reugn/go-quartz/quartz
MIT License
1.79k stars 84 forks source link

RunOnceTrigger cannot be properly unmarshalled #118

Closed anshul-raman closed 8 months ago

anshul-raman commented 8 months ago

Expected Behaviour: When using runOnceTrigger the job should fire after the given delay and expire immediately.

Current behaviour: When using runOnceTrigger with the delay of 5secs, the job is never expired.

Steps to reproduce: Use the following code to schedule the job in the jobQueue example given in the repository.

if err := scheduler.ScheduleJob(jobDetail1, quartz.NewRunOnceTrigger(5*time.Second)); err != nil {
    logger.Warnf("Failed to schedule job: %s", jobDetail1.JobKey())
}

Possible Cause: The RunOnceTrigger has the expired field as private, because of which we cannot create expired RunOnceTriggers. When using persistent storage, the user needs to serialise and recreate the trigger. Allowing users to create expired RunOnceTrigger can solve the problem.

reugn commented 8 months ago

@anshul-raman, PR #120 exports the expired field, to allow proper decoding of the trigger.