@resolveio/server-lib 9.6.30 → 9.6.32

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.
@@ -13,6 +13,8 @@ interface MongoQueueModel {
13
13
  cbs_next: Function[];
14
14
  running: boolean;
15
15
  cacheId: number;
16
+ next_run?: Date;
17
+ last_run?: Date;
16
18
  }
17
19
  export declare class MongoManager {
18
20
  private _collections;
@@ -59,6 +59,7 @@ var log_collection_1 = require("../collections/log.collection");
59
59
  var NodeCache = require("node-cache");
60
60
  var crypto = require('crypto');
61
61
  var scmp = require('scmp');
62
+ var moment = require("moment");
62
63
  var MongoManager = /** @class */ (function () {
63
64
  function MongoManager() {
64
65
  this._collections = [];
@@ -85,6 +86,7 @@ var MongoManager = /** @class */ (function () {
85
86
  }
86
87
  else {
87
88
  _mongoQueue.cbs_next.push(mongoQueue.cbs[0]);
89
+ _mongoQueue.next_run = moment().add(1, 'second').toDate();
88
90
  }
89
91
  }
90
92
  else {
@@ -98,7 +100,7 @@ var MongoManager = /** @class */ (function () {
98
100
  var _this = this;
99
101
  return __generator(this, function (_a) {
100
102
  setInterval(function () {
101
- var queueArr = _this._mongoQueue.filter(function (a) { return !a.running && a.cbs.length; });
103
+ var queueArr = _this._mongoQueue.filter(function (a) { return !a.running && a.cbs.length && (!a.next_run || a.next_run.getTime() <= Date.now()); });
102
104
  if (queueArr.length) {
103
105
  var _loop_1 = function (i) {
104
106
  var _a, _b, _c;
@@ -113,6 +115,7 @@ var MongoManager = /** @class */ (function () {
113
115
  mongoQueue.running = false;
114
116
  }
115
117
  else {
118
+ mongoQueue.last_run = new Date();
116
119
  if (!mongoQueue.name_function_addt) {
117
120
  (_a = index_1.ResolveIOServer.getMainDB().collection(mongoQueue.name_collection))[mongoQueue.name_function].apply(_a, mongoQueue.data_function).then(function (res) {
118
121
  mongoQueue.cacheId = _this._mongoQueueCacheId;
@@ -188,7 +191,7 @@ var MongoManager = /** @class */ (function () {
188
191
  queueArr[zz].cacheId = 0;
189
192
  deleteCount += 1;
190
193
  nodeCacheSize = this._nodeCache.getStats().vsize;
191
- if (nodeCacheSize < 100000000) {
194
+ if (nodeCacheSize < 750000000) {
192
195
  break;
193
196
  }
194
197
  }