UNPKG

owhat-job

Version:

owhat红包清理

202 lines (159 loc) 11.7 kB
'use strict'; var _regenerator = require('babel-runtime/regenerator'); var _regenerator2 = _interopRequireDefault(_regenerator); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; var _gcl = require('gcl'); var _gcl2 = _interopRequireDefault(_gcl); var _myprocesscontroller = require('myprocesscontroller'); var _myprocesscontroller2 = _interopRequireDefault(_myprocesscontroller); var _ASCDealer = require('./ASCDealer'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } //console.log = function() {}; _myprocesscontroller2.default.start(_asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee5() { var conf, count, that; return _regenerator2.default.wrap(function _callee5$(_context5) { while (1) { switch (_context5.prev = _context5.next) { case 0: conf = C.AppSettings(this.Config, "dy"); if (conf) { _context5.next = 3; break; } throw new Error('配置获取失败!'); case 3: count = {}; that = this; return _context5.abrupt('return', new _myprocesscontroller2.default.CACProcess(new (function (_pro$ABulkWorker) { _inherits(_class, _pro$ABulkWorker); function _class() { _classCallCheck(this, _class); return _possibleConstructorReturn(this, (_class.__proto__ || Object.getPrototypeOf(_class)).call(this, 'wk', threadcount, 1000, 6000000, max)); } _createClass(_class, [{ key: 'getData', value: function () { var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee(data) { return _regenerator2.default.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: console.log('获取数据'); return _context.abrupt('return', null); case 2: case 'end': return _context.stop(); } } }, _callee, this); })); function getData(_x) { return _ref2.apply(this, arguments); } return getData; }() }, { key: 'bulkcustom', value: function () { var _ref3 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2(ret2, data) { var ret; return _regenerator2.default.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: if (!data.array) data.array = 1;else data.array++; if (!data.client) { data.Log = that.Log; data.Ni = that.Ni; data.Config = that.Config; } ret = ret2; //todo hear and ret2 is Array return _context2.abrupt('return', false); case 4: case 'end': return _context2.stop(); } } }, _callee2, this); })); function bulkcustom(_x2, _x3) { return _ref3.apply(this, arguments); } return bulkcustom; }() }, { key: 'rollback', value: function () { var _ref4 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee3(v, data) { return _regenerator2.default.wrap(function _callee3$(_context3) { while (1) { switch (_context3.prev = _context3.next) { case 0: console.log('rollback 抛弃数据', v); return _context3.abrupt('return', false); case 2: case 'end': return _context3.stop(); } } }, _callee3, this); })); function rollback(_x4, _x5) { return _ref4.apply(this, arguments); } return rollback; }() }, { key: 'dispose', value: function () { var _ref5 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee4(data) { return _regenerator2.default.wrap(function _callee4$(_context4) { while (1) { switch (_context4.prev = _context4.next) { case 0: _context4.prev = 0; _context4.next = 3; return _get(_class.prototype.__proto__ || Object.getPrototypeOf(_class.prototype), 'dispose', this).call(this, data); case 3: _context4.next = 8; break; case 5: _context4.prev = 5; _context4.t0 = _context4['catch'](0); console.log('dispose', _context4.t0.message); case 8: _context4.prev = 8; //todo 关闭特有资源 delete data.Log; delete data.Ni; delete data.Config; return _context4.finish(8); case 13: return _context4.abrupt('return', false); case 14: case 'end': return _context4.stop(); } } }, _callee4, this, [[0, 5, 8, 13]]); })); function dispose(_x6) { return _ref5.apply(this, arguments); } return dispose; }() }]); return _class; }(_myprocesscontroller2.default.ABulkWorker))(), this.Log, threadcount, 10000)); case 6: case 'end': return _context5.stop(); } } }, _callee5, this); })));