Permalink
Browse files

Support for delayed, retries

  • Loading branch information...
1 parent e309388 commit 5016f62348463326bd76aef3aa9531eb4b98ad08 @3rd-Eden committed Jan 17, 2012
Showing with 9 additions and 3 deletions.
  1. +9 −3 lib/queue/worker.js
View
@@ -89,14 +89,20 @@ Worker.prototype.error = function(err, job){
Worker.prototype.failed = function(job, err, fn){
var self = this;
+
events.emit(job.id, 'failed');
job.failed().error(err);
self.error(err, job);
+
job.attempt(function(error, remaining, attempts, max){
if (error) return self.error(error, job);
- remaining
- ? job.inactive()
- : job.failed();
+
+ if (!remaining) {
+ job.failed();
+ } else if (job._state !== 'delayed') {
+ job.inactive();
+ }
+
self.start(fn);
});
};

0 comments on commit 5016f62

Please sign in to comment.