Skip to content

Commit

Permalink
Fixed #572
Browse files Browse the repository at this point in the history
  • Loading branch information
manast committed Dec 6, 2017
1 parent 5fcd4b7 commit c1213d0
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/queue.js
Expand Up @@ -234,7 +234,9 @@ function redisClientGetter(queue, options, initCallback) {
return function() { // getter function
if (connections[type] != null) return connections[type];
var client = connections[type] = createClient(type, options.redis);
queue.clients.push(client);
if(!options.createClient){
queue.clients.push(client);
}
return initCallback(type, client), client;
};
};
Expand Down
32 changes: 32 additions & 0 deletions test/test_connection.js
Expand Up @@ -71,4 +71,36 @@ describe('connection', function () {
});
});

it('should not close external connections', function () {

var client = new redis();
var subscriber = new redis();

var opts = {
createClient: function(type){
switch(type){
case 'client':
return client;
case 'subscriber':
return subscriber;
default:
return new redis();
}
}
};

var testQueue = utils.buildQueue('external connections', opts);

return testQueue.isReady().then(function(){
return testQueue.add({'foo': 'bar'});
}).then(function(){
expect(testQueue.client).to.be.eql(client);
expect(testQueue.eclient).to.be.eql(subscriber);

return testQueue.close();
}).then(function(){
expect(client.status).to.be.eql('ready');
expect(subscriber.status).to.be.eql('ready');
});
});
});

0 comments on commit c1213d0

Please sign in to comment.