Skip to content

Commit

Permalink
Implemented redis portion of Job.attempts(n)
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Jul 7, 2011
1 parent 003cc1c commit ef1aa4b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 0 additions & 1 deletion lib/http/public/javascripts/job.js
Expand Up @@ -187,7 +187,6 @@ Job.prototype.renderUpdate = function(){

// attempts
if (this.attempts.made) {
console.log(this.attempts);
view.attempts(this.attempts.made + '/' + this.attempts.max);
} else {
view.attempts().remove();
Expand Down
4 changes: 3 additions & 1 deletion lib/queue/job.js
Expand Up @@ -451,6 +451,7 @@ Job.prototype.active = function(){
Job.prototype.save = function(fn){
var client = this.client
, fn = fn || noop
, max = this._max_attempts
, self = this;

// update
Expand All @@ -459,9 +460,10 @@ Job.prototype.save = function(fn){
// incr id
client.incr('q:ids', function(err, id){
if (err) return fn(err);
var key = 'q:job:' + id;
self.id = id;
self.state = 'inactive';
client.hset('q:job:' + id, 'max_attempts', this._max_attempts);
if (max) client.hset(key, 'max_attempts', max);
client.sadd('q:job:types', self.type);
self.set('type', self.type);
self.set('created_at', Date.now());
Expand Down

0 comments on commit ef1aa4b

Please sign in to comment.