UI同时暴露一组JSON接口,为UI所用。
查询作业, 例如 "GET /job/search?q=avi video":
["5", "7", "10"]
默认kue为了搜索索引所有作业数据对象,但是可以通过调用 Job#searchKeys
来自定义,来告诉kue那些作业数据的键创建索引如:
var kue = require('kue');
jobs = kue.createQueue();
jobs.create('email', {
title: 'welcome email for tj'
, to: '[email protected]'
, template: 'welcome-email'
}).searchKeys( ['to', 'title'] ).save();
你也可设置全局禁用搜索索引来优化redis内存:
var kue = require('kue');
q = kue.createQueue({
disableSearch: true
});
带状态计数当前响应,以及工作者活动时间以毫秒为单位:
{"inactiveCount":4,"completeCount":69,"activeCount":2,"failedCount":0,"workTime":20892}
通过 :id
: 获取作业
{"id":"3","type":"email","data":{"title":"welcome email for tj","to":"[email protected]","template":"welcome-email"},"priority":-10,"progress":"100","state":"complete","attempts":null,"created_at":"1309973155248","updated_at":"1309973155248","duration":"15002"}
获取 :id
的日志:
['foo', 'bar', 'baz']
获取指定 :from
到 :to
区间的作业, 例如 "/jobs/0..2", :order
可能是 "asc" 或者 "desc":
[{"id":"12","type":"email","data":{"title":"welcome email for tj","to":"[email protected]","template":"welcome-email"},"priority":-10,"progress":0,"state":"active","attempts":null,"created_at":"1309973299293","updated_at":"1309973299293"},{"id":"130","type":"email","data":{"title":"welcome email for tj","to":"[email protected]","template":"welcome-email"},"priority":-10,"progress":0,"state":"active","attempts":null,"created_at":"1309975157291","updated_at":"1309975157291"}]
同上, 受限于以下 :state
:
- active
- inactive
- failed
- complete
同上, 然而,受限于 :type
何 :state
.
删除作业 :id
:
$ curl -X DELETE http://local:3000/job/2
{"message":"job 2 removed"}
创建作业:
$ curl -H "Content-Type: application/json" -X POST -d \
'{
"type": "email",
"data": {
"title": "welcome email for tj",
"to": "[email protected]",
"template": "welcome-email"
},
"options" : {
"attempts": 5,
"priority": "high"
}
}' http://localhost:3000/job
{"message":"job 3 created"}