fix worker example

add example of async worker
This commit is contained in:
2016-06-06 15:06:30 -07:00
parent 5fe4e644d6
commit 1c24a4f7c1

View File

@@ -109,19 +109,27 @@ size | `10` | Number of records to return when polling for new jobs. Higher valu
The worker's `output` can either be the raw output from the job, or on object that specifies the output's content type.
```js
var workerFn1 = function (payload, cb) {
var workerFn1 = function (payload) {
// Do some work, using the payload if required
var output = new Date().toString();
cb(null, output);
return output;
};
var workerFn2 = function (payload, cb) {
var workerFn2 = function (payload) {
// Do some work, using the payload if required
var output = {
content_type: 'text/plain',
content: new Date().toString();
};
cb(null, output);
return output;
};
var asyncWorker = function (payload) {
// Do some work, using the payload if required
return Promise.resolve({
content_type: 'text/plain',
content: new Date().toString();
})
};
```