fix worker example
add example of async worker
This commit is contained in:
16
readme.md
16
readme.md
@@ -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.
|
The worker's `output` can either be the raw output from the job, or on object that specifies the output's content type.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
var workerFn1 = function (payload, cb) {
|
var workerFn1 = function (payload) {
|
||||||
// Do some work, using the payload if required
|
// Do some work, using the payload if required
|
||||||
var output = new Date().toString();
|
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
|
// Do some work, using the payload if required
|
||||||
var output = {
|
var output = {
|
||||||
content_type: 'text/plain',
|
content_type: 'text/plain',
|
||||||
content: new Date().toString();
|
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();
|
||||||
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user