amqplib-easy
Advanced tools
Comparing version 2.1.0 to 2.2.0
15
index.js
@@ -7,4 +7,19 @@ 'use strict'; | ||
retry = require('amqplib-retry'), | ||
diehard = require('diehard'), | ||
connections = {}; | ||
function cleanup(done) { | ||
BPromise.map( | ||
Object.keys(connections), | ||
function (connectionUrl) { | ||
return connections[connectionUrl] | ||
.then(function (connection) { | ||
return connection.close(); | ||
}); | ||
} | ||
).nodeify(done); | ||
} | ||
diehard.register(cleanup); | ||
module.exports = function (amqpUrl) { | ||
@@ -11,0 +26,0 @@ function connect() { |
{ | ||
"name": "amqplib-easy", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "Simplified API for interacting with AMQP", | ||
@@ -35,4 +35,5 @@ "main": "index.js", | ||
"bluebird": "^2.6.2", | ||
"diehard": "^1.1.2", | ||
"lodash.defaults": "^2.4.1" | ||
} | ||
} |
@@ -5,2 +5,3 @@ /*globals it:false*/ | ||
var amqpUrl = 'amqp://guest:guest@localhost:5672', | ||
childProcess = require('child_process'), | ||
BPromise = require('bluebird'), | ||
@@ -105,1 +106,33 @@ amqp = require('../index')(amqpUrl); | ||
}); | ||
describe('Connection managment', function () { | ||
it('should reuse the existing connection', function (done) { | ||
amqp.connect() | ||
.then(function (connection1) { | ||
amqp.connect() | ||
.then(function (connection2) { | ||
connection1.should.equal(connection2); | ||
done(); | ||
}); | ||
}) | ||
.catch(done); | ||
}); | ||
it('should close the connection upon death', function (done) { | ||
this.timeout(3000); | ||
// Spin up a process to kill | ||
var testProcess = childProcess.fork('./test/resources/death.js', { silent: false }); | ||
testProcess.on('message', function (message) { | ||
switch (message) { | ||
case 'ok': | ||
return done(); | ||
case 'ready': | ||
return testProcess.kill('SIGTERM'); | ||
default: | ||
return done(new Error('Unknown message ' + message)); | ||
} | ||
}); | ||
}); | ||
}); |
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
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
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
17415
12
293
5
1
+ Addeddiehard@^1.1.2
+ Addedasync@2.6.4(transitive)
+ Addeddeath@1.1.0(transitive)
+ Addeddebug@3.2.7(transitive)
+ Addeddiehard@1.5.2(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedms@2.1.3(transitive)