servicebus
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -12,3 +12,3 @@ var events = require('events'), | ||
QueueRegistry.prototype.getCurrentQueues = function getCurrentQueues (callback) { | ||
if ( ! this.queues) { | ||
if ( ! this.queues || JSON.stringify(this.queues) === "{}") { | ||
var self = this; | ||
@@ -30,8 +30,18 @@ this.serializer.on('deserialized', function (queues) { | ||
function Correlator () { | ||
function Correlator () { | ||
events.EventEmitter.call(this); | ||
var self = this; | ||
this.ready = false; | ||
this.registry = new QueueRegistry(); | ||
this.registry.getCurrentQueues(function (err, queues) { | ||
self.ready = true; | ||
self.emit('ready'); | ||
}); | ||
} | ||
util.inherits(Correlator, events.EventEmitter); | ||
Correlator.prototype.getUniqueId = function getUniqueId (queueName, subscriptionId, callback) { | ||
var id; | ||
var id, | ||
self = this; | ||
if ( ! subscriptionId) { | ||
@@ -41,8 +51,22 @@ id = queueName + '.' + newId(); | ||
} | ||
if( ! this.registry.queues[subscriptionId]) { | ||
id = queueName + '.' + newId(); | ||
this.registry.queues[subscriptionId] = id; | ||
this.registry.setCurrentQueues(this.registry.queues, function (err) { | ||
if (err) callback(err); | ||
else callback(null, id); | ||
function getIdFromQueueData () { | ||
if( ! self.registry.queues[subscriptionId]) { | ||
id = queueName + '.' + newId(); | ||
self.registry.queues[subscriptionId] = id; | ||
self.registry.setCurrentQueues(self.registry.queues, function (err) { | ||
if (err) callback(err); | ||
else callback(null, id); | ||
}); | ||
} else { | ||
id = self.registry.queues[subscriptionId]; | ||
callback(null, id); | ||
} | ||
} | ||
if (this.ready) { | ||
getIdFromQueueData(); | ||
} else { | ||
this.on('ready', function () { | ||
getIdFromQueueData(); | ||
}); | ||
@@ -49,0 +73,0 @@ } |
@@ -16,3 +16,3 @@ var events = require('events'), | ||
var self = this; | ||
fs.readFile(this.filename, function (err, data) { | ||
fs.readFile(this.filename, "utf-8", function (err, data) { | ||
if (err) { | ||
@@ -19,0 +19,0 @@ self.emit('deserialized', {}) |
@@ -7,3 +7,3 @@ { | ||
"description": "Simple service bus for sending events between processes using amqp.", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"homepage": "https://github.com/mateodelnorte/servicebus", | ||
@@ -10,0 +10,0 @@ "repository": { |
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
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
27281
728
0