Comparing version 0.0.9 to 0.0.10
@@ -7,5 +7,5 @@ "use strict"; | ||
return comb.define(null, { | ||
instance:{ | ||
instance: { | ||
constructor:function _GetConnection() { | ||
constructor: function _GetConnection() { | ||
this._super(arguments); | ||
@@ -17,9 +17,19 @@ var args = comb(arguments).toArray(), | ||
} | ||
this.__connection = null; | ||
this.getConnectionCb = connectionCb; | ||
}, | ||
getConnection:function () { | ||
return when(this.getConnectionCb()); | ||
getConnection: function () { | ||
if (!this.__connection) { | ||
var self = this; | ||
return when(this.getConnectionCb()).chain(function (connection) { | ||
self.__connection = connection; | ||
return connection; | ||
}); | ||
} else { | ||
return when(this.__connection); | ||
} | ||
} | ||
} | ||
}).as(module); |
@@ -22,5 +22,6 @@ "use strict"; | ||
var connect = (function connectWrapper() { | ||
var connectionPromise, connection, isConnected = false; | ||
function connect(url, opts) { | ||
var connectionPromise = new Promise(), connection, isConnected = false; | ||
function ready() { | ||
@@ -30,3 +31,2 @@ isConnected = true; | ||
connection.removeListener("error", connectionError); | ||
//set up error logging | ||
connection.on("error", errorHandler); | ||
@@ -48,14 +48,10 @@ connectionPromise.callback(connection); | ||
return function connect(url, opts) { | ||
if (!connectionPromise) { | ||
connectionPromise = new Promise(); | ||
connection = amqp.createConnection(url, opts); | ||
connection.once('ready', ready); | ||
connection.once('error', connectionError); | ||
connection.once("close", checkConnected); | ||
} | ||
return connectionPromise; | ||
}; | ||
}()); | ||
connection = amqp.createConnection(url, opts); | ||
connection.once('ready', ready); | ||
connection.once('error', connectionError); | ||
connection.once("close", checkConnected); | ||
return connectionPromise; | ||
} | ||
var Hare = comb.define(_Options, { | ||
@@ -62,0 +58,0 @@ |
{ | ||
"name": "hare", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"description": "Wrapper around amqp to make common patterns easier", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34481
722