@resolveio/server-lib 9.7.5 → 9.7.7
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.
|
@@ -65,20 +65,10 @@ var common_1 = require("../util/common");
|
|
|
65
65
|
var moment = require("moment");
|
|
66
66
|
var NodeCache = require("node-cache");
|
|
67
67
|
var v8 = require('v8');
|
|
68
|
-
//
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
// publication: string;
|
|
72
|
-
// subscriptionData: any[];
|
|
73
|
-
// date_start: Date;
|
|
74
|
-
// date_end: Date;
|
|
75
|
-
// duration: number;
|
|
76
|
-
// result: string;
|
|
77
|
-
// }
|
|
68
|
+
// Performance Dependencies
|
|
69
|
+
var path = require("path");
|
|
70
|
+
var Worker = require('worker_threads').Worker;
|
|
78
71
|
var SubscriptionManager = /** @class */ (function () {
|
|
79
|
-
// private currentPerfomanceMonitor: CurrentPerformanceMonitor[] = [];
|
|
80
|
-
// private idPerformance: number = 0;
|
|
81
|
-
// private performanceThread;
|
|
82
72
|
function SubscriptionManager(mainServer, wss, serverConfig) {
|
|
83
73
|
var _this = this;
|
|
84
74
|
this._publications = {};
|
|
@@ -91,24 +81,26 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
91
81
|
this._cacheId = 1;
|
|
92
82
|
this._heapStats = v8.getHeapStatistics();
|
|
93
83
|
this._heapLimit = 0;
|
|
84
|
+
this.currentPerfomanceMonitor = [];
|
|
85
|
+
this.idPerformance = 0;
|
|
94
86
|
this._mainServer = mainServer;
|
|
95
87
|
this._nodeCache = new NodeCache({ stdTTL: 0, checkperiod: 0 });
|
|
96
88
|
this._heapLimit = this._heapStats.heap_size_limit / 4;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
89
|
+
setTimeout(function () {
|
|
90
|
+
console.log('Setting up performance thread');
|
|
91
|
+
_this.performanceThread = new Worker(path.join(__dirname, './subscription.performance.js'));
|
|
92
|
+
_this.performanceThread.on('exit', function (code) {
|
|
93
|
+
console.error(new Date(), 'THREAD EXITED!!!!!!!!!!!!!!!!!!', code);
|
|
94
|
+
});
|
|
95
|
+
_this.performanceThread.on('error', function (code) {
|
|
96
|
+
console.error(new Date(), 'THREAD RECV ERROR !!!!!!!!!!!!!!!!!!', code);
|
|
97
|
+
});
|
|
98
|
+
}, 5000);
|
|
99
|
+
setInterval(function () {
|
|
100
|
+
console.log('Post thread msg');
|
|
101
|
+
_this.performanceThread.postMessage(_this.currentPerfomanceMonitor);
|
|
102
|
+
_this.currentPerfomanceMonitor = [];
|
|
103
|
+
}, 10000);
|
|
112
104
|
this.serverConfig = serverConfig;
|
|
113
105
|
this._wss = wss;
|
|
114
106
|
// Publications
|
|
@@ -128,12 +120,12 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
128
120
|
report_builder_dashboard_builders_1.loadReportBuilderDashboardBuilderPublications(this);
|
|
129
121
|
this.tailOpLog();
|
|
130
122
|
setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
131
|
-
var _loop_1, this_1, i, queueArr, i, mongoQueue, j, client, ws;
|
|
123
|
+
var startDate, _loop_1, this_1, i, endDate, queueArr, startDate, i, mongoQueue, j, client, ws, endDate;
|
|
132
124
|
var _this = this;
|
|
133
125
|
return __generator(this, function (_a) {
|
|
134
126
|
if (!this._runningQueue) {
|
|
135
127
|
if (this._sendQueue.length) {
|
|
136
|
-
|
|
128
|
+
startDate = new Date();
|
|
137
129
|
this._runningQueue = true;
|
|
138
130
|
_loop_1 = function (i) {
|
|
139
131
|
var ws = this_1._mainServer.getWS(this_1._sendQueue[i].id_ws);
|
|
@@ -157,17 +149,17 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
157
149
|
_loop_1(i);
|
|
158
150
|
}
|
|
159
151
|
this._runningQueue = false;
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
152
|
+
endDate = new Date();
|
|
153
|
+
this.currentPerfomanceMonitor.push({
|
|
154
|
+
_id: this.idPerformance++,
|
|
155
|
+
function: 'sendInterval',
|
|
156
|
+
publication: '',
|
|
157
|
+
subscriptionData: [],
|
|
158
|
+
date_start: startDate,
|
|
159
|
+
date_end: endDate,
|
|
160
|
+
duration: moment(endDate).diff(moment(startDate), 'milliseconds', false),
|
|
161
|
+
result: 'Done'
|
|
162
|
+
});
|
|
171
163
|
}
|
|
172
164
|
}
|
|
173
165
|
queueArr = this._mongoQueue.filter(function (a) { return !a.running; });
|
|
@@ -175,7 +167,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
175
167
|
queueArr.forEach(function (entry) {
|
|
176
168
|
entry.running = true;
|
|
177
169
|
});
|
|
178
|
-
|
|
170
|
+
startDate = new Date();
|
|
179
171
|
for (i = queueArr.length - 1; i >= 0; i--) {
|
|
180
172
|
mongoQueue = queueArr[i];
|
|
181
173
|
if (this._publications[mongoQueue.subscription.publication].ws_specific) {
|
|
@@ -198,17 +190,17 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
198
190
|
this._mongoQueue.splice(this._mongoQueue.map(function (a) { return a._id; }).indexOf(mongoQueue._id), 1);
|
|
199
191
|
}
|
|
200
192
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
193
|
+
endDate = new Date();
|
|
194
|
+
this.currentPerfomanceMonitor.push({
|
|
195
|
+
_id: this.idPerformance++,
|
|
196
|
+
function: 'mongoQueue',
|
|
197
|
+
publication: '',
|
|
198
|
+
subscriptionData: queueArr,
|
|
199
|
+
date_start: startDate,
|
|
200
|
+
date_end: endDate,
|
|
201
|
+
duration: moment(endDate).diff(moment(startDate), 'milliseconds', false),
|
|
202
|
+
result: 'Done'
|
|
203
|
+
});
|
|
212
204
|
}
|
|
213
205
|
return [2 /*return*/];
|
|
214
206
|
});
|
|
@@ -268,61 +260,63 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
268
260
|
}); }, 30000);
|
|
269
261
|
}
|
|
270
262
|
SubscriptionManager.prototype.addToQueue = function (mongoQueue) {
|
|
271
|
-
|
|
263
|
+
var startDate = new Date();
|
|
272
264
|
var _mongoQueue = this._mongoQueue.filter(function (a) { return a.subscription.publication === mongoQueue.subscription.publication && JSON.stringify(a.subscription.subscriptionData) === JSON.stringify(mongoQueue.subscription.subscriptionData); })[0];
|
|
273
265
|
if (_mongoQueue) {
|
|
274
266
|
if (_mongoQueue.running) {
|
|
275
267
|
_mongoQueue.run_again = true;
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
268
|
+
var endDate = new Date();
|
|
269
|
+
this.currentPerfomanceMonitor.push({
|
|
270
|
+
_id: this.idPerformance++,
|
|
271
|
+
function: 'addToQueue',
|
|
272
|
+
publication: mongoQueue.subscription.publication,
|
|
273
|
+
subscriptionData: mongoQueue.subscription.subscriptionData,
|
|
274
|
+
date_start: startDate,
|
|
275
|
+
date_end: endDate,
|
|
276
|
+
duration: moment(endDate).diff(moment(startDate), 'milliseconds', false),
|
|
277
|
+
result: 'Run Again'
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
var endDate = new Date();
|
|
282
|
+
this.currentPerfomanceMonitor.push({
|
|
283
|
+
_id: this.idPerformance++,
|
|
284
|
+
function: 'addToQueue',
|
|
285
|
+
publication: mongoQueue.subscription.publication,
|
|
286
|
+
subscriptionData: mongoQueue.subscription.subscriptionData,
|
|
287
|
+
date_start: startDate,
|
|
288
|
+
date_end: endDate,
|
|
289
|
+
duration: moment(endDate).diff(moment(startDate), 'milliseconds', false),
|
|
290
|
+
result: 'Not Running Yet'
|
|
291
|
+
});
|
|
287
292
|
}
|
|
288
|
-
// else {
|
|
289
|
-
// let endDate = new Date();
|
|
290
|
-
// this.currentPerfomanceMonitor.push({
|
|
291
|
-
// _id: this.idPerformance++,
|
|
292
|
-
// function: 'addToQueue',
|
|
293
|
-
// publication: mongoQueue.subscription.publication,
|
|
294
|
-
// subscriptionData: mongoQueue.subscription.subscriptionData,
|
|
295
|
-
// date_start: startDate,
|
|
296
|
-
// date_end: endDate,
|
|
297
|
-
// duration: moment(endDate).diff(moment(startDate), 'milliseconds', false),
|
|
298
|
-
// result: 'Not Running Yet'
|
|
299
|
-
// });
|
|
300
|
-
// }
|
|
301
293
|
}
|
|
302
294
|
else {
|
|
303
295
|
mongoQueue._id = this._mongoQueueId;
|
|
304
296
|
this._mongoQueueId += 1;
|
|
305
297
|
this._mongoQueue.splice(0, 0, mongoQueue);
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
298
|
+
var endDate = new Date();
|
|
299
|
+
this.currentPerfomanceMonitor.push({
|
|
300
|
+
_id: this.idPerformance++,
|
|
301
|
+
function: 'addToQueue',
|
|
302
|
+
publication: mongoQueue.subscription.publication,
|
|
303
|
+
subscriptionData: mongoQueue.subscription.subscriptionData,
|
|
304
|
+
date_start: startDate,
|
|
305
|
+
date_end: endDate,
|
|
306
|
+
duration: moment(endDate).diff(moment(startDate), 'milliseconds', false),
|
|
307
|
+
result: 'Add to Queue'
|
|
308
|
+
});
|
|
317
309
|
}
|
|
318
310
|
};
|
|
319
311
|
SubscriptionManager.prototype.invalidatePubsCache = function (collection, type) {
|
|
320
|
-
|
|
312
|
+
var startDate = new Date();
|
|
321
313
|
var collSubs = this._subscriptions.filter(function (a) { return a.collections.includes(collection); });
|
|
322
314
|
for (var i = collSubs.length - 1; i >= 0; i--) {
|
|
323
315
|
var sub = collSubs[i];
|
|
324
|
-
|
|
325
|
-
|
|
316
|
+
if (sub.cacheId) {
|
|
317
|
+
this._nodeCache.del(sub.cacheId);
|
|
318
|
+
sub.cacheId = 0;
|
|
319
|
+
}
|
|
326
320
|
this.addToQueue({
|
|
327
321
|
_id: 0,
|
|
328
322
|
type: type,
|
|
@@ -333,17 +327,17 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
333
327
|
});
|
|
334
328
|
}
|
|
335
329
|
index_1.ResolveIOServer.getMongoManager().invalidateQueryCache(collection);
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
330
|
+
var endDate = new Date();
|
|
331
|
+
this.currentPerfomanceMonitor.push({
|
|
332
|
+
_id: this.idPerformance++,
|
|
333
|
+
function: 'invalidatePubsCache',
|
|
334
|
+
publication: collection,
|
|
335
|
+
subscriptionData: [],
|
|
336
|
+
date_start: startDate,
|
|
337
|
+
date_end: endDate,
|
|
338
|
+
duration: moment(endDate).diff(moment(startDate), 'milliseconds', false),
|
|
339
|
+
result: 'Done'
|
|
340
|
+
});
|
|
347
341
|
};
|
|
348
342
|
// Add all files to publications private object
|
|
349
343
|
SubscriptionManager.prototype.publications = function (method) {
|
|
@@ -377,8 +371,9 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
377
371
|
subscriptionData[_i - 4] = arguments[_i];
|
|
378
372
|
}
|
|
379
373
|
return __awaiter(this, void 0, void 0, function () {
|
|
380
|
-
var pub, valObj, valKeys, rootKeys, i, sub_1, newLoggedInUser;
|
|
374
|
+
var startDate, pub, valObj, valKeys, rootKeys, i, sub_1, endDate, endDate, newLoggedInUser;
|
|
381
375
|
return __generator(this, function (_a) {
|
|
376
|
+
startDate = new Date();
|
|
382
377
|
pub = this._publications[publication];
|
|
383
378
|
if (!pub) {
|
|
384
379
|
console.error(new Date(), 'No Publication: ' + publication);
|
|
@@ -449,31 +444,31 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
449
444
|
running: false,
|
|
450
445
|
run_again: false
|
|
451
446
|
});
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
447
|
+
endDate = new Date();
|
|
448
|
+
this.currentPerfomanceMonitor.push({
|
|
449
|
+
_id: this.idPerformance++,
|
|
450
|
+
function: 'subscribe',
|
|
451
|
+
publication: publication,
|
|
452
|
+
subscriptionData: subscriptionData,
|
|
453
|
+
date_start: startDate,
|
|
454
|
+
date_end: endDate,
|
|
455
|
+
duration: moment(endDate).diff(moment(startDate), 'milliseconds', false),
|
|
456
|
+
result: 'Add to Queue'
|
|
457
|
+
});
|
|
463
458
|
}
|
|
464
459
|
else if (sub_1.cacheId) {
|
|
465
460
|
this.sendPubDataOnce(ws, messageId, sub_1, 'newSub', publication);
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
461
|
+
endDate = new Date();
|
|
462
|
+
this.currentPerfomanceMonitor.push({
|
|
463
|
+
_id: this.idPerformance++,
|
|
464
|
+
function: 'subscribe',
|
|
465
|
+
publication: publication,
|
|
466
|
+
subscriptionData: subscriptionData,
|
|
467
|
+
date_start: startDate,
|
|
468
|
+
date_end: endDate,
|
|
469
|
+
duration: moment(endDate).diff(moment(startDate), 'milliseconds', false),
|
|
470
|
+
result: 'Send Pub Data Once'
|
|
471
|
+
});
|
|
477
472
|
}
|
|
478
473
|
}
|
|
479
474
|
if (publication === 'appversion') {
|
|
@@ -507,9 +502,9 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
507
502
|
subscriptionData[_i - 4] = arguments[_i];
|
|
508
503
|
}
|
|
509
504
|
return __awaiter(this, void 0, void 0, function () {
|
|
510
|
-
var sub, i;
|
|
505
|
+
var startDate, sub, i, endDate;
|
|
511
506
|
return __generator(this, function (_a) {
|
|
512
|
-
|
|
507
|
+
startDate = new Date();
|
|
513
508
|
// console.log('Before');
|
|
514
509
|
// console.dir(this._subscriptions.map(a => a.publication));
|
|
515
510
|
if (!this._publications[publication]) {
|
|
@@ -526,6 +521,17 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
526
521
|
}
|
|
527
522
|
}
|
|
528
523
|
}
|
|
524
|
+
endDate = new Date();
|
|
525
|
+
this.currentPerfomanceMonitor.push({
|
|
526
|
+
_id: this.idPerformance++,
|
|
527
|
+
function: 'unsubscribe',
|
|
528
|
+
publication: publication,
|
|
529
|
+
subscriptionData: subscriptionData,
|
|
530
|
+
date_start: startDate,
|
|
531
|
+
date_end: endDate,
|
|
532
|
+
duration: moment(endDate).diff(moment(startDate), 'milliseconds', false),
|
|
533
|
+
result: 'Done'
|
|
534
|
+
});
|
|
529
535
|
return [2 /*return*/];
|
|
530
536
|
});
|
|
531
537
|
});
|
|
@@ -533,10 +539,11 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
533
539
|
// Unsubscribe from publication
|
|
534
540
|
SubscriptionManager.prototype.unsubscribeAll = function (ws) {
|
|
535
541
|
return __awaiter(this, void 0, void 0, function () {
|
|
536
|
-
var loggedInUser, userSubs, i, sub, j;
|
|
542
|
+
var startDate, loggedInUser, userSubs, i, sub, j, endDate;
|
|
537
543
|
return __generator(this, function (_a) {
|
|
538
544
|
switch (_a.label) {
|
|
539
545
|
case 0:
|
|
546
|
+
startDate = new Date();
|
|
540
547
|
if (!ws) return [3 /*break*/, 2];
|
|
541
548
|
return [4 /*yield*/, logged_in_users_collection_1.LoggedInUsers.findOne({ id_ws: ws['id_socket'] })];
|
|
542
549
|
case 1:
|
|
@@ -557,6 +564,17 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
557
564
|
}
|
|
558
565
|
}
|
|
559
566
|
ws.terminate();
|
|
567
|
+
endDate = new Date();
|
|
568
|
+
this.currentPerfomanceMonitor.push({
|
|
569
|
+
_id: this.idPerformance++,
|
|
570
|
+
function: 'unsubscribeAll',
|
|
571
|
+
publication: '',
|
|
572
|
+
subscriptionData: [ws['id_socket']],
|
|
573
|
+
date_start: startDate,
|
|
574
|
+
date_end: endDate,
|
|
575
|
+
duration: moment(endDate).diff(moment(startDate), 'milliseconds', false),
|
|
576
|
+
result: 'Done'
|
|
577
|
+
});
|
|
560
578
|
_a.label = 2;
|
|
561
579
|
case 2: return [2 /*return*/];
|
|
562
580
|
}
|
|
@@ -572,7 +590,7 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
572
590
|
var _this = this;
|
|
573
591
|
this._oplog = index_1.ResolveIOServer.getMainDB().watch();
|
|
574
592
|
this._oplog.on('change', function (doc) {
|
|
575
|
-
|
|
593
|
+
var startDate = new Date();
|
|
576
594
|
if (doc.ns) {
|
|
577
595
|
var collection = doc.ns.coll;
|
|
578
596
|
// console.log(new Date(), 'Op log doc', doc.operationType, collection);
|
|
@@ -590,17 +608,17 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
590
608
|
if (collection !== 'method-responses') {
|
|
591
609
|
_this.invalidatePubsCache(collection, 'insert');
|
|
592
610
|
}
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
611
|
+
var endDate = new Date();
|
|
612
|
+
_this.currentPerfomanceMonitor.push({
|
|
613
|
+
_id: _this.idPerformance++,
|
|
614
|
+
function: 'oplog',
|
|
615
|
+
publication: collection,
|
|
616
|
+
subscriptionData: [doc.documentKey._id],
|
|
617
|
+
date_start: startDate,
|
|
618
|
+
date_end: endDate,
|
|
619
|
+
duration: moment(endDate).diff(moment(startDate), 'milliseconds', false),
|
|
620
|
+
result: 'Insert'
|
|
621
|
+
});
|
|
604
622
|
}
|
|
605
623
|
else if (doc.operationType === 'update' || doc.operationType === 'replace') {
|
|
606
624
|
if (collection === 'cron-jobs') {
|
|
@@ -609,17 +627,17 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
609
627
|
if (collection !== 'method-responses') {
|
|
610
628
|
_this.invalidatePubsCache(collection, 'update');
|
|
611
629
|
}
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
630
|
+
var endDate = new Date();
|
|
631
|
+
_this.currentPerfomanceMonitor.push({
|
|
632
|
+
_id: _this.idPerformance++,
|
|
633
|
+
function: 'oplog',
|
|
634
|
+
publication: collection,
|
|
635
|
+
subscriptionData: [doc.documentKey._id],
|
|
636
|
+
date_start: startDate,
|
|
637
|
+
date_end: endDate,
|
|
638
|
+
duration: moment(endDate).diff(moment(startDate), 'milliseconds', false),
|
|
639
|
+
result: 'Update'
|
|
640
|
+
});
|
|
623
641
|
}
|
|
624
642
|
else if (doc.operationType === 'delete') {
|
|
625
643
|
if (collection === 'cron-jobs') {
|
|
@@ -628,17 +646,17 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
628
646
|
if (collection !== 'method-responses') {
|
|
629
647
|
_this.invalidatePubsCache(collection, 'delete');
|
|
630
648
|
}
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
649
|
+
var endDate = new Date();
|
|
650
|
+
_this.currentPerfomanceMonitor.push({
|
|
651
|
+
_id: _this.idPerformance++,
|
|
652
|
+
function: 'oplog',
|
|
653
|
+
publication: collection,
|
|
654
|
+
subscriptionData: [doc.documentKey._id],
|
|
655
|
+
date_start: startDate,
|
|
656
|
+
date_end: endDate,
|
|
657
|
+
duration: moment(endDate).diff(moment(startDate), 'milliseconds', false),
|
|
658
|
+
result: 'Delete'
|
|
659
|
+
});
|
|
642
660
|
}
|
|
643
661
|
}
|
|
644
662
|
}
|
|
@@ -656,11 +674,11 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
656
674
|
SubscriptionManager.prototype.sendPubDataOnce = function (ws, messageId, subscription, type, collection) {
|
|
657
675
|
var _this = this;
|
|
658
676
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
659
|
-
var cacheData, serverRes;
|
|
677
|
+
var startDate, cacheData, serverRes, endDate;
|
|
660
678
|
var _a;
|
|
661
679
|
var _this = this;
|
|
662
680
|
return __generator(this, function (_b) {
|
|
663
|
-
|
|
681
|
+
startDate = new Date();
|
|
664
682
|
if (!this._publications[subscription.publication].ws_specific) { // Same pub for all users
|
|
665
683
|
if (subscription.cacheId) {
|
|
666
684
|
cacheData = null;
|
|
@@ -696,17 +714,17 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
696
714
|
run_again: false
|
|
697
715
|
});
|
|
698
716
|
}
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
717
|
+
endDate = new Date();
|
|
718
|
+
this.currentPerfomanceMonitor.push({
|
|
719
|
+
_id: this.idPerformance++,
|
|
720
|
+
function: 'sendPubDataOnce',
|
|
721
|
+
publication: subscription.publication,
|
|
722
|
+
subscriptionData: subscription.subscriptionData,
|
|
723
|
+
date_start: startDate,
|
|
724
|
+
date_end: endDate,
|
|
725
|
+
duration: moment(endDate).diff(moment(startDate), 'milliseconds', false),
|
|
726
|
+
result: 'Send cache'
|
|
727
|
+
});
|
|
710
728
|
resolve(true);
|
|
711
729
|
}
|
|
712
730
|
else {
|
|
@@ -729,17 +747,17 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
729
747
|
}
|
|
730
748
|
// console.log('Send Pub Data Once 2', new Date(), 'Success', subscription);
|
|
731
749
|
_this.sendWS(ws, serverRes);
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
750
|
+
var endDate = new Date();
|
|
751
|
+
_this.currentPerfomanceMonitor.push({
|
|
752
|
+
_id: _this.idPerformance++,
|
|
753
|
+
function: 'sendPubDataOnce',
|
|
754
|
+
publication: subscription.publication,
|
|
755
|
+
subscriptionData: subscription.subscriptionData,
|
|
756
|
+
date_start: startDate,
|
|
757
|
+
date_end: endDate,
|
|
758
|
+
duration: moment(endDate).diff(moment(startDate), 'milliseconds', false),
|
|
759
|
+
result: 'Send ws spec data'
|
|
760
|
+
});
|
|
743
761
|
resolve(true);
|
|
744
762
|
}, function (err) {
|
|
745
763
|
var serverRes = {
|
|
@@ -760,10 +778,11 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
760
778
|
SubscriptionManager.prototype.sendPubData = function (subscription, type, collection) {
|
|
761
779
|
var _this = this;
|
|
762
780
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
781
|
+
var startDate;
|
|
763
782
|
var _a;
|
|
764
783
|
var _this = this;
|
|
765
784
|
return __generator(this, function (_b) {
|
|
766
|
-
|
|
785
|
+
startDate = new Date();
|
|
767
786
|
if (!subscription.clients.length) {
|
|
768
787
|
if (subscription.cacheId) {
|
|
769
788
|
this._nodeCache.del(subscription.cacheId);
|
|
@@ -784,17 +803,17 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
784
803
|
_this._nodeCache.del(subscription.cacheId);
|
|
785
804
|
}
|
|
786
805
|
_this._subscriptions.splice(_this._subscriptions.findIndex(function (a) { return a.publication === subscription.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscription.subscriptionData); }), 1);
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
806
|
+
var endDate = new Date();
|
|
807
|
+
_this.currentPerfomanceMonitor.push({
|
|
808
|
+
_id: _this.idPerformance++,
|
|
809
|
+
function: 'sendPubData',
|
|
810
|
+
publication: subscription.publication,
|
|
811
|
+
subscriptionData: subscription.subscriptionData,
|
|
812
|
+
date_start: startDate,
|
|
813
|
+
date_end: endDate,
|
|
814
|
+
duration: moment(endDate).diff(moment(startDate), 'milliseconds', false),
|
|
815
|
+
result: 'No clients'
|
|
816
|
+
});
|
|
798
817
|
resolve(false);
|
|
799
818
|
}
|
|
800
819
|
else {
|
|
@@ -835,17 +854,17 @@ var SubscriptionManager = /** @class */ (function () {
|
|
|
835
854
|
_this._cacheId += 1;
|
|
836
855
|
_this._nodeCache.set(cacheId, JSON.stringify(res));
|
|
837
856
|
subscription.cacheId = cacheId;
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
857
|
+
var endDate = new Date();
|
|
858
|
+
_this.currentPerfomanceMonitor.push({
|
|
859
|
+
_id: _this.idPerformance++,
|
|
860
|
+
function: 'sendPubData',
|
|
861
|
+
publication: subscription.publication,
|
|
862
|
+
subscriptionData: subscription.subscriptionData,
|
|
863
|
+
date_start: startDate,
|
|
864
|
+
date_end: endDate,
|
|
865
|
+
duration: moment(endDate).diff(moment(startDate), 'milliseconds', false),
|
|
866
|
+
result: 'Same data'
|
|
867
|
+
});
|
|
849
868
|
}
|
|
850
869
|
resolve(true);
|
|
851
870
|
}
|