@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
- // interface CurrentPerformanceMonitor {
69
- // _id: number;
70
- // function: string;
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
- // setTimeout(() => {
98
- // console.log('Setting up performance thread');
99
- // this.performanceThread = new Worker(path.join(__dirname, './subscription.performance.js'));
100
- // this.performanceThread.on('exit', code => {
101
- // console.error(new Date(), 'THREAD EXITED!!!!!!!!!!!!!!!!!!', code);
102
- // });
103
- // this.performanceThread.on('error', code => {
104
- // console.error(new Date(), 'THREAD RECV ERROR !!!!!!!!!!!!!!!!!!', code);
105
- // });
106
- // }, 5000);
107
- // setInterval(() => {
108
- // console.log('Post thread msg');
109
- // this.performanceThread.postMessage(this.currentPerfomanceMonitor);
110
- // this.currentPerfomanceMonitor = [];
111
- // }, 10000);
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
- // let startDate = new Date();
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
- // let endDate = new Date();
161
- // this.currentPerfomanceMonitor.push({
162
- // _id: this.idPerformance++,
163
- // function: 'sendInterval',
164
- // publication: '',
165
- // subscriptionData: [],
166
- // date_start: startDate,
167
- // date_end: endDate,
168
- // duration: moment(endDate).diff(moment(startDate), 'milliseconds', false),
169
- // result: 'Done'
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
- // let startDate = new Date();
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
- // let endDate = new Date();
202
- // this.currentPerfomanceMonitor.push({
203
- // _id: this.idPerformance++,
204
- // function: 'mongoQueue',
205
- // publication: '',
206
- // subscriptionData: queueArr,
207
- // date_start: startDate,
208
- // date_end: endDate,
209
- // duration: moment(endDate).diff(moment(startDate), 'milliseconds', false),
210
- // result: 'Done'
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
- // let startDate = new Date();
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
- // let endDate = new Date();
277
- // this.currentPerfomanceMonitor.push({
278
- // _id: this.idPerformance++,
279
- // function: 'addToQueue',
280
- // publication: mongoQueue.subscription.publication,
281
- // subscriptionData: mongoQueue.subscription.subscriptionData,
282
- // date_start: startDate,
283
- // date_end: endDate,
284
- // duration: moment(endDate).diff(moment(startDate), 'milliseconds', false),
285
- // result: 'Run Again'
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
- // let endDate = new Date();
307
- // this.currentPerfomanceMonitor.push({
308
- // _id: this.idPerformance++,
309
- // function: 'addToQueue',
310
- // publication: mongoQueue.subscription.publication,
311
- // subscriptionData: mongoQueue.subscription.subscriptionData,
312
- // date_start: startDate,
313
- // date_end: endDate,
314
- // duration: moment(endDate).diff(moment(startDate), 'milliseconds', false),
315
- // result: 'Add to Queue'
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
- // let startDate = new Date();
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
- this._nodeCache.del(sub.cacheId);
325
- sub.cacheId = 0;
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
- // let endDate = new Date();
337
- // this.currentPerfomanceMonitor.push({
338
- // _id: this.idPerformance++,
339
- // function: 'invalidatePubsCache',
340
- // publication: collection,
341
- // subscriptionData: [],
342
- // date_start: startDate,
343
- // date_end: endDate,
344
- // duration: moment(endDate).diff(moment(startDate), 'milliseconds', false),
345
- // result: 'Done'
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
- // let endDate = new Date();
453
- // this.currentPerfomanceMonitor.push({
454
- // _id: this.idPerformance++,
455
- // function: 'subscribe',
456
- // publication: publication,
457
- // subscriptionData: subscriptionData,
458
- // date_start: startDate,
459
- // date_end: endDate,
460
- // duration: moment(endDate).diff(moment(startDate), 'milliseconds', false),
461
- // result: 'Add to Queue'
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
- // let endDate = new Date();
467
- // this.currentPerfomanceMonitor.push({
468
- // _id: this.idPerformance++,
469
- // function: 'subscribe',
470
- // publication: publication,
471
- // subscriptionData: subscriptionData,
472
- // date_start: startDate,
473
- // date_end: endDate,
474
- // duration: moment(endDate).diff(moment(startDate), 'milliseconds', false),
475
- // result: 'Send Pub Data Once'
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
- // let startDate = new Date();
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
- // let startDate = new Date();
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
- // let endDate = new Date();
594
- // this.currentPerfomanceMonitor.push({
595
- // _id: this.idPerformance++,
596
- // function: 'oplog',
597
- // publication: collection,
598
- // subscriptionData: [doc.documentKey._id],
599
- // date_start: startDate,
600
- // date_end: endDate,
601
- // duration: moment(endDate).diff(moment(startDate), 'milliseconds', false),
602
- // result: 'Insert'
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
- // let endDate = new Date();
613
- // this.currentPerfomanceMonitor.push({
614
- // _id: this.idPerformance++,
615
- // function: 'oplog',
616
- // publication: collection,
617
- // subscriptionData: [doc.documentKey._id],
618
- // date_start: startDate,
619
- // date_end: endDate,
620
- // duration: moment(endDate).diff(moment(startDate), 'milliseconds', false),
621
- // result: 'Update'
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
- // let endDate = new Date();
632
- // this.currentPerfomanceMonitor.push({
633
- // _id: this.idPerformance++,
634
- // function: 'oplog',
635
- // publication: collection,
636
- // subscriptionData: [doc.documentKey._id],
637
- // date_start: startDate,
638
- // date_end: endDate,
639
- // duration: moment(endDate).diff(moment(startDate), 'milliseconds', false),
640
- // result: 'Delete'
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
- // let startDate = new Date();
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
- // let endDate = new Date();
700
- // this.currentPerfomanceMonitor.push({
701
- // _id: this.idPerformance++,
702
- // function: 'sendPubDataOnce',
703
- // publication: subscription.publication,
704
- // subscriptionData: subscription.subscriptionData,
705
- // date_start: startDate,
706
- // date_end: endDate,
707
- // duration: moment(endDate).diff(moment(startDate), 'milliseconds', false),
708
- // result: 'Send cache'
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
- // let endDate = new Date();
733
- // this.currentPerfomanceMonitor.push({
734
- // _id: this.idPerformance++,
735
- // function: 'sendPubDataOnce',
736
- // publication: subscription.publication,
737
- // subscriptionData: subscription.subscriptionData,
738
- // date_start: startDate,
739
- // date_end: endDate,
740
- // duration: moment(endDate).diff(moment(startDate), 'milliseconds', false),
741
- // result: 'Send ws spec data'
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
- // let startDate = new Date();
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
- // let endDate = new Date();
788
- // this.currentPerfomanceMonitor.push({
789
- // _id: this.idPerformance++,
790
- // function: 'sendPubData',
791
- // publication: subscription.publication,
792
- // subscriptionData: subscription.subscriptionData,
793
- // date_start: startDate,
794
- // date_end: endDate,
795
- // duration: moment(endDate).diff(moment(startDate), 'milliseconds', false),
796
- // result: 'No clients'
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
- // let endDate = new Date();
839
- // this.currentPerfomanceMonitor.push({
840
- // _id: this.idPerformance++,
841
- // function: 'sendPubData',
842
- // publication: subscription.publication,
843
- // subscriptionData: subscription.subscriptionData,
844
- // date_start: startDate,
845
- // date_end: endDate,
846
- // duration: moment(endDate).diff(moment(startDate), 'milliseconds', false),
847
- // result: 'Same data'
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
  }