@azteam/rabbitmq-async 1.0.195 → 1.0.198
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Provider.js +11 -13
- package/lib/RabbitMQAsync.js +354 -370
- package/package.json +24 -1
package/lib/Provider.js
CHANGED
|
@@ -7,7 +7,7 @@ exports["default"] = void 0;
|
|
|
7
7
|
var _RabbitMQAsync = _interopRequireDefault(require("./RabbitMQAsync"));
|
|
8
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
9
9
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
10
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
10
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
11
11
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
12
12
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
13
13
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
@@ -50,18 +50,16 @@ var Provider = /*#__PURE__*/function () {
|
|
|
50
50
|
var _waitAllConnection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
51
51
|
var _this2 = this;
|
|
52
52
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
53
|
-
while (1) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return _context.stop();
|
|
64
|
-
}
|
|
53
|
+
while (1) switch (_context.prev = _context.next) {
|
|
54
|
+
case 0:
|
|
55
|
+
_context.next = 2;
|
|
56
|
+
return Promise.all(Object.keys(this.configs).map(function (keyConfig) {
|
|
57
|
+
var connection = _this2.getConnection(keyConfig);
|
|
58
|
+
return connection.waitConnection();
|
|
59
|
+
}));
|
|
60
|
+
case 2:
|
|
61
|
+
case "end":
|
|
62
|
+
return _context.stop();
|
|
65
63
|
}
|
|
66
64
|
}, _callee, this);
|
|
67
65
|
}));
|
package/lib/RabbitMQAsync.js
CHANGED
|
@@ -12,7 +12,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
|
|
|
12
12
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
13
13
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
14
14
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
15
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
16
16
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
17
17
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
18
18
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
@@ -40,32 +40,30 @@ var RabbitMQAsync = /*#__PURE__*/function () {
|
|
|
40
40
|
i,
|
|
41
41
|
_args = arguments;
|
|
42
42
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
43
|
-
while (1) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
_context.next = 8;
|
|
51
|
-
break;
|
|
52
|
-
}
|
|
53
|
-
_context.next = 5;
|
|
54
|
-
return (0, _util.timeout)(1000);
|
|
55
|
-
case 5:
|
|
56
|
-
i += 1;
|
|
57
|
-
_context.next = 2;
|
|
43
|
+
while (1) switch (_context.prev = _context.next) {
|
|
44
|
+
case 0:
|
|
45
|
+
n = _args.length > 0 && _args[0] !== undefined ? _args[0] : 10;
|
|
46
|
+
i = 0;
|
|
47
|
+
case 2:
|
|
48
|
+
if (!(!this.connected || i < n)) {
|
|
49
|
+
_context.next = 8;
|
|
58
50
|
break;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
51
|
+
}
|
|
52
|
+
_context.next = 5;
|
|
53
|
+
return (0, _util.timeout)(1000);
|
|
54
|
+
case 5:
|
|
55
|
+
i += 1;
|
|
56
|
+
_context.next = 2;
|
|
57
|
+
break;
|
|
58
|
+
case 8:
|
|
59
|
+
if (this.connected) {
|
|
60
|
+
_context.next = 10;
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
throw new Error('Rabbit not connected');
|
|
64
|
+
case 10:
|
|
65
|
+
case "end":
|
|
66
|
+
return _context.stop();
|
|
69
67
|
}
|
|
70
68
|
}, _callee, this);
|
|
71
69
|
}));
|
|
@@ -81,42 +79,40 @@ var RabbitMQAsync = /*#__PURE__*/function () {
|
|
|
81
79
|
var _this = this;
|
|
82
80
|
var opt;
|
|
83
81
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
84
|
-
while (1) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
_this._alert('close', 'MQ closed');
|
|
106
|
-
process.exit(1);
|
|
107
|
-
});
|
|
108
|
-
_context2.next = 17;
|
|
109
|
-
break;
|
|
110
|
-
case 12:
|
|
111
|
-
_context2.prev = 12;
|
|
112
|
-
_context2.t0 = _context2["catch"](2);
|
|
113
|
-
this.connected = false;
|
|
114
|
-
this._alert('error', "MQ connect ".concat(_context2.t0));
|
|
82
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
83
|
+
case 0:
|
|
84
|
+
this._alert('connecting', 'MQ connecting...');
|
|
85
|
+
opt = {
|
|
86
|
+
credentials: _amqplib["default"].credentials.plain(this.username, this.password)
|
|
87
|
+
};
|
|
88
|
+
_context2.prev = 2;
|
|
89
|
+
_context2.next = 5;
|
|
90
|
+
return _amqplib["default"].connect("amqp://".concat(this.host), opt);
|
|
91
|
+
case 5:
|
|
92
|
+
this.client = _context2.sent;
|
|
93
|
+
this.connected = true;
|
|
94
|
+
this._alert('connect', 'MQ connected');
|
|
95
|
+
this.client.on('error', function (err) {
|
|
96
|
+
_this.connected = false;
|
|
97
|
+
_this._alert('error', "MQ Error ".concat(err));
|
|
98
|
+
process.exit(1);
|
|
99
|
+
});
|
|
100
|
+
this.client.on('close', function () {
|
|
101
|
+
_this.connected = false;
|
|
102
|
+
_this._alert('close', 'MQ closed');
|
|
115
103
|
process.exit(1);
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
104
|
+
});
|
|
105
|
+
_context2.next = 17;
|
|
106
|
+
break;
|
|
107
|
+
case 12:
|
|
108
|
+
_context2.prev = 12;
|
|
109
|
+
_context2.t0 = _context2["catch"](2);
|
|
110
|
+
this.connected = false;
|
|
111
|
+
this._alert('error', "MQ connect ".concat(_context2.t0));
|
|
112
|
+
process.exit(1);
|
|
113
|
+
case 17:
|
|
114
|
+
case "end":
|
|
115
|
+
return _context2.stop();
|
|
120
116
|
}
|
|
121
117
|
}, _callee2, this, [[2, 12]]);
|
|
122
118
|
}));
|
|
@@ -155,71 +151,69 @@ var RabbitMQAsync = /*#__PURE__*/function () {
|
|
|
155
151
|
queueInfo,
|
|
156
152
|
_args3 = arguments;
|
|
157
153
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
158
|
-
while (1) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
_context3.next = 33;
|
|
166
|
-
break;
|
|
167
|
-
}
|
|
168
|
-
_context3.prev = 4;
|
|
169
|
-
_context3.next = 7;
|
|
170
|
-
return this.client.createChannel();
|
|
171
|
-
case 7:
|
|
172
|
-
channel = _context3.sent;
|
|
173
|
-
_context3.next = 10;
|
|
174
|
-
return channel.assertQueue(prefixQueueName, {
|
|
175
|
-
durable: true
|
|
176
|
-
});
|
|
177
|
-
case 10:
|
|
178
|
-
queueInfo = _context3.sent;
|
|
179
|
-
if (!(limit === 0 || queueInfo.messageCount < limit)) {
|
|
180
|
-
_context3.next = 14;
|
|
181
|
-
break;
|
|
182
|
-
}
|
|
183
|
-
_context3.next = 14;
|
|
184
|
-
return channel.sendToQueue(prefixQueueName, Buffer.from(JSON.stringify(_objectSpread({
|
|
185
|
-
retry: 5
|
|
186
|
-
}, msg))), {
|
|
187
|
-
persistent: true
|
|
188
|
-
});
|
|
189
|
-
case 14:
|
|
190
|
-
return _context3.abrupt("return", true);
|
|
191
|
-
case 17:
|
|
192
|
-
_context3.prev = 17;
|
|
193
|
-
_context3.t0 = _context3["catch"](4);
|
|
194
|
-
_context3.next = 21;
|
|
195
|
-
return (0, _util.timeout)(2000);
|
|
196
|
-
case 21:
|
|
197
|
-
return _context3.abrupt("return", this.send(queueName, msg));
|
|
198
|
-
case 22:
|
|
199
|
-
_context3.prev = 22;
|
|
200
|
-
_context3.prev = 23;
|
|
201
|
-
_context3.next = 26;
|
|
202
|
-
return channel.close();
|
|
203
|
-
case 26:
|
|
204
|
-
_context3.next = 30;
|
|
154
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
155
|
+
case 0:
|
|
156
|
+
msg = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
|
|
157
|
+
limit = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : 0;
|
|
158
|
+
prefixQueueName = this.parsePrefix(queueName, msg.self);
|
|
159
|
+
if (!this.connected) {
|
|
160
|
+
_context3.next = 33;
|
|
205
161
|
break;
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
162
|
+
}
|
|
163
|
+
_context3.prev = 4;
|
|
164
|
+
_context3.next = 7;
|
|
165
|
+
return this.client.createChannel();
|
|
166
|
+
case 7:
|
|
167
|
+
channel = _context3.sent;
|
|
168
|
+
_context3.next = 10;
|
|
169
|
+
return channel.assertQueue(prefixQueueName, {
|
|
170
|
+
durable: true
|
|
171
|
+
});
|
|
172
|
+
case 10:
|
|
173
|
+
queueInfo = _context3.sent;
|
|
174
|
+
if (!(limit === 0 || queueInfo.messageCount < limit)) {
|
|
175
|
+
_context3.next = 14;
|
|
213
176
|
break;
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
177
|
+
}
|
|
178
|
+
_context3.next = 14;
|
|
179
|
+
return channel.sendToQueue(prefixQueueName, Buffer.from(JSON.stringify(_objectSpread({
|
|
180
|
+
retry: 5
|
|
181
|
+
}, msg))), {
|
|
182
|
+
persistent: true
|
|
183
|
+
});
|
|
184
|
+
case 14:
|
|
185
|
+
return _context3.abrupt("return", true);
|
|
186
|
+
case 17:
|
|
187
|
+
_context3.prev = 17;
|
|
188
|
+
_context3.t0 = _context3["catch"](4);
|
|
189
|
+
_context3.next = 21;
|
|
190
|
+
return (0, _util.timeout)(2000);
|
|
191
|
+
case 21:
|
|
192
|
+
return _context3.abrupt("return", this.send(queueName, msg));
|
|
193
|
+
case 22:
|
|
194
|
+
_context3.prev = 22;
|
|
195
|
+
_context3.prev = 23;
|
|
196
|
+
_context3.next = 26;
|
|
197
|
+
return channel.close();
|
|
198
|
+
case 26:
|
|
199
|
+
_context3.next = 30;
|
|
200
|
+
break;
|
|
201
|
+
case 28:
|
|
202
|
+
_context3.prev = 28;
|
|
203
|
+
_context3.t1 = _context3["catch"](23);
|
|
204
|
+
case 30:
|
|
205
|
+
return _context3.finish(22);
|
|
206
|
+
case 31:
|
|
207
|
+
_context3.next = 36;
|
|
208
|
+
break;
|
|
209
|
+
case 33:
|
|
210
|
+
_context3.next = 35;
|
|
211
|
+
return (0, _util.timeout)(2000);
|
|
212
|
+
case 35:
|
|
213
|
+
return _context3.abrupt("return", this.send(queueName, msg));
|
|
214
|
+
case 36:
|
|
215
|
+
case "end":
|
|
216
|
+
return _context3.stop();
|
|
223
217
|
}
|
|
224
218
|
}, _callee3, this, [[4, 17, 22, 31], [23, 28]]);
|
|
225
219
|
}));
|
|
@@ -237,52 +231,50 @@ var RabbitMQAsync = /*#__PURE__*/function () {
|
|
|
237
231
|
channel,
|
|
238
232
|
_args4 = arguments;
|
|
239
233
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
240
|
-
while (1) {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
_context4.next = 26;
|
|
247
|
-
break;
|
|
248
|
-
}
|
|
249
|
-
_context4.prev = 3;
|
|
250
|
-
_context4.next = 6;
|
|
251
|
-
return this.client.createChannel();
|
|
252
|
-
case 6:
|
|
253
|
-
channel = _context4.sent;
|
|
254
|
-
_context4.next = 9;
|
|
255
|
-
return channel.assertQueue(prefixQueueName, {
|
|
256
|
-
durable: true
|
|
257
|
-
});
|
|
258
|
-
case 9:
|
|
259
|
-
return _context4.abrupt("return", _context4.sent);
|
|
260
|
-
case 12:
|
|
261
|
-
_context4.prev = 12;
|
|
262
|
-
_context4.t0 = _context4["catch"](3);
|
|
263
|
-
return _context4.abrupt("return", this.getInfo(queueName));
|
|
264
|
-
case 15:
|
|
265
|
-
_context4.prev = 15;
|
|
266
|
-
_context4.prev = 16;
|
|
267
|
-
_context4.next = 19;
|
|
268
|
-
return channel.close();
|
|
269
|
-
case 19:
|
|
270
|
-
_context4.next = 23;
|
|
234
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
235
|
+
case 0:
|
|
236
|
+
self = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : false;
|
|
237
|
+
prefixQueueName = this.parsePrefix(queueName, self);
|
|
238
|
+
if (!this.connected) {
|
|
239
|
+
_context4.next = 26;
|
|
271
240
|
break;
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
241
|
+
}
|
|
242
|
+
_context4.prev = 3;
|
|
243
|
+
_context4.next = 6;
|
|
244
|
+
return this.client.createChannel();
|
|
245
|
+
case 6:
|
|
246
|
+
channel = _context4.sent;
|
|
247
|
+
_context4.next = 9;
|
|
248
|
+
return channel.assertQueue(prefixQueueName, {
|
|
249
|
+
durable: true
|
|
250
|
+
});
|
|
251
|
+
case 9:
|
|
252
|
+
return _context4.abrupt("return", _context4.sent);
|
|
253
|
+
case 12:
|
|
254
|
+
_context4.prev = 12;
|
|
255
|
+
_context4.t0 = _context4["catch"](3);
|
|
256
|
+
return _context4.abrupt("return", this.getInfo(queueName));
|
|
257
|
+
case 15:
|
|
258
|
+
_context4.prev = 15;
|
|
259
|
+
_context4.prev = 16;
|
|
260
|
+
_context4.next = 19;
|
|
261
|
+
return channel.close();
|
|
262
|
+
case 19:
|
|
263
|
+
_context4.next = 23;
|
|
264
|
+
break;
|
|
265
|
+
case 21:
|
|
266
|
+
_context4.prev = 21;
|
|
267
|
+
_context4.t1 = _context4["catch"](16);
|
|
268
|
+
case 23:
|
|
269
|
+
return _context4.finish(15);
|
|
270
|
+
case 24:
|
|
271
|
+
_context4.next = 27;
|
|
272
|
+
break;
|
|
273
|
+
case 26:
|
|
274
|
+
return _context4.abrupt("return", this.getInfo(queueName));
|
|
275
|
+
case 27:
|
|
276
|
+
case "end":
|
|
277
|
+
return _context4.stop();
|
|
286
278
|
}
|
|
287
279
|
}, _callee4, this, [[3, 12, 15, 24], [16, 21]]);
|
|
288
280
|
}));
|
|
@@ -297,188 +289,184 @@ var RabbitMQAsync = /*#__PURE__*/function () {
|
|
|
297
289
|
var _consume = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(queueName, self, asyncFunction, callbackError) {
|
|
298
290
|
var prefixQueueName, channel, messageQueue;
|
|
299
291
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
300
|
-
while (1) {
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
_context6.next = 29;
|
|
306
|
-
break;
|
|
307
|
-
}
|
|
308
|
-
_context6.prev = 2;
|
|
309
|
-
_context6.next = 5;
|
|
310
|
-
return this.client.createChannel();
|
|
311
|
-
case 5:
|
|
312
|
-
channel = _context6.sent;
|
|
313
|
-
_context6.next = 8;
|
|
314
|
-
return channel.assertQueue(prefixQueueName, {
|
|
315
|
-
durable: true
|
|
316
|
-
});
|
|
317
|
-
case 8:
|
|
318
|
-
_context6.next = 10;
|
|
319
|
-
return channel.prefetch(1);
|
|
320
|
-
case 10:
|
|
321
|
-
messageQueue = this;
|
|
322
|
-
_context6.next = 13;
|
|
323
|
-
return new Promise(function (resolve, reject) {
|
|
324
|
-
channel.consume(prefixQueueName, /*#__PURE__*/function () {
|
|
325
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(msg) {
|
|
326
|
-
var data, errString;
|
|
327
|
-
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
328
|
-
while (1) {
|
|
329
|
-
switch (_context5.prev = _context5.next) {
|
|
330
|
-
case 0:
|
|
331
|
-
if (!msg) {
|
|
332
|
-
_context5.next = 54;
|
|
333
|
-
break;
|
|
334
|
-
}
|
|
335
|
-
data = JSON.parse(msg.content.toString());
|
|
336
|
-
if (!data) {
|
|
337
|
-
_context5.next = 51;
|
|
338
|
-
break;
|
|
339
|
-
}
|
|
340
|
-
_context5.prev = 3;
|
|
341
|
-
if (!msg.fields.redelivered) {
|
|
342
|
-
_context5.next = 22;
|
|
343
|
-
break;
|
|
344
|
-
}
|
|
345
|
-
data.retry -= 1;
|
|
346
|
-
if (!(data.retry > 0)) {
|
|
347
|
-
_context5.next = 16;
|
|
348
|
-
break;
|
|
349
|
-
}
|
|
350
|
-
if (!messageQueue.worker) {
|
|
351
|
-
_context5.next = 12;
|
|
352
|
-
break;
|
|
353
|
-
}
|
|
354
|
-
_context5.next = 10;
|
|
355
|
-
return messageQueue.send(queueName, _objectSpread(_objectSpread({}, data), {}, {
|
|
356
|
-
self: true
|
|
357
|
-
}));
|
|
358
|
-
case 10:
|
|
359
|
-
_context5.next = 14;
|
|
360
|
-
break;
|
|
361
|
-
case 12:
|
|
362
|
-
_context5.next = 14;
|
|
363
|
-
return messageQueue.send(queueName, data);
|
|
364
|
-
case 14:
|
|
365
|
-
_context5.next = 18;
|
|
366
|
-
break;
|
|
367
|
-
case 16:
|
|
368
|
-
_context5.next = 18;
|
|
369
|
-
return messageQueue.send(messageQueue.parsePrefix('RETRY'), {
|
|
370
|
-
queueName: queueName,
|
|
371
|
-
data: data,
|
|
372
|
-
retry_time: new Date()
|
|
373
|
-
});
|
|
374
|
-
case 18:
|
|
375
|
-
_context5.next = 20;
|
|
376
|
-
return channel.ack(msg);
|
|
377
|
-
case 20:
|
|
378
|
-
_context5.next = 44;
|
|
379
|
-
break;
|
|
380
|
-
case 22:
|
|
381
|
-
_context5.prev = 22;
|
|
382
|
-
_context5.next = 25;
|
|
383
|
-
return asyncFunction(data);
|
|
384
|
-
case 25:
|
|
385
|
-
_context5.next = 27;
|
|
386
|
-
return channel.ack(msg);
|
|
387
|
-
case 27:
|
|
388
|
-
_context5.next = 44;
|
|
389
|
-
break;
|
|
390
|
-
case 29:
|
|
391
|
-
_context5.prev = 29;
|
|
392
|
-
_context5.t0 = _context5["catch"](22);
|
|
393
|
-
errString = _context5.t0.toString();
|
|
394
|
-
if (!_lodash["default"].some(['IllegalOperationError: Channel closed'], function (el) {
|
|
395
|
-
return _lodash["default"].includes(errString, el);
|
|
396
|
-
})) {
|
|
397
|
-
_context5.next = 36;
|
|
398
|
-
break;
|
|
399
|
-
}
|
|
400
|
-
reject(new Error(errString));
|
|
401
|
-
_context5.next = 44;
|
|
402
|
-
break;
|
|
403
|
-
case 36:
|
|
404
|
-
if (callbackError) {
|
|
405
|
-
callbackError(prefixQueueName, _context5.t0);
|
|
406
|
-
}
|
|
407
|
-
if (!(data.retry <= 0)) {
|
|
408
|
-
_context5.next = 42;
|
|
409
|
-
break;
|
|
410
|
-
}
|
|
411
|
-
_context5.next = 40;
|
|
412
|
-
return channel.ack(msg);
|
|
413
|
-
case 40:
|
|
414
|
-
_context5.next = 44;
|
|
415
|
-
break;
|
|
416
|
-
case 42:
|
|
417
|
-
_context5.next = 44;
|
|
418
|
-
return channel.nack(msg);
|
|
419
|
-
case 44:
|
|
420
|
-
_context5.next = 49;
|
|
421
|
-
break;
|
|
422
|
-
case 46:
|
|
423
|
-
_context5.prev = 46;
|
|
424
|
-
_context5.t1 = _context5["catch"](3);
|
|
425
|
-
reject(_context5.t1);
|
|
426
|
-
case 49:
|
|
427
|
-
_context5.next = 52;
|
|
428
|
-
break;
|
|
429
|
-
case 51:
|
|
430
|
-
channel.ack(msg);
|
|
431
|
-
case 52:
|
|
432
|
-
_context5.next = 55;
|
|
433
|
-
break;
|
|
434
|
-
case 54:
|
|
435
|
-
reject(new Error('msg null'));
|
|
436
|
-
case 55:
|
|
437
|
-
case "end":
|
|
438
|
-
return _context5.stop();
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
}, _callee5, null, [[3, 46], [22, 29]]);
|
|
442
|
-
}));
|
|
443
|
-
return function (_x7) {
|
|
444
|
-
return _ref.apply(this, arguments);
|
|
445
|
-
};
|
|
446
|
-
}());
|
|
447
|
-
});
|
|
448
|
-
case 13:
|
|
449
|
-
_context6.next = 27;
|
|
450
|
-
break;
|
|
451
|
-
case 15:
|
|
452
|
-
_context6.prev = 15;
|
|
453
|
-
_context6.t0 = _context6["catch"](2);
|
|
454
|
-
_context6.prev = 17;
|
|
455
|
-
_context6.next = 20;
|
|
456
|
-
return channel.close();
|
|
457
|
-
case 20:
|
|
458
|
-
_context6.next = 24;
|
|
459
|
-
break;
|
|
460
|
-
case 22:
|
|
461
|
-
_context6.prev = 22;
|
|
462
|
-
_context6.t1 = _context6["catch"](17);
|
|
463
|
-
case 24:
|
|
464
|
-
_context6.next = 26;
|
|
465
|
-
return (0, _util.timeout)(5000);
|
|
466
|
-
case 26:
|
|
467
|
-
return _context6.abrupt("return", this.consume(queueName, self, asyncFunction, callbackError));
|
|
468
|
-
case 27:
|
|
469
|
-
_context6.next = 32;
|
|
292
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
293
|
+
case 0:
|
|
294
|
+
prefixQueueName = this.parsePrefix(queueName, self);
|
|
295
|
+
if (!this.connected) {
|
|
296
|
+
_context6.next = 29;
|
|
470
297
|
break;
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
298
|
+
}
|
|
299
|
+
_context6.prev = 2;
|
|
300
|
+
_context6.next = 5;
|
|
301
|
+
return this.client.createChannel();
|
|
302
|
+
case 5:
|
|
303
|
+
channel = _context6.sent;
|
|
304
|
+
_context6.next = 8;
|
|
305
|
+
return channel.assertQueue(prefixQueueName, {
|
|
306
|
+
durable: true
|
|
307
|
+
});
|
|
308
|
+
case 8:
|
|
309
|
+
_context6.next = 10;
|
|
310
|
+
return channel.prefetch(1);
|
|
311
|
+
case 10:
|
|
312
|
+
messageQueue = this;
|
|
313
|
+
_context6.next = 13;
|
|
314
|
+
return new Promise(function (resolve, reject) {
|
|
315
|
+
channel.consume(prefixQueueName, /*#__PURE__*/function () {
|
|
316
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(msg) {
|
|
317
|
+
var data, errString;
|
|
318
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
319
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
320
|
+
case 0:
|
|
321
|
+
if (!msg) {
|
|
322
|
+
_context5.next = 54;
|
|
323
|
+
break;
|
|
324
|
+
}
|
|
325
|
+
data = JSON.parse(msg.content.toString());
|
|
326
|
+
if (!data) {
|
|
327
|
+
_context5.next = 51;
|
|
328
|
+
break;
|
|
329
|
+
}
|
|
330
|
+
_context5.prev = 3;
|
|
331
|
+
if (!msg.fields.redelivered) {
|
|
332
|
+
_context5.next = 22;
|
|
333
|
+
break;
|
|
334
|
+
}
|
|
335
|
+
data.retry -= 1;
|
|
336
|
+
if (!(data.retry > 0)) {
|
|
337
|
+
_context5.next = 16;
|
|
338
|
+
break;
|
|
339
|
+
}
|
|
340
|
+
if (!messageQueue.worker) {
|
|
341
|
+
_context5.next = 12;
|
|
342
|
+
break;
|
|
343
|
+
}
|
|
344
|
+
_context5.next = 10;
|
|
345
|
+
return messageQueue.send(queueName, _objectSpread(_objectSpread({}, data), {}, {
|
|
346
|
+
self: true
|
|
347
|
+
}));
|
|
348
|
+
case 10:
|
|
349
|
+
_context5.next = 14;
|
|
350
|
+
break;
|
|
351
|
+
case 12:
|
|
352
|
+
_context5.next = 14;
|
|
353
|
+
return messageQueue.send(queueName, data);
|
|
354
|
+
case 14:
|
|
355
|
+
_context5.next = 18;
|
|
356
|
+
break;
|
|
357
|
+
case 16:
|
|
358
|
+
_context5.next = 18;
|
|
359
|
+
return messageQueue.send(messageQueue.parsePrefix('RETRY'), {
|
|
360
|
+
queueName: queueName,
|
|
361
|
+
data: data,
|
|
362
|
+
retry_time: new Date()
|
|
363
|
+
});
|
|
364
|
+
case 18:
|
|
365
|
+
_context5.next = 20;
|
|
366
|
+
return channel.ack(msg);
|
|
367
|
+
case 20:
|
|
368
|
+
_context5.next = 44;
|
|
369
|
+
break;
|
|
370
|
+
case 22:
|
|
371
|
+
_context5.prev = 22;
|
|
372
|
+
_context5.next = 25;
|
|
373
|
+
return asyncFunction(data);
|
|
374
|
+
case 25:
|
|
375
|
+
_context5.next = 27;
|
|
376
|
+
return channel.ack(msg);
|
|
377
|
+
case 27:
|
|
378
|
+
_context5.next = 44;
|
|
379
|
+
break;
|
|
380
|
+
case 29:
|
|
381
|
+
_context5.prev = 29;
|
|
382
|
+
_context5.t0 = _context5["catch"](22);
|
|
383
|
+
errString = _context5.t0.toString();
|
|
384
|
+
if (!_lodash["default"].some(['IllegalOperationError: Channel closed'], function (el) {
|
|
385
|
+
return _lodash["default"].includes(errString, el);
|
|
386
|
+
})) {
|
|
387
|
+
_context5.next = 36;
|
|
388
|
+
break;
|
|
389
|
+
}
|
|
390
|
+
reject(new Error(errString));
|
|
391
|
+
_context5.next = 44;
|
|
392
|
+
break;
|
|
393
|
+
case 36:
|
|
394
|
+
if (callbackError) {
|
|
395
|
+
callbackError(prefixQueueName, _context5.t0);
|
|
396
|
+
}
|
|
397
|
+
if (!(data.retry <= 0)) {
|
|
398
|
+
_context5.next = 42;
|
|
399
|
+
break;
|
|
400
|
+
}
|
|
401
|
+
_context5.next = 40;
|
|
402
|
+
return channel.ack(msg);
|
|
403
|
+
case 40:
|
|
404
|
+
_context5.next = 44;
|
|
405
|
+
break;
|
|
406
|
+
case 42:
|
|
407
|
+
_context5.next = 44;
|
|
408
|
+
return channel.nack(msg);
|
|
409
|
+
case 44:
|
|
410
|
+
_context5.next = 49;
|
|
411
|
+
break;
|
|
412
|
+
case 46:
|
|
413
|
+
_context5.prev = 46;
|
|
414
|
+
_context5.t1 = _context5["catch"](3);
|
|
415
|
+
reject(_context5.t1);
|
|
416
|
+
case 49:
|
|
417
|
+
_context5.next = 52;
|
|
418
|
+
break;
|
|
419
|
+
case 51:
|
|
420
|
+
channel.ack(msg);
|
|
421
|
+
case 52:
|
|
422
|
+
_context5.next = 55;
|
|
423
|
+
break;
|
|
424
|
+
case 54:
|
|
425
|
+
reject(new Error('msg null'));
|
|
426
|
+
case 55:
|
|
427
|
+
case "end":
|
|
428
|
+
return _context5.stop();
|
|
429
|
+
}
|
|
430
|
+
}, _callee5, null, [[3, 46], [22, 29]]);
|
|
431
|
+
}));
|
|
432
|
+
return function (_x7) {
|
|
433
|
+
return _ref.apply(this, arguments);
|
|
434
|
+
};
|
|
435
|
+
}());
|
|
436
|
+
});
|
|
437
|
+
case 13:
|
|
438
|
+
_context6.next = 27;
|
|
439
|
+
break;
|
|
440
|
+
case 15:
|
|
441
|
+
_context6.prev = 15;
|
|
442
|
+
_context6.t0 = _context6["catch"](2);
|
|
443
|
+
_context6.prev = 17;
|
|
444
|
+
_context6.next = 20;
|
|
445
|
+
return channel.close();
|
|
446
|
+
case 20:
|
|
447
|
+
_context6.next = 24;
|
|
448
|
+
break;
|
|
449
|
+
case 22:
|
|
450
|
+
_context6.prev = 22;
|
|
451
|
+
_context6.t1 = _context6["catch"](17);
|
|
452
|
+
case 24:
|
|
453
|
+
_context6.next = 26;
|
|
454
|
+
return (0, _util.timeout)(5000);
|
|
455
|
+
case 26:
|
|
456
|
+
return _context6.abrupt("return", this.consume(queueName, self, asyncFunction, callbackError));
|
|
457
|
+
case 27:
|
|
458
|
+
_context6.next = 32;
|
|
459
|
+
break;
|
|
460
|
+
case 29:
|
|
461
|
+
_context6.next = 31;
|
|
462
|
+
return (0, _util.timeout)(5000);
|
|
463
|
+
case 31:
|
|
464
|
+
return _context6.abrupt("return", this.consume(queueName, self, asyncFunction, callbackError));
|
|
465
|
+
case 32:
|
|
466
|
+
return _context6.abrupt("return", true);
|
|
467
|
+
case 33:
|
|
468
|
+
case "end":
|
|
469
|
+
return _context6.stop();
|
|
482
470
|
}
|
|
483
471
|
}, _callee6, this, [[2, 15], [17, 22]]);
|
|
484
472
|
}));
|
|
@@ -492,14 +480,12 @@ var RabbitMQAsync = /*#__PURE__*/function () {
|
|
|
492
480
|
value: function () {
|
|
493
481
|
var _selfReceiving = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(queueName, asyncFunction, callbackError) {
|
|
494
482
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
495
|
-
while (1) {
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
return _context7.stop();
|
|
502
|
-
}
|
|
483
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
484
|
+
case 0:
|
|
485
|
+
this.consume(queueName, true, asyncFunction, callbackError);
|
|
486
|
+
case 1:
|
|
487
|
+
case "end":
|
|
488
|
+
return _context7.stop();
|
|
503
489
|
}
|
|
504
490
|
}, _callee7, this);
|
|
505
491
|
}));
|
|
@@ -515,18 +501,16 @@ var RabbitMQAsync = /*#__PURE__*/function () {
|
|
|
515
501
|
var callbackError,
|
|
516
502
|
_args8 = arguments;
|
|
517
503
|
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
518
|
-
while (1) {
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
return _context8.stop();
|
|
529
|
-
}
|
|
504
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
505
|
+
case 0:
|
|
506
|
+
callbackError = _args8.length > 2 && _args8[2] !== undefined ? _args8[2] : null;
|
|
507
|
+
this.consume(queueName, false, asyncFunction, callbackError);
|
|
508
|
+
if (this.worker) {
|
|
509
|
+
this.selfReceiving(queueName, asyncFunction, callbackError);
|
|
510
|
+
}
|
|
511
|
+
case 3:
|
|
512
|
+
case "end":
|
|
513
|
+
return _context8.stop();
|
|
530
514
|
}
|
|
531
515
|
}, _callee8, this);
|
|
532
516
|
}));
|
package/package.json
CHANGED
|
@@ -1 +1,24 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"name": "@azteam/rabbitmq-async",
|
|
3
|
+
"version": "1.0.198",
|
|
4
|
+
"description": "N/A",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"toda",
|
|
7
|
+
"nodejs",
|
|
8
|
+
"rabbitmq",
|
|
9
|
+
"rabbitmq async"
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"author": "toda <sp.azsolution.net@gmail.com>",
|
|
13
|
+
"main": "./lib/index.js",
|
|
14
|
+
"module": "./src/index.js",
|
|
15
|
+
"scripts": {
|
|
16
|
+
"prepublishOnly": "babel src --delete-dir-on-start -d lib"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@azteam/util": "1.0.47",
|
|
20
|
+
"amqplib": "0.8.0",
|
|
21
|
+
"fs-extra": "10.1.0",
|
|
22
|
+
"lodash": "4.17.21"
|
|
23
|
+
}
|
|
24
|
+
}
|