11/*
22Package cron implements a cron spec parser and job runner.
33
4- Installation
4+ # Installation
55
66To download the specific tagged release, run:
77
8- go get github.com/robfig /cron/[email protected] .0 8+ go get github.com/fufuok /cron@v0.3 .0
99
1010Import it in your program as:
1111
12- import "github.com/robfig /cron/v3 "
12+ import "github.com/fufuok /cron"
1313
1414It requires Go 1.11 or later due to usage of Go Modules.
1515
16- Usage
16+ # Usage
1717
1818Callers may register Funcs to be invoked on a given schedule. Cron will run
1919them in their own goroutines.
@@ -36,7 +36,7 @@ them in their own goroutines.
3636 ..
3737 c.Stop() // Stop the scheduler (does not stop any jobs already running).
3838
39- CRON Expression Format
39+ # CRON Expression Format
4040
4141A cron expression represents a set of times, using 5 space-separated fields.
4242
@@ -54,7 +54,7 @@ Month and Day-of-week field values are case insensitive. "SUN", "Sun", and
5454The specific interpretation of the format is based on the Cron Wikipedia page:
5555https://en.wikipedia.org/wiki/Cron
5656
57- Alternative Formats
57+ # Alternative Formats
5858
5959Alternative Cron expression formats support other fields like seconds. You can
6060implement that by creating a custom Parser as follows.
@@ -73,7 +73,7 @@ parser you saw earlier, except that its seconds field is REQUIRED:
7373That emulates Quartz, the most popular alternative Cron schedule format:
7474http://www.quartz-scheduler.org/documentation/quartz-2.x/tutorials/crontrigger.html
7575
76- Special Characters
76+ # Special Characters
7777
7878Asterisk ( * )
7979
@@ -105,7 +105,7 @@ Question mark ( ? )
105105Question mark may be used instead of '*' for leaving either day-of-month or
106106day-of-week blank.
107107
108- Predefined schedules
108+ # Predefined schedules
109109
110110You may use one of several pre-defined schedules in place of a cron expression.
111111
@@ -117,12 +117,12 @@ You may use one of several pre-defined schedules in place of a cron expression.
117117 @daily (or @midnight) | Run once a day, midnight | 0 0 * * *
118118 @hourly | Run once an hour, beginning of hour | 0 * * * *
119119
120- Intervals
120+ # Intervals
121121
122122You may also schedule a job to execute at fixed intervals, starting at the time it's added
123123or cron is run. This is supported by formatting the cron spec like this:
124124
125- @every <duration>
125+ @every <duration>
126126
127127where "duration" is a string accepted by time.ParseDuration
128128(http://golang.org/pkg/time/#ParseDuration).
@@ -134,13 +134,13 @@ Note: The interval does not take the job runtime into account. For example,
134134if a job takes 3 minutes to run, and it is scheduled to run every 5 minutes,
135135it will have only 2 minutes of idle time between each run.
136136
137- Time zones
137+ # Time zones
138138
139139By default, all interpretation and scheduling is done in the machine's local
140140time zone (time.Local). You can specify a different time zone on construction:
141141
142- cron.New(
143- cron.WithLocation(time.UTC))
142+ cron.New(
143+ cron.WithLocation(time.UTC))
144144
145145Individual cron schedules may also override the time zone they are to be
146146interpreted in by providing an additional space-separated field at the beginning
@@ -169,7 +169,7 @@ The prefix "TZ=(TIME ZONE)" is also supported for legacy compatibility.
169169Be aware that jobs scheduled during daylight-savings leap-ahead transitions will
170170not be run!
171171
172- Job Wrappers
172+ # Job Wrappers
173173
174174A Cron runner may be configured with a chain of job wrappers to add
175175cross-cutting functionality to all submitted jobs. For example, they may be used
@@ -192,15 +192,15 @@ Install wrappers for individual jobs by explicitly wrapping them:
192192 cron.SkipIfStillRunning(logger),
193193 ).Then(job)
194194
195- Thread safety
195+ # Thread safety
196196
197197Since the Cron service runs concurrently with the calling code, some amount of
198198care must be taken to ensure proper synchronization.
199199
200200All cron methods are designed to be correctly synchronized as long as the caller
201201ensures that invocations have a clear happens-before ordering between them.
202202
203- Logging
203+ # Logging
204204
205205Cron defines a Logger interface that is a subset of the one defined in
206206github.com/go-logr/logr. It has two logging levels (Info and Error), and
@@ -216,16 +216,15 @@ Activate it with a one-off logger as follows:
216216 cron.WithLogger(
217217 cron.VerbosePrintfLogger(log.New(os.Stdout, "cron: ", log.LstdFlags))))
218218
219-
220- Implementation
219+ # Implementation
221220
222221Cron entries are stored in an array, sorted by their next activation time. Cron
223222sleeps until the next job is due to be run.
224223
225224Upon waking:
226- - it runs each entry that is active on that second
227- - it calculates the next run times for the jobs that were run
228- - it re-sorts the array of entries by next activation time.
229- - it goes to sleep until the soonest job.
225+ - it runs each entry that is active on that second
226+ - it calculates the next run times for the jobs that were run
227+ - it re-sorts the array of entries by next activation time.
228+ - it goes to sleep until the soonest job.
230229*/
231230package cron
0 commit comments