go-co-op / gocron

Easy and fluent Go cron scheduling. This is a fork from https://github.com/jasonlvhit/gocron
MIT License
5.46k stars 304 forks source link

[FEATURE] - Support for an `AtTimes` job #740

Closed rbroggi closed 2 months ago

rbroggi commented 2 months ago

Is your feature request related to a problem? Please describe

In some instances I would like to schedule future jobs to be run at specific times. Those could be totally or only partially in the future (in case of an engine restart in the middle of the schedule). For convenience reasons, it can be way easier to define an AtTimes job rather than a dedicated cron-schedule if the input from another system is a limited list of times.

Describe the solution you'd like

a new type of job that can be invoked similarly to the other, something like:

// OneTimeJob is to run a job once at a specified time and not on
// any regular schedule.
func AtTimesTimeJob(atTimes ...time.Time) JobDefinition

Describe alternatives you've considered

Multiple schedules with OneTimeJob is an alternative to the above. I find it less convenient and worse case the AtTimes should be a more generic way to implement also the OneTimeJob.

Additional context