Golang Model for Cycle Scheduler
GoCycleSchedulerModel currently supports four cycle scheduler(Never Stop) type as below:
- Week: Execute task once a week and start either this week or next week
- Day: Execute task every day and start either today or tomorrow
- Hour: Execute task every hour and start one hour later
- Minute: Execute task every minute and start one minute later
mkdir -p /data/go/src
export GOPATH=/data/go
mkdir /data/duyanghao
cd /data/duyanghao
git clone https://github.com/duyanghao/GoCycleSchedulerModel.git
cd /data/duyanghao/GoCycleSchedulerModel
ln -s $PWD/Scheduler $GOPATH/src/Scheduler
export GOPATH=$PWD:$GOPATH
go build
Example schedule
string:
R2/2017-06-04T19:25:16.828696-07:00/PT10S
This string can be split into three parts:
Number of times to repeat/Start Datetime/Interval Between Runs
This is designated with a number, prefixed with an R
. Leave out the number if it should repeat forever.
Examples:
R
- Will repeat foreverR1
- Will repeat onceR231
- Will repeat 231 times.
This is the datetime for the first time the job should run.
Kala will return an error if the start datetime has already passed.
Examples:
2017-06-04T19:25:16
2017-06-04T19:25:16.828696
2017-06-04T19:25:16.828696-07:00
2017-06-04T19:25:16-07:00
To Note: It is recommended to include a timezone within your schedule parameter.
This is defined by the ISO8601 Interval Notation.
It starts with a P
, then you can specify years, months, or days, then a T
, preceded by hours, minutes, and seconds.
Lets break down a long interval: P1Y2M10DT2H30M15S
P
- Starts the notation1Y
- One year2M
- Two months10D
- Ten daysT
- Starts the time second2H
- Two hours30M
- Thirty minutes15S
- Fifteen seconds
Now, there is one alternative. You can optionally use just weeks. When you use the week operator, you only get that. An example of using the week operator for an interval of every two weeks is P2W
.
Examples:
P1DT1M
- Interval of one day and one minuteP1W
- Interval of one weekPT1H
- Interval of one hour.