resolve-bus-rabbitmq
Advanced tools
Comparing version 0.0.1-alpha.79f28edb to 0.0.2
@@ -7,37 +7,2 @@ 'use strict'; | ||
var _stringify = require('babel-runtime/core-js/json/stringify'); | ||
var _stringify2 = _interopRequireDefault(_stringify); | ||
var _assign = require('babel-runtime/core-js/object/assign'); | ||
var _assign2 = _interopRequireDefault(_assign); | ||
exports.default = function (options) { | ||
var handler = function handler() {}; | ||
var config = (0, _assign2.default)(defaultOptions, options); | ||
var initPromise = init(config, function (event) { | ||
return handler(event); | ||
}); | ||
return { | ||
publish: function publish(event) { | ||
return initPromise.then(function (channel) { | ||
channel.publish(config.exchange, config.queueName, new Buffer((0, _stringify2.default)(event)), | ||
// Additional options described here: | ||
// http://www.squaremobius.net/amqp.node/channel_api.html#channel_publish | ||
{ | ||
expiration: config.messageTtl, | ||
persistent: false | ||
}); | ||
}); | ||
}, | ||
setTrigger: function setTrigger(callback) { | ||
return initPromise.then(function () { | ||
return handler = callback; | ||
}); | ||
} | ||
}; | ||
}; | ||
var _amqplib = require('amqplib'); | ||
@@ -90,2 +55,32 @@ | ||
}); | ||
} | ||
} | ||
function createDriver(options) { | ||
var handler = function handler() {}; | ||
var config = Object.assign(defaultOptions, options); | ||
var initPromise = init(config, function (event) { | ||
return handler(event); | ||
}); | ||
return { | ||
publish: function publish(event) { | ||
return initPromise.then(function (channel) { | ||
channel.publish(config.exchange, config.queueName, new Buffer(JSON.stringify(event)), | ||
// Additional options described here: | ||
// http://www.squaremobius.net/amqp.node/channel_api.html#channel_publish | ||
{ | ||
expiration: config.messageTtl, | ||
persistent: false | ||
}); | ||
}); | ||
}, | ||
setTrigger: function setTrigger(callback) { | ||
return initPromise.then(function () { | ||
return handler = callback; | ||
}); | ||
} | ||
}; | ||
} | ||
exports.default = createDriver; | ||
module.exports = exports['default']; |
{ | ||
"name": "resolve-bus-rabbitmq", | ||
"version": "0.0.1-alpha.79f28edb", | ||
"version": "0.0.2", | ||
"description": "This package is a driver for resolve-bus to emit events using RabbitMQ.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
3743
74
1