video-utils
Advanced tools
Comparing version 1.0.73 to 1.0.74
{ | ||
"name": "video-utils", | ||
"version": "1.0.73", | ||
"version": "1.0.74", | ||
"dependencies": { | ||
@@ -5,0 +5,0 @@ "amqp": "0.2.x", |
@@ -25,3 +25,3 @@ var | ||
var publish = function (exc) { | ||
var publish = function (exc, _cb) { | ||
exc.publish(generateRoutingKey(userId), data, { | ||
@@ -31,3 +31,3 @@ headers: { | ||
} | ||
}, cb); | ||
}, _cb); | ||
}; | ||
@@ -41,29 +41,35 @@ | ||
// если не передан обменник, будем паблишить во все открытые | ||
var exchanges = []; | ||
Object.keys(this._connection.exchanges).forEach(function (exchangeKey) { | ||
var exc = this._connection.exchanges[exchangeKey]; | ||
if (exc && exc.state === 'open') { | ||
publish(exc); | ||
exchanges.push(exc); | ||
} | ||
}, this); | ||
} | ||
if (!exchanges.length) { | ||
cb(new Error('no open exchanges')); | ||
} else { | ||
async.each(exchanges, publish, cb); | ||
} | ||
} else { | ||
var _exchange = self._getExchange(exchange); | ||
var _exchange = self._getExchange(exchange); | ||
if (_exchange) { | ||
if (_exchange.state === 'open') { | ||
publish(_exchange); | ||
if (_exchange) { | ||
if (_exchange.state === 'open') { | ||
publish(_exchange, cb); | ||
} else { | ||
this._queue.push(arguments); | ||
} | ||
} else { | ||
// нет обменника, создадим с типом direct и passive == false | ||
self._connection.exchange(exchange, { | ||
passive: false, | ||
type: 'direct', | ||
confirm: true | ||
}, function(){ | ||
self._logger.info('Rabbit Sender', 'Exchange "'+ exchange +'" opened!'); | ||
self._processQueue(); | ||
}); | ||
this._queue.push(arguments); | ||
} | ||
} else { | ||
// нет обменника, создадим с типом direct и passive == false | ||
self._connection.exchange(exchange, { | ||
passive: false, | ||
type: 'direct', | ||
confirm: true | ||
}, function(){ | ||
self._logger.info('Rabbit Sender', 'Exchange "'+ exchange +'" opened!'); | ||
self._processQueue(); | ||
}); | ||
this._queue.push(arguments); | ||
} | ||
@@ -70,0 +76,0 @@ }; |
42245
993