- All the flexibility and power of Cron as a Service.
- Simple REST protocol, integrating with a web application in a easy and straightforward way.
- No more wasting time building and managing scheduling infrastructure.
Crony works by calling back to your application via HTTP GET according to a schedule constructed by you or your application.
Env vars
export DATASTORE_URL="postgresql://postgres@localhost/crony?sslmode=disable"
export PORT=3000
mkdir -p $GOPATH/src/github.com/rafaeljesus
cd $GOPATH/src/github.com/rafaeljesus
git clone https://github.com/rafaeljesus/crony.git
cd crony
make all
./dist/crony
# => Starting Crony at port 3000
This API does not ship with an authentication layer. You should not expose the API to the Internet. This API should be deployed behind a firewall, only your application servers should be allowed to send requests to the API.
GET
/health - Get application healthGET
/events - Get a list of scheduled eventsPOST
/events - Create a eventGET
/events/:id - Get a single eventDELETE
/events/:id - Delete a eventPATCH
/events/:id - Update a event
Get a list of available events.
- Method:
GET
- Endpoint:
/events
- Responses:
- 200 OK
[ { "id":1, "url":"your-api/job", "expression": "0 5 * * * *", "status": "active", "max_retries": 2, "retry_timeout": 3, "created_at": "2016-12-10T14:02:37.064641296-02:00", "updated_at": "2016-12-10T14:02:37.064641296-02:00" } ]
id
is the id of the event.url
: is the url callback to called.expression
: is cron expression format.status
: tell if the event is active or paused.max_retries
: the number of attempts to send event.retry_timeout
: is the retry timeout.
Create a new event.
-
Method:
POST
-
Endpoint:
/events
-
Input: The
Content-Type
HTTP header should be set toapplication/json
{ "url":"your-api/job", "expression": "0 5 * * * *", "status": "active", "max_retries": 2, "retry_timeout": 3, }
-
Responses:
- 201 Created
{ "url":"your-api/job", "expression": "0 5 * * * *", "status": "active", "max_retries": 2, "retry_timeout": 3, "updated_at": "2016-12-10T14:02:37.064641296-02:00", "created_at": "2016-12-10T14:02:37.064641296-02:00" }
- 422 Unprocessable entity:
{ "status":"invalid_event", "message":"<reason>" }
- 400 Bad Request
{ "status":"invalid_json", "message":"Cannot decode the given JSON payload" }
Common reasons:
- the event job already scheduled. The
message
will beEvent already exists
- the expression must be crontab format.
- the retry must be between
0
and10
- the status must be
active
orincative
Get a specific event.
- Method:
GET
- Endpoint:
/events/:id
- Responses:
- 200 OK
{ "url":"your-api/job", "expression": "0 5 * * * *", "status": "active", "max_retries": 2, "retry_timeout": 3, "updated_at": "2016-12-10T14:02:37.064641296-02:00", "created_at": "2016-12-10T14:02:37.064641296-02:00" }
- 404 Not Found
{ "status":"event_not_found", "message":"The event was not found" }
Remove a scheduled event.
- Method:
DELETE
- Endpoint:
/events/:id
- Responses:
- 200 OK
{ "status":"event_deleted", "message":"The event was successfully deleted" }
- 404 Not Found
{ "status":"event_not_found", "message":"The event was not found" }
Update a event.
-
Method:
PATCH
-
Endpoint:
/events/:id
-
Input: The
Content-Type
HTTP header should be set toapplication/json
{ "expression": "0 2 * * * *" }
-
Responses:
- 200 OK
{ "url":"your-api/job", "expression": "0 2 * * * *", "status": "active", "max_retries": 2, "retry_timeout": 3, "updated_at": "2016-12-10T14:02:37.064641296-02:00", "created_at": "2016-12-10T14:02:37.064641296-02:00" }
- 404 Not Found
{ "status":"event_not_found", "message":"The event was not found" }
- 422 Unprocessable entity:
{ "status":"invalid_json", "message":"Cannot decode the given JSON payload" }
- 400 Bad Request
{ "status":"invalid_event", "message":"<reason>" }
The cron expression format allowed is:
Field name | Mandatory? | Allowed values | Allowed special characters |
---|---|---|---|
Seconds | Yes | 0-59 | * / , - |
Minutes | Yes | 0-59 | * / , - |
Hours | Yes | 0-23 | * / , - |
Day of month | Yes | 1-31 | * / , - ? |
Month | Yes | 1-12 or JAN-DEC | * / , - |
Day of week | Yes | 0-6 or SUN-SAT | * / , - ? |
more details about expression format here |
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request