Permalink
Browse files

Be more flexible if we don't get a job wrapped in a list the way Stal…

…ker queues them.

If the job is malformed & doesn't have a type, bury it and move on.
Also, just look for a false-y handler when deciding we don't have one.
  • Loading branch information...
1 parent 2b7801b commit 16a46a80d1ee8987b38d8e1adbfe5dc59e8eb3c0 @ceejbot committed Mar 4, 2012
Showing with 11 additions and 4 deletions.
  1. +11 −4 lib/worker.js
View
@@ -157,10 +157,12 @@ FiveBeansWorker.prototype.doNext = function()
var job = null;
try { job = JSON.parse(payload); }
catch (e) { self.logError('error parsing JSON for job '+jobID, e); }
- if (job !== null)
+ if (!job)
+ self.buryAndMoveOn(jobID);
+ if (job instanceof Array)
self.runJob(jobID, job[1]);
else
- self.buryAndMoveOn(jobID);
+ self.runJob(jobID, job);
}
});
};
@@ -169,10 +171,15 @@ FiveBeansWorker.prototype.runJob = function(jobID, job)
{
var self = this;
var handler = this.lookupHandler(job.type);
- if (handler === null)
+ if (job.type === undefined)
+ {
+ self.logError('job id '+jobID+' has type '+job.type+'; deleting');
+ self.deleteAndMoveOn(jobID);
+ }
+ else if (!handler)
{
self.logError('no handler for job id '+jobID+' with type '+job.type);
- self.logError(JSON.stringify(job));
+ // self.logError(JSON.stringify(job));
self.buryAndMoveOn(jobID);
}
else

0 comments on commit 16a46a8

Please sign in to comment.