Skip to content

rosbit/delay-tasks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

delay-tasks

An implementation of delayed tasks.

diag-1

Usage

$ git clone https://github.com/rosbit/delay-tasks
$ cd delay-tasks
$ make

An executable delay-tasks will be generated. Run it like the following:

$ CONF_FILE=./sample.conf.json ./delay-tasks

API

1. Register category handler

  • POST /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.
      }

2. Create/Update a delayed task in a category

  • POST /task/:cate

  • Body:

    {
      "timestamp": in-seconds,
      "key": uint64,
      "params": {anything},
      "handler": "using caterory handler if it is blank"
    }
  • Response

    {
       "code": 200,
       "msg": "OK"
    }

3. Remove a delayed task in a category

  • DELETE /task/:cate

  • Body:

    {
       "timestamp": in-seconds,
       "key": uint64, 
       "exec": true|false // executing task before being removed if true.
    }
  • Response

    {
       "code": 200,
       "msg": "OK"
    }

4. Get task

  • GET /task/:cate/:key[?timestamp=xxx]

  • Response

    {
       "code": 200,
       "msg": "OK",
       "result": {
          "timeToRun": xxxx,
          "params": {JSON},
          "handler": "http://handler"
       }
    }

5. List tasks

  • GET /tasks
  • Result will be dumped as Response.

About

a delayed tasks implementation

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published