An implementation of delayed tasks.
$ git clone https://github.com/rosbit/delay-tasks
$ cd delay-tasks
$ makeAn executable delay-tasks will be generated. Run it like the following:
$ CONF_FILE=./sample.conf.json ./delay-tasksPOST /handler/:cate
Body:
{"handler": "a http url"}Response
{ "code": 200, "msg": "OK" }A handler must be implemented as an endpoint satisfy the following:
- method: POST
- BODY: a JSON, see params detail in Create/Update task.
{ "cate": "task category", "key": uint64, // task key in the category"params": JSON, // params when adding task"inAdvance": false|true // whether the task is run in advance. }
POST /task/:cate
Body:
{ "timestamp": in-seconds,"key": uint64,"params": {anything}, "handler": "using caterory handler if it is blank" }Response
{ "code": 200, "msg": "OK" }
DELETE /task/:cate
Body:
{ "timestamp": in-seconds,"key": uint64, "exec": true|false // executing task before being removed if true. }Response
{ "code": 200, "msg": "OK" }
GET /task/:cate/:key[?timestamp=xxx]
Response
{ "code": 200, "msg": "OK", "result": { "timeToRun": xxxx,"params": {JSON}, "handler": "http://handler" } }
- GET /tasks
- Result will be dumped as Response.
