Permalink
Browse files

merge small fix PRs

  • Loading branch information...
1 parent 206aead commit e9667a9ba4437dba1fd6370361acea8b68cabf2d @behrad behrad committed Jan 31, 2014
Showing with 10 additions and 11 deletions.
  1. +9 −11 lib/queue/job.js
  2. +1 −0 lib/queue/worker.js
View
20 lib/queue/job.js
@@ -436,9 +436,7 @@ Job.prototype.remove = function (fn) {
// events.remove(this);
fn && fn(err);
if( !exports.disableSearch ){
- getSearch().remove(this.id, function(){
- console.log( "remove index...");
- }.bind( this ));
+ getSearch().remove(this.id);
}
// }.bind(this));
}.bind(this));
@@ -478,7 +476,8 @@ Job.prototype.removeState = function (fn) {
*/
Job.prototype.state = function (state, fn) {
- var client = this.client;
+ var client = this.client
+ , fn = fn || noop;
this.removeState(function () {
this._state = state;
// console.log( "setState(%d) Start ", this.id, state, this._state );
@@ -507,14 +506,15 @@ Job.prototype.state = function (state, fn) {
*/
Job.prototype.error = function (err) {
+ var str, summary;
if (0 == arguments.length) return this._error;
if ('string' == typeof err) {
- var str = err
- , summary = '';
+ str = err;
+ summary = '';
} else {
- var str = err.stack || err.message
- , summary = str.split('\n')[0];
+ str = err.stack || err.message;
+ summary = str ? str.split('\n')[0] : '';
}
this.set('failed_at', Date.now());
@@ -631,9 +631,7 @@ Job.prototype.update = function (fn) {
}.bind(this));
if( !exports.disableSearch ) {
- getSearch().index(json, this.id, function(){
- //console.log( "add index..."); // leaving this in causes a ton of logging to happen.
- }.bind(this));
+ getSearch().index(json, this.id);
}
};
View
1 lib/queue/worker.js
@@ -232,6 +232,7 @@ Worker.prototype.getJob = function (fn) {
|| (clients[self.type] = redis.createClient());
if (!self.running) {
+ //TODO add&test with return
fn("Already Shutdown");
}
// BLPOP indicates we have a new inactive job to process

0 comments on commit e9667a9

Please sign in to comment.