agenda-rest
Scheduling as a Service, based on Agenda
Assuming all job types could be thought of as REST endpoints, scheduling could be offered as a service. agenda-rest
does just that, introduce a URL, name it, agenda-rest will call it on the times that you specify.
Installation
Install agenda-rest as a global package
npm install -g agenda-rest
Usage
To launch the agenda-rest server, use the command line interface specifying the database host name and the database name
agenda-rest --dbhost localhost --dbname agenda
Command Line Interface options
Options | Description |
---|
-d, --dbname | [optional] Name of the Mongo database, default is agenda |
-h, --dbhost | [optional] Mongo instance's IP or domain name, default is localhost |
-u, --dburi | [optional] Full Mongo connection string. If specified, will override --dbhost, --dbname |
-p, --port | [optional] agenda-rest server port, default is 4040 |
-k, --key | [optional] x-api-key to be expected in headers. If not specified, access to agenda-rest server would be unauthenticated |
-t, --timeout | [optional] Timeout for request duration, default is 5000 ms |
-a, --agenda_settings | [optional] A JSON string containing additional agenda settings. For example '{ "processEvery": "30 seconds" }' |
APIs
API Documentation
API Documentation (Postman Generated) available at https://explore.postman.com/templates/4883/agenda-rest
GET /api/job
Get a list of defined jobs
POST /api/job
Defines a new category of jobs
{
name,
url,
method,
callback: {
url,
method,
headers
}
}
PUT /api/job/:jobName
Updates definition of a job category
- Method: PUT
- Data: same as POST
/api/job
DELETE /api/job/:jobName
Deletes job definition and cancels occurrences
POST /api/job/once
& POST /api/job/every
Schedule a job for single or multiple occurrences
{
name,
interval,
data: {
headers,
params,
query,
body
},
options: {
timezone,
skipImmediate
}
}
Callback, if present, would be invoked by the following object:
{
data: {
},
response
}
POST /api/job/now
Like once
and every
, though without interval
. Executes the job now.
POST /api/job/cancel
Cancels (not to be confused with 'delete') any jobs matching the query
- Method: POST
- Data: Mongo query
{
name: "foo"
}