Skip to content

Commit

Permalink
Merge pull request #1 from LearnBoost/master
Browse files Browse the repository at this point in the history
test
  • Loading branch information
scinos committed Sep 30, 2012
2 parents cac8132 + 860609a commit f0bf563
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
5 changes: 5 additions & 0 deletions History.md
@@ -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
==================

Expand Down
3 changes: 1 addition & 2 deletions lib/queue/job.js
Expand Up @@ -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');
};

/**
Expand Down
16 changes: 11 additions & 5 deletions lib/queue/worker.js
Expand Up @@ -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
Expand All @@ -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);
});
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -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>"
Expand Down

0 comments on commit f0bf563

Please sign in to comment.