Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion lib/database/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,26 @@ Connection.prototype.connect = function(cb) {
redis.createClient(config.port, config.host, config.options).auth(config.password) :
redis.createClient(config.port, config.host, config.options);

client.once('ready', function() {
if (config.options.onError) {
client.on('error', function connectionErrorListener(){
var args = Array.prototype.slice.call(arguments);
args.push(client);
config.options.onError.apply(this, args);
});
}

var event = 'ready';
if (config.options.no_ready_check) {
event = 'connect';
}

//cant share the listener below as thats tied with waterline business
if (config.options.onReady) {
client.on(event, config.options.onReady);
}

//make the client listen on on rather than once, a reconnect happens it needs to run the cb
client.once(event, function() {
cb(null, client);
});
};