Comparing version 0.0.15 to 0.2.0
@@ -37,24 +37,4 @@ "use strict"; | ||
}, | ||
close: function () { | ||
var ret = new comb.Promise(); | ||
if (this._defaultExchange) { | ||
var connection = this.__connection, exchange = this._defaultExchange; | ||
exchange.on("close", function (err) { | ||
if (err) { | ||
ret.errback(new Error("Unexpected Error closing connection")); | ||
} else { | ||
connection.destroy(); | ||
ret.callback(); | ||
} | ||
}); | ||
exchange.on("error", ret.errback); | ||
exchange.close(); | ||
} else { | ||
ret.callback(); | ||
} | ||
return ret; | ||
} | ||
} | ||
}).as(module); |
@@ -22,6 +22,5 @@ "use strict"; | ||
var connect = (function connectWrapper() { | ||
var connectionPromise, connection, isConnected = false; | ||
function connect(url, opts) { | ||
var connectionPromise = new Promise(), connection, isConnected = false; | ||
function ready() { | ||
@@ -31,2 +30,3 @@ isConnected = true; | ||
connection.removeListener("error", connectionError); | ||
//set up error logging | ||
connection.on("error", errorHandler); | ||
@@ -48,10 +48,14 @@ connectionPromise.callback(connection); | ||
connection = amqp.createConnection(url, opts); | ||
connection.once('ready', ready); | ||
connection.once('error', connectionError); | ||
connection.once("close", checkConnected); | ||
return connectionPromise; | ||
} | ||
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; | ||
}; | ||
}()); | ||
var Hare = comb.define(_Options, { | ||
@@ -58,0 +62,0 @@ |
@@ -31,14 +31,14 @@ "use strict"; | ||
__getQueue: function __getQueue() { | ||
var queueName = this.queueName; | ||
var queueName = this.queueName, self = this; | ||
if (!this.__queuePromise) { | ||
this.__queuePromise = this.getConnection().chain(function connectCb(connection) { | ||
var ret = new Promise(); | ||
connection.queue(queueName, this.options, function (queue) { | ||
queueName = this.queueName = queue.name; | ||
queue.bind(this.get("exchange"), this.get("routingKey") || queue.name); | ||
this.__queue = queue; | ||
connection.queue(queueName, self.options, function (queue) { | ||
queueName = self.queueName = queue.name; | ||
queue.bind(self.get("exchange"), self.get("routingKey") || queue.name); | ||
self.__queue = queue; | ||
ret.callback(queue); | ||
}.bind(this)); | ||
}); | ||
return ret; | ||
}.bind(this)); | ||
}); | ||
} | ||
@@ -108,5 +108,7 @@ return this.__queuePromise; | ||
subscribe: function subscribe(listener) { | ||
return this.__getQueue().then(function (queue) { | ||
this.__subscribe(queue, listener); | ||
}.bind(this)); | ||
var self = this; | ||
return this.__getQueue().chain(function (queue) { | ||
self.__subscribe(queue, listener); | ||
return queue; | ||
}); | ||
}, | ||
@@ -113,0 +115,0 @@ |
{ | ||
"name": "hare", | ||
"version": "0.0.15", | ||
"version": "0.2.0", | ||
"description": "Wrapper around amqp to make common patterns easier", | ||
@@ -16,3 +16,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"amqp": "~0.1.3", | ||
"amqp": "~0.2.0", | ||
"comb": "~0.2.3" | ||
@@ -19,0 +19,0 @@ }, |
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
35842
754
+ Addedamqp@0.2.7(transitive)
+ Addedlodash@4.17.21(transitive)
- Removedamqp@0.1.8(transitive)
- Removedbuffer-from@1.1.2(transitive)
- Removedlodash@1.3.1(transitive)
- Removedlongjohn@0.2.12(transitive)
- Removedsource-map@0.6.1(transitive)
- Removedsource-map-support@0.5.21(transitive)
Updatedamqp@~0.2.0