Permalink
Browse files

Merge pull request #1 from LearnBoost/master

test
  • Loading branch information...
2 parents cac8132 + 860609a commit f0bf563083d827accfa7018f2ffd6f61e6d440eb @scinos scinos committed Sep 30, 2012
Showing with 18 additions and 8 deletions.
  1. +5 −0 History.md
  2. +1 −2 lib/queue/job.js
  3. +11 −5 lib/queue/worker.js
  4. +1 −1 package.json
View
@@ -1,4 +1,9 @@
+0.4.1 / 2012-09-25
+==================
+
+ * fix: if a job with a delay has more attempts, honor the original delay [mathrawka]
+
0.4.0 / 2012-06-28
==================
View
@@ -335,8 +335,7 @@ Job.prototype.progress = function(complete, total){
Job.prototype.delay = function(ms){
if (0 == arguments.length) return this._delay;
this._delay = ms;
- this._state = 'delayed';
- return this;
+ return this.state('delayed');
};
/**
View
@@ -85,8 +85,8 @@ Worker.prototype.error = function(err, job){
/**
* Process a failed `job`. Set's the job's state
* to "failed" unless more attempts remain, in which
- * case the job is marked as "inactive" and remains
- * in the queue.
+ * case the job is marked as "inactive" or "delayed"
+ * and remains in the queue.
*
* @param {Function} fn
* @return {Worker} for chaining
@@ -100,9 +100,15 @@ Worker.prototype.failed = function(job, err, fn){
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) {
+ if (job.delay()) {
+ job.delay(job.delay());
+ } else {
+ job.inactive();
+ }
+ } else {
+ job.failed();
+ }
self.start(fn);
});
};
View
@@ -1,6 +1,6 @@
{
"name": "kue"
- , "version": "0.4.0"
+ , "version": "0.4.1"
, "description": "Feature rich priority job queue backed by redis"
, "keywords": ["job", "queue", "worker", "redis"]
, "author": "TJ Holowaychuk <tj@learnboost.com>"

0 comments on commit f0bf563

Please sign in to comment.