@resolveio/server-lib 9.9.13 → 9.9.15
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.
|
@@ -85,20 +85,14 @@ var MongoManager = /** @class */ (function () {
|
|
|
85
85
|
MongoManager.prototype.addToQueue = function (mongoQueue) {
|
|
86
86
|
var _mongoQueue = this._mongoQueue.filter(function (a) { return a.name_collection === mongoQueue.name_collection && a.name_function === mongoQueue.name_function && a.name_function_addt === mongoQueue.name_function_addt && JSON.stringify(a.data_function) === JSON.stringify(mongoQueue.data_function) && JSON.stringify(a.data_function_addt) === JSON.stringify(mongoQueue.data_function_addt); })[0];
|
|
87
87
|
if (_mongoQueue) {
|
|
88
|
-
if (mongoQueue.name_collection !== 'logged-in-users' && mongoQueue.name_collection !== 'cron-jobs') {
|
|
89
|
-
console.log(new Date(), 'Add To queue - found queue', mongoQueue.name_collection, mongoQueue.running, mongoQueue.name_function, JSON.stringify(mongoQueue.data_function));
|
|
90
|
-
}
|
|
91
88
|
if (!_mongoQueue.running) {
|
|
92
89
|
_mongoQueue.cbs.push(mongoQueue.cbs[0]);
|
|
93
90
|
}
|
|
94
91
|
else {
|
|
95
|
-
_mongoQueue.cbs_next
|
|
92
|
+
_mongoQueue.cbs_next.push(mongoQueue.cbs[0]);
|
|
96
93
|
}
|
|
97
94
|
}
|
|
98
95
|
else {
|
|
99
|
-
if (mongoQueue.name_collection !== 'logged-in-users' && mongoQueue.name_collection !== 'cron-jobs') {
|
|
100
|
-
console.log(new Date(), 'Add To queue - new queue', mongoQueue.name_collection, mongoQueue.name_function, JSON.stringify(mongoQueue.data_function));
|
|
101
|
-
}
|
|
102
96
|
mongoQueue._id = this._mongoQueueId;
|
|
103
97
|
this._mongoQueueId += 1;
|
|
104
98
|
this._mongoQueue.splice(0, 0, mongoQueue);
|
|
@@ -118,9 +112,6 @@ var MongoManager = /** @class */ (function () {
|
|
|
118
112
|
var mongoQueue = queueArr[i];
|
|
119
113
|
mongoQueue.running = true;
|
|
120
114
|
mongoQueue.invalidateFlag = false;
|
|
121
|
-
if (mongoQueue.name_collection !== 'logged-in-users' && mongoQueue.name_collection !== 'cron-jobs') {
|
|
122
|
-
console.log(new Date(), 'Run queue - Before', mongoQueue.cacheId, mongoQueue.name_collection, mongoQueue.name_function, JSON.stringify(mongoQueue.data_function));
|
|
123
|
-
}
|
|
124
115
|
if (mongoQueue.cacheId) {
|
|
125
116
|
var res_1 = JSON.parse(_this._nodeCache.get(mongoQueue.cacheId), common_1.dateReviver);
|
|
126
117
|
mongoQueue.cbs.forEach(function (cb) {
|
|
@@ -128,19 +119,10 @@ var MongoManager = /** @class */ (function () {
|
|
|
128
119
|
});
|
|
129
120
|
mongoQueue.cbs = [];
|
|
130
121
|
mongoQueue.running = false;
|
|
131
|
-
if (mongoQueue.name_collection !== 'logged-in-users' && mongoQueue.name_collection !== 'cron-jobs') {
|
|
132
|
-
console.log(new Date(), 'Send Cache', mongoQueue.cacheId, mongoQueue.invalidateFlag, mongoQueue.name_collection, mongoQueue.running, mongoQueue.name_function, JSON.stringify(mongoQueue.data_function), mongoQueue.cbs_next.length);
|
|
133
|
-
}
|
|
134
122
|
}
|
|
135
123
|
else {
|
|
136
124
|
if (!mongoQueue.name_function_addt) {
|
|
137
|
-
if (mongoQueue.name_collection !== 'logged-in-users' && mongoQueue.name_collection !== 'cron-jobs') {
|
|
138
|
-
console.log(new Date(), 'Before Funct 1', mongoQueue.invalidateFlag, mongoQueue.name_collection, mongoQueue.running, mongoQueue.name_function, JSON.stringify(mongoQueue.data_function), mongoQueue.cbs_next.length);
|
|
139
|
-
}
|
|
140
125
|
(_a = index_1.ResolveIOServer.getMainDB().collection(mongoQueue.name_collection))[mongoQueue.name_function].apply(_a, mongoQueue.data_function).then(function (res) {
|
|
141
|
-
if (mongoQueue.name_collection !== 'logged-in-users' && mongoQueue.name_collection !== 'cron-jobs') {
|
|
142
|
-
console.log(new Date(), 'After Funct 1', mongoQueue.invalidateFlag, mongoQueue.name_collection, mongoQueue.running, mongoQueue.name_function, JSON.stringify(mongoQueue.data_function), mongoQueue.cbs_next.length);
|
|
143
|
-
}
|
|
144
126
|
if (!mongoQueue.invalidateFlag) {
|
|
145
127
|
mongoQueue.cacheId = _this._mongoQueueCacheId;
|
|
146
128
|
_this._mongoQueueCacheId += 1;
|
|
@@ -148,13 +130,16 @@ var MongoManager = /** @class */ (function () {
|
|
|
148
130
|
mongoQueue.cbs.forEach(function (cb) {
|
|
149
131
|
cb(null, res, false);
|
|
150
132
|
});
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
133
|
+
if (mongoQueue.cbs_next.length) {
|
|
134
|
+
mongoQueue.cbs = mongoQueue.cbs_next;
|
|
135
|
+
mongoQueue.cbs_next = [];
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
mongoQueue.cbs = [];
|
|
139
|
+
}
|
|
155
140
|
}
|
|
156
141
|
else {
|
|
157
|
-
mongoQueue.cbs =
|
|
142
|
+
mongoQueue.cbs = mongoQueue.cbs.concat(mongoQueue.cbs_next);
|
|
158
143
|
}
|
|
159
144
|
mongoQueue.running = false;
|
|
160
145
|
}, function (err) {
|
|
@@ -170,13 +155,7 @@ var MongoManager = /** @class */ (function () {
|
|
|
170
155
|
});
|
|
171
156
|
}
|
|
172
157
|
else {
|
|
173
|
-
if (mongoQueue.name_collection !== 'logged-in-users' && mongoQueue.name_collection !== 'cron-jobs') {
|
|
174
|
-
console.log(new Date(), 'Before Funct 2', mongoQueue.invalidateFlag, mongoQueue.name_collection, mongoQueue.running, mongoQueue.name_function, JSON.stringify(mongoQueue.data_function), mongoQueue.cbs_next.length);
|
|
175
|
-
}
|
|
176
158
|
(_b = (_c = index_1.ResolveIOServer.getMainDB().collection(mongoQueue.name_collection))[mongoQueue.name_function].apply(_c, mongoQueue.data_function))[mongoQueue.name_function_addt].apply(_b, mongoQueue.data_function_addt).then(function (res) {
|
|
177
|
-
if (mongoQueue.name_collection !== 'logged-in-users' && mongoQueue.name_collection !== 'cron-jobs') {
|
|
178
|
-
console.log(new Date(), 'After Funct 2', mongoQueue.invalidateFlag, mongoQueue.name_collection, mongoQueue.running, mongoQueue.name_function, JSON.stringify(mongoQueue.data_function), mongoQueue.cbs_next.length);
|
|
179
|
-
}
|
|
180
159
|
if (!mongoQueue.invalidateFlag) {
|
|
181
160
|
mongoQueue.cacheId = _this._mongoQueueCacheId;
|
|
182
161
|
_this._mongoQueueCacheId += 1;
|
|
@@ -184,13 +163,16 @@ var MongoManager = /** @class */ (function () {
|
|
|
184
163
|
mongoQueue.cbs.forEach(function (cb) {
|
|
185
164
|
cb(null, res, false);
|
|
186
165
|
});
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
166
|
+
if (mongoQueue.cbs_next.length) {
|
|
167
|
+
mongoQueue.cbs = mongoQueue.cbs_next;
|
|
168
|
+
mongoQueue.cbs_next = [];
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
mongoQueue.cbs = [];
|
|
172
|
+
}
|
|
191
173
|
}
|
|
192
174
|
else {
|
|
193
|
-
mongoQueue.cbs =
|
|
175
|
+
mongoQueue.cbs = mongoQueue.cbs.concat(mongoQueue.cbs_next);
|
|
194
176
|
}
|
|
195
177
|
mongoQueue.running = false;
|
|
196
178
|
}, function (err) {
|
|
@@ -235,29 +217,23 @@ var MongoManager = /** @class */ (function () {
|
|
|
235
217
|
if (nodeCacheSize < this._heapLimit * 0.75) {
|
|
236
218
|
break;
|
|
237
219
|
}
|
|
238
|
-
if (queue.name_collection !== 'logged-in-users' && queue.name_collection !== 'cron-jobs') {
|
|
239
|
-
console.log(new Date(), 'Deleting Cache', queue.name_collection, queue.running, queue.name_function, JSON.stringify(queue.data_function));
|
|
240
|
-
}
|
|
241
220
|
}
|
|
242
221
|
console.log('Query Cache: ' + 'Too Big, - Deleted: ' + deleteCount + ' - ' + nodeCacheSize);
|
|
243
222
|
}
|
|
244
|
-
// console.log(new Date(), 'Add To Cache', JSON.stringify(data));
|
|
245
223
|
this._nodeCache.set(id, JSON.stringify(data));
|
|
246
224
|
};
|
|
247
225
|
MongoManager.prototype.invalidateQueryCache = function (collection) {
|
|
248
226
|
var queueArr = this._mongoQueue.filter(function (a) { return (a.name_collection === collection || a.lookup_collections.includes(collection)); });
|
|
249
227
|
for (var i = queueArr.length - 1; i >= 0; i--) {
|
|
250
228
|
var queue = queueArr[i];
|
|
229
|
+
if (queue.cacheId) {
|
|
230
|
+
this._nodeCache.del(queue.cacheId);
|
|
231
|
+
}
|
|
251
232
|
if (queue.running) {
|
|
252
233
|
queue.invalidateFlag = true;
|
|
253
|
-
|
|
234
|
+
queue.cacheId = 0;
|
|
254
235
|
}
|
|
255
236
|
else if (queue.cacheId) {
|
|
256
|
-
this._nodeCache.del(queue.cacheId);
|
|
257
|
-
queue.cacheId = 0;
|
|
258
|
-
if (queue.name_collection !== 'logged-in-users' && queue.name_collection !== 'cron-jobs') {
|
|
259
|
-
console.log(new Date(), 'Invalidate query', queue.name_collection, queue.running, queue.name_function, JSON.stringify(queue.data_function));
|
|
260
|
-
}
|
|
261
237
|
if (this._mongoQueue.map(function (a) { return a._id; }).indexOf(queue._id) >= 0) {
|
|
262
238
|
this._mongoQueue.splice(this._mongoQueue.map(function (a) { return a._id; }).indexOf(queue._id), 1);
|
|
263
239
|
}
|