go-co-op / gocron

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

[FEATURE] - Exposing job definition/scheduling information #746

Open chicknsoup opened 2 months ago

chicknsoup commented 2 months ago

Is your feature request related to a problem? Please describe

I want to list out all scheduled jobs with detailed definition (job type, scheduling intervals, last run, next runs, etc..) like in version v1

Describe the solution you'd like

It would be nice to expose internalJob information via Job structure.

JohnRoesler commented 2 months ago

Hi @chicknsoup that information could be added to the public Job structure and populated from the internal job when passed to the caller.

chicknsoup commented 2 months ago

Hi @chicknsoup that information could be added to the public Job structure and populated from the internal job when passed to the caller.

Can I have an example, please? Thank you.

JohnRoesler commented 2 months ago
  1. add the fields to the job struct -> https://github.com/go-co-op/gocron/blob/212db8e476f266016cb0279ca06794a96ffaf3c7/job.go#L947-L959
  2. add methods to the Job interface to return that information -> https://github.com/go-co-op/gocron/blob/212db8e476f266016cb0279ca06794a96ffaf3c7/job.go#L926-L945
  3. pass the information from the internalJob to the job struct -> https://github.com/go-co-op/gocron/blob/9d27ea867351b4a2f945b1ab2409a461110b844e/scheduler.go#L500-L508
chicknsoup commented 1 month ago

Thanks, but there are different types of jobs (cronJob, durationJob, dailyJob, weeklyJob, etc.) and I'm wondering about how to expose their definition via a single method as they have different fields.

JohnRoesler commented 1 month ago

@chicknsoup that's a good point. I'm giving it some thought. Initial reaction, we have some enum type that denotes the job type. And then perhaps an interface that stores the different job schedules...hm.