Code Review Request: Cron library for Go

548 views
Skip to first unread message

robfig

unread,
Jul 20, 2012, 9:48:27 PM7/20/12
to golan...@googlegroups.com
Hello,

I wrote a library for running jobs using Cron specs.  It is not much code and it comes with a test suite, so I'm pretty confident that it works.  However, I was wondering if any experienced gophers were interested in providing a code review.  

Parts to highlight in particular:
- how it provides synchronized access to cron job entries
- generally, the structure of the cron scheduling loop
 -- is it idiomatic to provide concurrent access to state by performing a request/response on an unbuffered channel and servicing that with a select loop?  (I am generally concerned about possibility for deadlock when using this approach)


Any comments / suggestions for improving it are welcome.

Thanks in advance!
-Rob

roger peppe

unread,
Jul 23, 2012, 12:02:09 PM7/23/12
to robfig, golan...@googlegroups.com
On 21 July 2012 02:48, robfig <rob...@gmail.com> wrote:
> https://github.com/robfig/cron
>
> Any comments / suggestions for improving it are welcome.

From a 5 second glance at the docs, the boilerplate suggestion
applies: follow the Go guidelines on documentation.

1) Document all methods
2) Method and function docs should start with the function name
being documented. For instance, instead of "Returns a new crontab schedule",
you should say "Parse returns a new ...".
3) Don't export implementation details (e.g. STAR_BIT)

robfig

unread,
Jul 23, 2012, 10:09:45 PM7/23/12
to golan...@googlegroups.com
Ah, I didn't realize there was a particular comment format.  I've made the changes you suggested and doc'ed everything.

Thanks!
-Rob

Dennis Francis

unread,
Nov 7, 2014, 1:59:38 PM11/7/14
to golan...@googlegroups.com

Hi Rob/All


I have forked the github.com/robfig/cron repository @ https://github.com/dennisfrancis/cron and added the following popular features and also created a pull request.

1) Seconds field is now optional and Dow field is mandatory to support standard GNU/Linux crontab format.

2) An optional TZ=<Location> 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()

3) Added a function NextNTimes for Entry struct which returns next (upto) N activation times.

4) Added DST support and test cases from github.com/lukescott/cron feature-dst branch

5) Added safe Remove() and its test cases.

6) Added a field called Text to Entry to store description about the entry.

Documentation at http://godoc.org/github.com/dennisfrancis/cron

Thanks,
Dennis
Reply all
Reply to author
Forward
0 new messages