Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@techteamer/mq

Package Overview
Dependencies
Maintainers
3
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@techteamer/mq - npm Package Compare versions

Comparing version 4.1.0 to 4.1.1

src/GatheringClient.js

3

CHANGELOG.md

@@ -0,1 +1,4 @@

4.1.1
- dependency updates
4.1.0

@@ -2,0 +5,0 @@ - promises rewrite to async-await in most cases

@@ -13,2 +13,4 @@ const QueueClient = require('./src/QueueClient')

const Subscriber = require('./src/Subscriber')
const GatheringClient = require('./src/GatheringClient')
const GatheringServer = require('./src/GatheringServer')

@@ -27,1 +29,3 @@ module.exports.QueueClient = QueueClient

module.exports.Subscriber = Subscriber
module.exports.GatheringClient = GatheringClient
module.exports.GatheringServer = GatheringServer

6

package.json
{
"name": "@techteamer/mq",
"version": "4.1.0",
"version": "4.1.1",
"description": "A RabbitMQ wrapper for node",

@@ -25,3 +25,3 @@ "main": "index.js",

"dependencies": {
"amqplib": "^0.6.0",
"amqplib": "^0.7.1",
"uuid": "^8.2.0"

@@ -36,3 +36,3 @@ },

"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-promise": "^5.1.0",
"eslint-plugin-standard": "^5.0.0",

@@ -39,0 +39,0 @@ "mocha": "^8.0.1",

@@ -34,8 +34,8 @@ const QueueMessage = require('./QueueMessage')

* @param {*} data
* @param {String} correlationId
* @param {Number} timeOut
* @param {Map} attachments
* @param {String} [correlationId]
* @param {Number} [timeOut]
* @param {Map} [attachments]
* @return {Promise}
* */
sendAction (action, data, correlationId, timeOut = null, attachments) {
sendAction (action, data, correlationId = null, timeOut = null, attachments = null) {
return this.send({ action, data }, correlationId, timeOut, attachments)

@@ -45,9 +45,9 @@ }

/**
* @param {String} message
* @param {String} correlationId
* @param {Number} timeOut
* @param {Map} attachments
* @param {*} message
* @param {String} [correlationId]
* @param {Number} [timeOut]
* @param {Map} [attachments]
* @return {Promise}
*/
async send (message, correlationId, timeOut = null, attachments = null) {
async send (message, correlationId = null, timeOut = null, attachments = null) {
const options = {}

@@ -54,0 +54,0 @@

@@ -9,2 +9,4 @@ const QueueConfig = require('./QueueConfig')

const QueueServer = require('./QueueServer')
const GatheringClient = require('./GatheringClient')
const GatheringServer = require('./GatheringServer')

@@ -14,2 +16,10 @@ /**

* @param {QueueConnection} connection
* @property {Map<String, RPCClient>} rpcClients
* @property {Map<String, RPCServer>} rpcServers
* @property {Map<String, Publisher>} publishers
* @property {Map<String, Subscriber>} subscribers
* @property {Map<String, QueueClient>} queueClients
* @property {Map<String, QueueServer>} queueServers
* @property {Map<String, GatheringClient>} gatheringClients
* @property {Map<String, GatheringServer>} gatheringServers
* */

@@ -37,2 +47,6 @@ class QueueManager {

this.queueServers = new Map()
/** @var Map<string, GatheringClient>} */
this.gatheringClients = new Map()
/** @var Map<string, GatheringServer>} */
this.gatheringServers = new Map()
}

@@ -69,2 +83,9 @@

}
for (const [, gatheringClient] of this.gatheringClients) {
await gatheringClient.initialize()
}
for (const [, gatheringServer] of this.gatheringServers) {
await gatheringServer.initialize()
}
} catch (err) {

@@ -200,2 +221,60 @@ this._logger.error('Failed to initialize servers', err)

/**
* @param {String} exchangeName
* @param {GatheringClient|function() : GatheringClient} OverrideClass
* @param {Object} [options]
* @return GatheringClient
*/
getGatheringClient (exchangeName, OverrideClass = GatheringClient, options = {}) {
if (this.gatheringClients.has(exchangeName)) {
return this.gatheringClients.get(exchangeName)
}
if (arguments.length === 2 && typeof OverrideClass !== 'function') {
options = OverrideClass
OverrideClass = GatheringClient
}
if (OverrideClass !== GatheringClient && !(OverrideClass.prototype instanceof GatheringClient)) {
throw new Error('Override must be a subclass of GatheringClient')
}
const gatheringClient = new OverrideClass(this.connection, this._logger, exchangeName, options)
this.gatheringClients.set(exchangeName, gatheringClient)
return gatheringClient
}
/**
* @param {String} exchangeName
* @param {GatheringServer|function() : GatheringServer} OverrideClass
* @param {Object} [options]
* @return GatheringServer
*/
getGatheringServer (exchangeName, OverrideClass = GatheringServer, options = {}) {
if (this.gatheringServers.has(exchangeName)) {
return this.gatheringServers.get(exchangeName)
}
if (arguments.length === 2 && typeof OverrideClass !== 'function') {
options = OverrideClass
OverrideClass = GatheringServer
}
if (OverrideClass !== GatheringServer && !(OverrideClass.prototype instanceof GatheringServer)) {
throw new Error('Override must be a subclass of GatheringServer')
}
const settings = Object.assign({
timeoutMs: this._config.rpcTimeoutMs
}, options)
const gatheringServer = new OverrideClass(this.connection, this._logger, exchangeName, settings)
this.gatheringServers.set(exchangeName, gatheringServer)
return gatheringServer
}
/**
* @param {String} queueName

@@ -202,0 +281,0 @@ * @param {QueueClient|function() : QueueClient} OverrideClass

@@ -0,7 +1,55 @@

const OK = 'OK'
const NOT_FOUND = 'NOT_FOUND'
const ERROR = 'ERROR'
const statuses = {
[OK]: OK,
[NOT_FOUND]: NOT_FOUND,
[ERROR]: ERROR
}
class QueueResponse {
constructor () {
this.statusMessage = ''
this.statusCode = ''
this.attachments = new Map()
}
get statuses () {
return statuses
}
get OK () {
return OK
}
get NOT_FOUND () {
return NOT_FOUND
}
get ERROR () {
return ERROR
}
/**
* @param statusCode
* @param [statusMessage]
*/
setStatus (statusCode, statusMessage = this.statuses[statusCode]) {
this.statusCode = statusCode
this.statusMessage = statusMessage
}
ok (statusMessage) {
this.setStatus(this.OK, statusMessage)
}
notFound (statusMessage) {
this.setStatus(this.NOT_FOUND, statusMessage)
}
error (statusMessage) {
this.setStatus(this.ERROR, statusMessage)
}
/**
* @param {String} name

@@ -8,0 +56,0 @@ * @param {Buffer} buffer

@@ -19,3 +19,2 @@ const QueueMessage = require('./QueueMessage')

this.name = rpcName
this._replyQueue = ''

@@ -22,0 +21,0 @@ const { prefetchCount, timeoutMs } = options

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