New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Addition of some popular features #17
Conversation
…pport standard GNU/Linux crontabs
…dded Text field for Entry to store description
+1 |
This looks really good, thank you. Wanted to discuss two items before getting into the nitty gritty:
Thanks again for your good work! I know I'm not a very responsive maintainer, but I'll try to keep on this |
Thanks.
|
Regarding 2.. it seems like providing the Entry back to clients would be helpful so they can access the members -- them having access to the Next field doesn't seem like that big of a problem to me, and they can already get it by calling Entries() My biggest concern about this changeset is that it changes the meaning of 5-element cron specs, which would invisibly break clients. I wonder how we could avoid that.. |
Entries() returns only a snapshot(copy) of the actual Entries (Cron.entries). Modifying Entry from Entries() will not affect the Cron.entries. If Entry from Cron.entries were available to the user directly, it is possible to skip job runs. |
It looks like it may be best to handle the backwards incompatibility using gopkg.in So, importing github.com/robfig/cron can be equivalent to gopkg.in/robfig/cron.v1 , and this collection of new features can go into the v2 branch, which is imported at gopkg.in/robfig/cron.v2. That means I'll leave master at v1 Sounds ok? |
Yes, Thanks. |
Yeah, you're right that the Entry ID approach is the right one. The thing that pushed me over was that cron needs concurrent write access to Next and Prev. I also made the snapshots into values, to make it clear that they are copies and not pointers to the original. Seems ok? |
The "DST support" piece didn't work against the larger test suite. For example, it would run a 2am nightly job twice during a 2am -> 1am transition, although it does seem to fix some of the other cases. It may take me a while to figure it out. Seems complicated |
Yes, that makes it clear for the user. |
All these changes are really great. I'd love to see them merged. Thanks! |
Closing dead PR |
Seconds field is now optional and Dow field is mandatory to support standard GNU/Linux crontab format.
An optional TZ= clause (ex : TZ=Europe/London) in the beginning of cron spec to support specification of cron times in that location rather than in the local timezone
Sample usage :
c := cron.New()
c.AddFunc("TZ=Europe/London 07 21 * * *", func() { fmt.Println("Runs at 21:07 London time") }, "London test")
c.Start()
Added a function NextNTimes for Entry struct which returns next (upto) N activation times.
Added DST support and test cases from github.com/lukescott/cron feature-dst branch
Added safe Remove() and its test cases.