bmqb-mns
Version:
BMQB aliyun mns
53 lines (42 loc) • 1.27 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _lodash = require('lodash');
var _lodash2 = _interopRequireDefault(_lodash);
var _queue = require('./queue');
var _queue2 = _interopRequireDefault(_queue);
var _topic = require('./topic');
var _topic2 = _interopRequireDefault(_topic);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
class MQProducer {
constructor(adapter, config) {
if (!adapter) {
throw new Error('adapter should not be empty');
}
if (!_lodash2.default.isObject(config)) {
throw new Error('invalid config');
}
this.adapter = adapter;
this.config = config;
}
getQueueProducer(queueName) {
if (!queueName) {
throw new Error('invalid queueName!');
}
const queueConfig = _lodash2.default.merge(this.config, {
queueName: queueName
});
return new _queue2.default(this.adapter, queueConfig);
}
getTopicProducer(topicName) {
if (!topicName) {
throw new Error('invalid topicName!');
}
const topicConfig = _lodash2.default.merge(this.config, {
topicName: topicName
});
return new _topic2.default(this.adapter, topicConfig);
}
}
exports.default = MQProducer;