Skip to content

Commit

Permalink
Merge pull request #159 from taskrabbit/no-multi-commands
Browse files Browse the repository at this point in the history
update worker untrack commands to work across cluster (no multi)
  • Loading branch information
evantahler authored Sep 4, 2016
2 parents e6dbf27 + ad89f59 commit 35b1590
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,8 @@ worker.prototype.track = function(callback){

worker.prototype.untrack = function(name, queues, callback){
var self = this;
var jobs = [];

if(self.connection && self.connection.redis){
self.connection.redis.srem(self.connection.key('workers'), (name + ':' + queues), function(error){
if(error){
Expand All @@ -383,12 +385,16 @@ worker.prototype.untrack = function(name, queues, callback){
return;
}

self.connection.redis.del([
[
self.connection.key('worker', name, self.stringQueues()),
self.connection.key('worker', name, self.stringQueues(), 'started'),
self.connection.key('stat', 'failed', name),
self.connection.key('stat', 'processed', name)
], function(error){
].forEach(function(key){
jobs.push(function(done){ self.connection.redis.del(key, done); });
});

async.series(jobs, function(error){
if(error){ self.emit('error', null, null, error); }
if(typeof callback === 'function'){ callback(error); }
});
Expand Down

0 comments on commit 35b1590

Please sign in to comment.