Comparing version 0.1.2 to 0.1.3
@@ -38,2 +38,3 @@ var $__Object = Object, $__getOwnPropertyNames = $__Object.getOwnPropertyNames, $__getOwnPropertyDescriptor = $__Object.getOwnPropertyDescriptor, $__getDescriptors = function(object) { | ||
var RELEASE_DELAY = ms('1m'); | ||
var ERROR_BACKOFF = ms('30s'); | ||
module.exports = (function() { | ||
@@ -136,3 +137,3 @@ 'use strict'; | ||
var timeout = setTimeout((function() { | ||
oncomplete(new Error('TIMED_OUT')); | ||
oncomplete('TIMED_OUT'); | ||
}), TIMEOUT_REQUEST); | ||
@@ -155,3 +156,3 @@ this._withClient(function(client) { | ||
var oncomplete; | ||
while (oncomplete = pending.shift()) oncomplete(new Error('TIMED_OUT')); | ||
while (oncomplete = pending.shift()) oncomplete('TIMED_OUT'); | ||
})); | ||
@@ -266,5 +267,5 @@ }, | ||
this._getSession.request('reserve_with_timeout', 0, (function(error, jobID, payload) { | ||
if (error == 'TIMED_OUT') callback(null, false); else if (error) callback(error); else this._processJob(jobID, payload, function(error) { | ||
if (error == 'TIMED_OUT') callback(null, false); else if (error) callback(error); else if (payload) this._processJob(jobID, payload, function(error) { | ||
callback(error, !error); | ||
}); | ||
}); else callback(null, false); | ||
}).bind(this)); | ||
@@ -278,3 +279,3 @@ }, | ||
this._logger.error(error); | ||
setImmediate(pickNextJob); | ||
setTimeout(pickNextJob, ERROR_BACKOFF); | ||
} else this._processContinously(jobID, payload, pickNextJob); | ||
@@ -281,0 +282,0 @@ }).bind(this)); |
{ | ||
"name": "ironium", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"scripts": { | ||
@@ -5,0 +5,0 @@ "test": "./node_modules/.bin/mocha", |
@@ -26,4 +26,8 @@ const _ = require('lodash'); | ||
// Back-off in case of connection error, prevents continously failing to | ||
// reserve a job. | ||
const ERROR_BACKOFF = ms('30s'); | ||
// Abstracts an Iron.io project / Beanstalkd configuration. | ||
@@ -184,3 +188,3 @@ // | ||
let timeout = setTimeout(()=> { | ||
oncomplete(new Error('TIMED_OUT')); | ||
oncomplete('TIMED_OUT'); | ||
}, TIMEOUT_REQUEST); | ||
@@ -211,3 +215,3 @@ // Get Fivebeans to execute this command. | ||
while (oncomplete = pending.shift()) | ||
oncomplete(new Error('TIMED_OUT')); | ||
oncomplete('TIMED_OUT'); | ||
}); | ||
@@ -376,6 +380,8 @@ } | ||
callback(error); | ||
else | ||
else if (payload) | ||
this._processJob(jobID, payload, function(error) { | ||
callback(error, !error); | ||
}); | ||
else | ||
callback(null, false); | ||
}); | ||
@@ -397,3 +403,3 @@ } | ||
this._logger.error(error) | ||
setImmediate(pickNextJob); | ||
setTimeout(pickNextJob, ERROR_BACKOFF); | ||
} else | ||
@@ -400,0 +406,0 @@ this._processContinously(jobID, payload, pickNextJob); |
46204
1157