Socket
Socket
Sign inDemoInstall

amqplib-easy

Package Overview
Dependencies
Maintainers
31
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

amqplib-easy - npm Package Compare versions

Comparing version 4.4.0 to 4.5.0

10

API.md

@@ -6,2 +6,3 @@ - [`Create(amqpUrl)`](#createamqpurl-socketoptions---amqp)

- [`AMQP.connect()`](#amqpconnect---promise)
- [`AMQP.close()`](#amqpclose---promise)
- [`Config`](#config)

@@ -46,2 +47,11 @@

### `AMQP.close()` -> `Promise`
Close the `AMQP` and delete its `connection` & `sendChannel` without affecting others. E.g.,
```javascript
var amqp = require('amqplib-easy');
var connection = amqplib('amqp://guest:guest@localhost:1337');
conneciton.close();
```
### `Config`

@@ -48,0 +58,0 @@ Recognized properties follow

36

index.js

@@ -11,19 +11,18 @@ 'use strict'

function closeConnection (connectionUrl) {
return connections[connectionUrl]
.then(function (connection) {
return connection.close()
}).catch(function (err) {
// this catch is necessary so that all single connections get closed and
// cleared, even if they are not established, without affection others.
console.warn(err.toString())
}).then(function () {
delete connections[connectionUrl]
delete sendChannels[connectionUrl]
})
}
function cleanup (done) {
return Promise.map(
Object.keys(connections),
function (connectionUrl) {
return connections[connectionUrl]
.then(function (connection) {
return connection.close()
}).catch(function (err) {
// this catch is necessary so that all single connections get closed and
// cleared, even if they are not established, without affection others.
console.warn(err.toString())
})
})
.then(function () {
connections = {}
sendChannels = {}
})
return Promise.map(Object.keys(connections), closeConnection)
.nodeify(done)

@@ -52,2 +51,6 @@ }

function close () {
return closeConnection(amqpUrl)
}
function sendChannel () {

@@ -228,2 +231,3 @@ if (!sendChannels[amqpUrl]) {

connect: connect,
close: close,
consume: consume,

@@ -230,0 +234,0 @@ publish: publish,

{
"name": "amqplib-easy",
"version": "4.4.0",
"version": "4.5.0",
"description": "Simplified API for interacting with AMQP",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -287,2 +287,38 @@ /* globals it:false */

describe('Connection managment', function () {
it('should close and delete connection – no reuse', function (done) {
amqp.connect()
.then(function (connection1) {
return amqp.close().then(function () {
amqp.connect()
.then(function (connection2) {
connection1.should.not.equal(connection2)
done()
})
})
})
.catch(done)
})
it('should close/delete connection and reconnect on consume', function (done) {
amqp.connect()
.then(function (connection1) {
return amqp.close().then(function () {
amqp.consume({
exchange: 'cat',
queue: 'found_cats',
topics: ['found.*']
},
function () {
done('Got a cat')
}).catch(done)
.then(function () {
amqp.connect().then(function () {
done()
})
})
})
})
.catch(done)
})
it('should reuse the existing connection', function (done) {

@@ -289,0 +325,0 @@ amqp.connect()

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc