Merge branch 'develop'

This commit is contained in:
2016-05-10 17:31:27 -07:00
3 changed files with 12 additions and 3 deletions

View File

@@ -1,7 +1,7 @@
{ {
"name": "esqueue", "name": "esqueue",
"version": "0.2.1", "version": "0.2.2",
"description": "", "description": "Job queue, powered by Elasticsearch",
"main": "lib/index.js", "main": "lib/index.js",
"scripts": { "scripts": {
"build": "rm -rf lib && babel src --out-dir lib", "build": "rm -rf lib && babel src --out-dir lib",
@@ -11,6 +11,12 @@
"unit": "nyc --require babel-core/register mocha test/src/**" "unit": "nyc --require babel-core/register mocha test/src/**"
}, },
"author": "Joe Fleming (https://github.com/w33ble)", "author": "Joe Fleming (https://github.com/w33ble)",
"keywords": [
"job",
"queue",
"worker",
"elasticsearch"
],
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/w33ble/esqueue.git" "url": "https://github.com/w33ble/esqueue.git"

View File

@@ -36,6 +36,7 @@ export default class Job extends events.EventEmitter {
payload: this.payload, payload: this.payload,
priority: this.priority, priority: this.priority,
timeout: this.timeout, timeout: this.timeout,
process_expiration: new Date(0), // use epoch so the job query works
created_at: new Date(), created_at: new Date(),
attempts: 0, attempts: 0,
max_attempts: this.maxAttempts, max_attempts: this.maxAttempts,

View File

@@ -26,6 +26,7 @@ export default class Job extends events.EventEmitter {
this.debug = (...msg) => debug(...msg, `id: ${this.id}`); this.debug = (...msg) => debug(...msg, `id: ${this.id}`);
this._checker = false; this._checker = false;
this.debug(`Created worker for type ${this.type}`);
this._startJobPolling(); this._startJobPolling();
} }
@@ -118,7 +119,8 @@ export default class Job extends events.EventEmitter {
const workerOutput = new Promise((resolve, reject) => { const workerOutput = new Promise((resolve, reject) => {
resolve(this.workerFn.call(null, job._source.payload)); resolve(this.workerFn.call(null, job._source.payload));
setTimeout(function () { setTimeout(() => {
this.debug(`Timeout processing job ${job._id}`);
reject(new WorkerTimeoutError({ reject(new WorkerTimeoutError({
timeout: job._source.timeout, timeout: job._source.timeout,
jobId: job._id, jobId: job._id,