@resolveio/server-lib 20.0.26 → 20.0.28
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.
- package/client-server-app.js +1 -47
- package/client-server-app.js.map +1 -1
- package/collections/app-status.collection.js +1 -50
- package/collections/app-status.collection.js.map +1 -1
- package/collections/counter.collection.js +1 -53
- package/collections/counter.collection.js.map +1 -1
- package/collections/cron-job-history.collection.js +1 -88
- package/collections/cron-job-history.collection.js.map +1 -1
- package/collections/cron-job.collection.js +1 -84
- package/collections/cron-job.collection.js.map +1 -1
- package/collections/email-history.collection.js +1 -65
- package/collections/email-history.collection.js.map +1 -1
- package/collections/email-verified.collection.js +1 -60
- package/collections/email-verified.collection.js.map +1 -1
- package/collections/file.collection.js +1 -72
- package/collections/file.collection.js.map +1 -1
- package/collections/flag.collection.js +1 -55
- package/collections/flag.collection.js.map +1 -1
- package/collections/log-method-latency.collection.js +1 -63
- package/collections/log-method-latency.collection.js.map +1 -1
- package/collections/log-subscription.collection.js +1 -67
- package/collections/log-subscription.collection.js.map +1 -1
- package/collections/log-ts.collection.js +1 -77
- package/collections/log-ts.collection.js.map +1 -1
- package/collections/log.collection.js +1 -76
- package/collections/log.collection.js.map +1 -1
- package/collections/logged-in-users.collection.js +1 -64
- package/collections/logged-in-users.collection.js.map +1 -1
- package/collections/method-response.collection.js +1 -65
- package/collections/method-response.collection.js.map +1 -1
- package/collections/monitor-cpu.collection.js +1 -62
- package/collections/monitor-cpu.collection.js.map +1 -1
- package/collections/monitor-memory.collection.js +1 -74
- package/collections/monitor-memory.collection.js.map +1 -1
- package/collections/monitor-mongo.collection.js +1 -68
- package/collections/monitor-mongo.collection.js.map +1 -1
- package/collections/notification.collection.js +1 -55
- package/collections/notification.collection.js.map +1 -1
- package/collections/report-builder-dashboard-builder.collection.js +1 -108
- package/collections/report-builder-dashboard-builder.collection.js.map +1 -1
- package/collections/report-builder-library.collection.js +1 -86
- package/collections/report-builder-library.collection.js.map +1 -1
- package/collections/report-builder-report.collection.js +1 -148
- package/collections/report-builder-report.collection.js.map +1 -1
- package/collections/user-group.collection.js +1 -93
- package/collections/user-group.collection.js.map +1 -1
- package/collections/user-guide.collection.js +1 -56
- package/collections/user-guide.collection.js.map +1 -1
- package/collections/user.collection.js +1 -265
- package/collections/user.collection.js.map +1 -1
- package/cron/cron.js +1 -101
- package/cron/cron.js.map +1 -1
- package/fixtures/cron-jobs.js +1 -87
- package/fixtures/cron-jobs.js.map +1 -1
- package/fixtures/init.js +1 -58
- package/fixtures/init.js.map +1 -1
- package/http/auth.js +1 -763
- package/http/auth.js.map +1 -1
- package/http/health.js +1 -11
- package/http/health.js.map +1 -1
- package/http/home.js +1 -65
- package/http/home.js.map +1 -1
- package/index.js +1 -126
- package/index.js.map +1 -1
- package/managers/cron.manager.js +1 -322
- package/managers/cron.manager.js.map +1 -1
- package/managers/method.manager.js +1 -593
- package/managers/method.manager.js.map +1 -1
- package/managers/mongo.manager.js +1 -2259
- package/managers/mongo.manager.js.map +1 -1
- package/managers/monitor.manager.js +1 -350
- package/managers/monitor.manager.js.map +1 -1
- package/managers/subscription.manager.js +1 -1110
- package/managers/subscription.manager.js.map +1 -1
- package/managers/subscription.performance.js +1 -102
- package/managers/subscription.performance.js.map +1 -1
- package/methods/accounts.js +1 -291
- package/methods/accounts.js.map +1 -1
- package/methods/aws.js +1 -616
- package/methods/aws.js.map +1 -1
- package/methods/collections.js +1 -499
- package/methods/collections.js.map +1 -1
- package/methods/counters.js +1 -121
- package/methods/counters.js.map +1 -1
- package/methods/cron-jobs.js +1 -1337
- package/methods/cron-jobs.js.map +1 -1
- package/methods/flags.js +1 -8
- package/methods/flags.js.map +1 -1
- package/methods/logs.js +1 -370
- package/methods/logs.js.map +1 -1
- package/methods/monitor.js +1 -564
- package/methods/monitor.js.map +1 -1
- package/methods/pdf.js +1 -731
- package/methods/pdf.js.map +1 -1
- package/methods/report-builder.js +1 -859
- package/methods/report-builder.js.map +1 -1
- package/methods/support.js +1 -245
- package/methods/support.js.map +1 -1
- package/models/app-status.model.js +1 -3
- package/models/app-status.model.js.map +1 -1
- package/models/billing-logged-in-users.model.js +1 -3
- package/models/billing-logged-in-users.model.js.map +1 -1
- package/models/collection-document.model.js +1 -3
- package/models/collection-document.model.js.map +1 -1
- package/models/counter.model.js +1 -3
- package/models/counter.model.js.map +1 -1
- package/models/cron-job-history.model.js +1 -3
- package/models/cron-job-history.model.js.map +1 -1
- package/models/cron-job.model.js +1 -3
- package/models/cron-job.model.js.map +1 -1
- package/models/dialog.model.js +1 -3
- package/models/dialog.model.js.map +1 -1
- package/models/email-history.model.js +1 -3
- package/models/email-history.model.js.map +1 -1
- package/models/email-verified.model.js +1 -3
- package/models/email-verified.model.js.map +1 -1
- package/models/file.model.js +1 -3
- package/models/file.model.js.map +1 -1
- package/models/flag.model.js +1 -3
- package/models/flag.model.js.map +1 -1
- package/models/log-method-latency.model.js +1 -3
- package/models/log-method-latency.model.js.map +1 -1
- package/models/log-subscription.model.js +1 -3
- package/models/log-subscription.model.js.map +1 -1
- package/models/log.model.js +1 -3
- package/models/log.model.js.map +1 -1
- package/models/logged-in-users.model.js +1 -3
- package/models/logged-in-users.model.js.map +1 -1
- package/models/method-response.model.js +1 -3
- package/models/method-response.model.js.map +1 -1
- package/models/method.model.js +1 -3
- package/models/method.model.js.map +1 -1
- package/models/monitor-cpu.model.js +1 -3
- package/models/monitor-cpu.model.js.map +1 -1
- package/models/monitor-memory.model.js +1 -3
- package/models/monitor-memory.model.js.map +1 -1
- package/models/monitor-mongo.model.js +1 -3
- package/models/monitor-mongo.model.js.map +1 -1
- package/models/notification.model.js +1 -3
- package/models/notification.model.js.map +1 -1
- package/models/pagination.model.js +1 -23
- package/models/pagination.model.js.map +1 -1
- package/models/permission.model.js +1 -3
- package/models/permission.model.js.map +1 -1
- package/models/report-builder-dashboard-builder.model.js +1 -3
- package/models/report-builder-dashboard-builder.model.js.map +1 -1
- package/models/report-builder-library.model.js +1 -3
- package/models/report-builder-library.model.js.map +1 -1
- package/models/report-builder-report.model.js +1 -3
- package/models/report-builder-report.model.js.map +1 -1
- package/models/report-builder.model.js +1 -3
- package/models/report-builder.model.js.map +1 -1
- package/models/select-data-label.model.js +1 -3
- package/models/select-data-label.model.js.map +1 -1
- package/models/server-response.model.js +1 -3
- package/models/server-response.model.js.map +1 -1
- package/models/subscription.model.js +1 -3
- package/models/subscription.model.js.map +1 -1
- package/models/support-ticket.model.js +1 -3
- package/models/support-ticket.model.js.map +1 -1
- package/models/user-group.model.js +1 -3
- package/models/user-group.model.js.map +1 -1
- package/models/user-guide.model.js +1 -3
- package/models/user-guide.model.js.map +1 -1
- package/models/user.model.js +1 -3
- package/models/user.model.js.map +1 -1
- package/package.json +6 -4
- package/public_api.js +1 -74
- package/public_api.js.map +1 -1
- package/publications/app-status.js +1 -16
- package/publications/app-status.js.map +1 -1
- package/publications/cron-jobs.js +1 -32
- package/publications/cron-jobs.js.map +1 -1
- package/publications/files.js +1 -36
- package/publications/files.js.map +1 -1
- package/publications/flags.js +1 -22
- package/publications/flags.js.map +1 -1
- package/publications/logs.js +1 -164
- package/publications/logs.js.map +1 -1
- package/publications/method-responses.js +1 -16
- package/publications/method-responses.js.map +1 -1
- package/publications/notifications.js +1 -16
- package/publications/notifications.js.map +1 -1
- package/publications/report-builder-dashboard-builders.js +1 -42
- package/publications/report-builder-dashboard-builders.js.map +1 -1
- package/publications/report-builder-libraries.js +1 -89
- package/publications/report-builder-libraries.js.map +1 -1
- package/publications/report-builder-reports.js +1 -50
- package/publications/report-builder-reports.js.map +1 -1
- package/publications/super-admin.js +1 -16
- package/publications/super-admin.js.map +1 -1
- package/publications/user-groups.js +1 -16
- package/publications/user-groups.js.map +1 -1
- package/publications/user-guides.js +1 -16
- package/publications/user-guides.js.map +1 -1
- package/server-app.js +1 -770
- package/server-app.js.map +1 -1
- package/util/common.js +1 -546
- package/util/common.js.map +1 -1
- package/util/schema-report-builder.js +1 -452
- package/util/schema-report-builder.js.map +1 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AAY,CAAC;IAC1B,CAAC;IACF,0BAAC;AAAD,CA/nCA,AA+nCC,IAAA;AA/nCY,kDAAmB","file":"subscription.manager.js","sourcesContent":["import { ServerResponseModel } from '../models/server-response.model';\nimport { ActiveSubscriptionModel, SubscriptionModel } from '../models/subscription.model';\nimport * as WebSocket from 'ws';\nimport { loadLogPublications } from '../publications/logs';\nimport { loadAppStatusPublications } from '../publications/app-status';\nimport { loadFilePublications } from '../publications/files';\nimport { loadSuperAdminPublications } from '../publications/super-admin';\nimport { LoggedInUsers } from '../collections/logged-in-users.collection';\nimport { loadCronJobPublications } from '../publications/cron-jobs';\nimport { loadFlagsPublications } from '../publications/flags';\nimport { loadMethodResponsePublications } from '../publications/method-responses';\nimport ResolveIOMainServer from '../server-app';\nimport { ResolveIOServer } from '../index';\nimport { loadNotificationPublications } from '../publications/notifications';\nimport { loadReportBuilderReportPublications } from '../publications/report-builder-reports';\nimport { LoggedInUserModel } from '../models/logged-in-users.model';\n\nimport { ChangeStream, ChangeStreamDeleteDocument, ChangeStreamDocument, ChangeStreamInsertDocument, ChangeStreamReplaceDocument, ChangeStreamUpdateDocument, ResumeToken } from 'mongodb';\nimport { loadReportBuilderLibraryPublications } from '../publications/report-builder-libraries';\nimport { loadUserGroupPublications } from '../publications/user-groups';\nimport { loadUserGuidePublications } from '../publications/user-guides';\nimport { loadReportBuilderDashboardBuilderPublications } from '../publications/report-builder-dashboard-builders';\nimport { objectIdHexString } from './mongo.manager';\nimport { dateReviver, deepCopy } from '../util/common';\nimport * as NodeCache from 'node-cache';\nimport { MonitorManagerFunction } from './monitor.manager';\nimport { Flags } from '../collections/flag.collection';\nimport { cpus } from 'os';\nconst numCPUs = cpus().length;\nconst v8 = require('v8');\n\n// Performance Dependencies\n// import * as path from 'path';\n// import { Worker } from 'worker_threads';\n\ninterface MongoQueueModel {\n\t_id: number,\n\ttype: string;\n\tcollection: string;\n\tsubscription: ActiveSubscriptionModel;\n\trunning: boolean;\n\trun_again: boolean;\n}\n\n// interface CurrentPerformanceMonitor {\n// \t_id: number;\n// \tfunction: string;\n// \tpublication: string;\n// \tsubscriptionData: any[];\n// \tdate_start: Date;\n// \tdate_end: Date;\n// \tduration: number;\n// \tresult: string;\n// }\n\nexport class SubscriptionManager {\n\n\tprivate _mainServer: ResolveIOMainServer;\n\tprivate _publications: SubscriptionModel = {};\n\tprivate _subscriptions: ActiveSubscriptionModel[] = [];\n\tprivate _wss: WebSocket.Server;\n\tprivate _loggedInUsers: LoggedInUserModel[] = [];\n\n\tprivate _mongoQueue: MongoQueueModel[] = [];\n\tprivate _mongoQueueId = 0;\n\n\tprivate _sendQueue = [];\n\tprivate _runningQueue = false;\n\t\n\tprivate _oplog$: ChangeStream;\n\n\tprivate _nodeCache;\n\tprivate _cacheId = 1;\n\n\tprivate serverConfig;\n\n\tprivate _heapStats = v8.getHeapStatistics();\n\tprivate _heapLimit = this._heapStats.heap_size_limit / numCPUs / 8;\n\n\tprivate _monitorManagerFunction: MonitorManagerFunction;\n\n\tprivate _enableDebug = false;\n\tprivate _debugOplogCollections = [];\n\tprivate _debugOplogHits = 0;\n\tprivate _debugSubCollections = [];\n\tprivate _debugSubHits = 0;\n\tprivate _debugUnSubHits = 0;\n\tprivate _debugUnSubAllHits = 0;\n\tprivate _debugMongoQueueHits = 0;\n\tprivate _debugMongoQueueCollections = [];\n\tprivate _debugSendQueueHits = 0;\n\tprivate _debugRemoveCacheHits = 0;\n\n\tprivate _oplogRetryCount = 0;\n\n\t// private currentPerfomanceMonitor: CurrentPerformanceMonitor[] = [];\n\t// private idPerformance: number = 0;\n\t// private performanceThread;\n\n\tconstructor(mainServer, wss: WebSocket.Server, serverConfig, monitorManagerFunction: MonitorManagerFunction) {\n\t\tthis._mainServer = mainServer;\n\t\tthis._monitorManagerFunction = monitorManagerFunction;\n\n\t\tthis._nodeCache = new NodeCache( { stdTTL: 0, checkperiod: 0 } );\n\n\t\t// setTimeout(() => {\n\t\t// \tconsole.log('Setting up performance thread');\n\n\t\t// \tthis.performanceThread = new Worker(path.join(__dirname, './subscription.performance.js'));\n\n\t\t// \tthis.performanceThread.on('exit', code => {\n\t\t// \t\tconsole.error(new Date(), 'THREAD EXITED!!!!!!!!!!!!!!!!!!', code);\n\t\t// \t});\n\n\t\t// \tthis.performanceThread.on('error', code => {\n\t\t// \t\tconsole.error(new Date(), 'THREAD RECV ERROR !!!!!!!!!!!!!!!!!!', code);\n\t\t// \t});\n\t\t// }, 5000);\n\n\t\t// setInterval(() => {\n\t\t// \tconsole.log('Post thread msg');\n\t\t// \tthis.performanceThread.postMessage(this.currentPerfomanceMonitor);\n\t\t// \tthis.currentPerfomanceMonitor = [];\n\t\t// }, 10000);\n\n\t\tthis.serverConfig = serverConfig;\n\t\tthis._wss = wss;\n\n\t\t// Publications\n\t\tloadSuperAdminPublications(this);\n\t\tloadAppStatusPublications(this);\n\t\tloadLogPublications(this);\n\t\tloadFilePublications(this);\n\t\tloadCronJobPublications(this);\n\t\tloadFlagsPublications(this);\n\t\tloadMethodResponsePublications(this);\n\t\tloadNotificationPublications(this);\n\t\tloadReportBuilderReportPublications(this);\n\t\tloadReportBuilderLibraryPublications(this);\n\t\tloadUserGroupPublications(this);\n\t\tloadUserGuidePublications(this);\n\t\tloadReportBuilderDashboardBuilderPublications(this);\n\n\t\tthis.tailOpLog();\n\n\t\tsetInterval(() => {\n\t\t\tthis._oplogRetryCount = 0;\n\t\t}, 15000);\n\n\t\tsetInterval(() => {\n\t\t\tif (this.getEnableDebug()) {\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Subs', this._subscriptions.length);\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Logged In Users', this._loggedInUsers.length);\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Mongo Queue', this._mongoQueue.length);\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Mongo Queue Hits', this._debugMongoQueueHits);\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Mongo Queue Collections', JSON.stringify(this._debugMongoQueueCollections.sort((a, b) => a.collection.localeCompare(b.collection) || a.publication.localeCompare(b.publication)), null, 2));\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Oplog Hits', this._debugOplogHits);\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Oplog Collections', JSON.stringify(this._debugOplogCollections.sort((a, b) => a.collection.localeCompare(b.collection) || a.type.localeCompare(b.type)), null, 2));\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Send Queue Hits', this._debugSendQueueHits);\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Sub Hits', this._debugSubHits);\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Sub Collections', JSON.stringify(this._debugSubCollections.sort((a, b) => a.publication.localeCompare(b.publication)), null, 2));\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Unsub Hits', this._debugUnSubHits);\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Unsub All Hits', this._debugUnSubAllHits);\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Cache Cleanup Hits', this._debugRemoveCacheHits);\n\t\t\t}\n\t\t\t\n\t\t\tthis._debugOplogHits = 0;\n\t\t\tthis._debugOplogCollections = [];\n\t\t\tthis._debugSubCollections = [];\n\t\t\tthis._debugMongoQueueHits = 0;\n\t\t\tthis._debugMongoQueueCollections = [];\n\t\t\tthis._debugSendQueueHits = 0;\n\t\t\tthis._debugSubHits = 0;\n\t\t\tthis._debugUnSubHits = 0;\n\t\t\tthis._debugUnSubAllHits = 0;\n\t\t\tthis._debugRemoveCacheHits = 0;\n\t\t}, 60000);\n\n\t\tsetInterval(async () => {\n\t\t\tif (!this._runningQueue) {\n\t\t\t\tthis._runningQueue = true;\n\n\t\t\t\tif (this._sendQueue.length) {\n\t\t\t\t\t// let startDate = new Date();\n\t\t\t\t\tfor (let i = this._sendQueue.length - 1; i >= 0; i--) {\n\t\t\t\t\t\tthis._debugSendQueueHits += 1;\n\n\t\t\t\t\t\tlet ws = this._mainServer.getWS(this._sendQueue[i].id_ws);\n\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\tif (ws.bufferedAmount < 20480) {\n\t\t\t\t\t\t\t\tlet sendItem = this._sendQueue.pop();\n\t\t\t\t\t\t\t\tws.send(JSON.stringify(sendItem.data), (error) => {\n\t\t\t\t\t\t\t\t\tif (error) {\n\t\t\t\t\t\t\t\t\t\tif (this.getEnableDebug()) {\n\t\t\t\t\t\t\t\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Unsub WS', ws['user'], ws['id_socket'], 1);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tthis.unsubscribeAll(ws);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tthis._sendQueue.splice(i, 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// let endDate = new Date();\n\t\t\t\t\t// this.currentPerfomanceMonitor.push({\n\t\t\t\t\t// \t_id: this.idPerformance++,\n\t\t\t\t\t// \tfunction: 'sendInterval',\n\t\t\t\t\t// \tpublication: '',\n\t\t\t\t\t// \tsubscriptionData: [],\n\t\t\t\t\t// \tdate_start: startDate,\n\t\t\t\t\t// \tdate_end: endDate,\n\t\t\t\t\t// \tduration: moment(endDate).diff(moment(startDate), 'milliseconds', false),\n\t\t\t\t\t// \tresult: 'Done'\n\t\t\t\t\t// });\n\t\t\t\t}\n\n\t\t\t\tconst queueArr = this._mongoQueue.filter(a => !a.running);\n\t\t\t\tif (queueArr.length) {\n\t\t\t\t\tqueueArr.forEach(entry => {\n\t\t\t\t\t\tentry.running = true;\n\t\t\t\t\t});\n\n\t\t\t\t\tfor (let i = queueArr.length - 1; i >= 0; i--) {\n\t\t\t\t\t\tthis._debugMongoQueueHits += 1;\n\t\t\t\t\t\t\n\t\t\t\t\t\tlet mongoQueue = queueArr[i];\n\n\t\t\t\t\t\tif (!this._debugMongoQueueCollections.some(a => a.collection === mongoQueue.collection && a.publication === mongoQueue.subscription.publication)) {\n\t\t\t\t\t\t\tthis._debugMongoQueueCollections.push({\n\t\t\t\t\t\t\t\tcollection: mongoQueue.collection,\n\t\t\t\t\t\t\t\tpublication: mongoQueue.subscription.publication,\n\t\t\t\t\t\t\t\thits: 1\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tthis._debugMongoQueueCollections.filter(a => a.collection === mongoQueue.collection && a.publication === mongoQueue.subscription.publication)[0].hits += 1;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (this._publications[mongoQueue.subscription.publication].user_specific) {\n\t\t\t\t\t\t\tlet promises = [];\n\t\t\t\t\t\t\tfor (let j = 0; j < mongoQueue.subscription.clients.length; j++) {\n\t\t\t\t\t\t\t\tlet client = mongoQueue.subscription.clients[j];\n\t\t\t\t\t\t\t\tlet ws = this._mainServer.getWS(client.id_socket);\n\t\t\t\t\t\t\t\tif (ws && ws['id_socket'] === client.id_socket) {\n\t\t\t\t\t\t\t\t\tpromises.push(this.sendDataToOne(ws, client.messageId, mongoQueue.subscription, mongoQueue.type, mongoQueue.collection).catch((err) => {\n\t\t\t\t\t\t\t\t\t\tthis._mainServer.getMethodManager().sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'Error Detected During sendDataToOne - User Specific - Socket: ' + client.id_socket + ', User: ' + client.id_user + ', MessageId: ' + client.messageId + ', Pub: ' + mongoQueue.subscription.publication + ', Err: ' + JSON.stringify(err, null, 2));\n\t\t\t\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tPromise.all(promises).then(() => {\n\t\t\t\t\t\t\t\tif (mongoQueue.run_again) {\n\t\t\t\t\t\t\t\t\tmongoQueue.running = false;\n\t\t\t\t\t\t\t\t\tmongoQueue.run_again = false;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tif (this._mongoQueue.map(a => a._id).indexOf(mongoQueue._id) >= 0) {\n\t\t\t\t\t\t\t\t\t\tthis._mongoQueue.splice(this._mongoQueue.map(a => a._id).indexOf(mongoQueue._id), 1);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tthis.sendDataToAll(mongoQueue).then(() => {\n\t\t\t\t\t\t\t\tif (mongoQueue.run_again) {\n\t\t\t\t\t\t\t\t\tmongoQueue.running = false;\n\t\t\t\t\t\t\t\t\tmongoQueue.run_again = false;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tif (this._mongoQueue.map(a => a._id).indexOf(mongoQueue._id) >= 0) {\n\t\t\t\t\t\t\t\t\t\tthis._mongoQueue.splice(this._mongoQueue.map(a => a._id).indexOf(mongoQueue._id), 1);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}, () => {\n\t\t\t\t\t\t\t\tif (this._mongoQueue.map(a => a._id).indexOf(mongoQueue._id) >= 0) {\n\t\t\t\t\t\t\t\t\tthis._mongoQueue.splice(this._mongoQueue.map(a => a._id).indexOf(mongoQueue._id), 1);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// let endDate = new Date();\n\t\t\t\t\t\n\t\t\t\t\t// this.currentPerfomanceMonitor.push({\n\t\t\t\t\t// \t_id: this.idPerformance++,\n\t\t\t\t\t// \tfunction: 'mongoQueue',\n\t\t\t\t\t// \tpublication: '',\n\t\t\t\t\t// \tsubscriptionData: [],\n\t\t\t\t\t// \tdate_start: startDate,\n\t\t\t\t\t// \tdate_end: endDate,\n\t\t\t\t\t// \tduration: moment(endDate).diff(moment(startDate), 'milliseconds', false),\n\t\t\t\t\t// \tresult: 'Done'\n\t\t\t\t\t// });\n\t\t\t\t}\t\n\n\t\t\t\tthis._runningQueue = false;\n\t\t\t}\n\t\t}, 25);\n\n\t\tsetInterval(async () => {\n\t\t\tthis._loggedInUsers = await LoggedInUsers.find();\n\t\n\t\t\tlet userCopy = deepCopy(this._loggedInUsers);\n\t\t\tfor (let i = this._loggedInUsers.length - 1; i >= 0; i--) {\n\t\t\t\tlet loggedInUser = userCopy[i];\n\n\t\t\t\tif (!loggedInUser.date || Date.now() - loggedInUser.date.getTime() > 120000) {\n\t\t\t\t\tif (this._mainServer.getWS(loggedInUser.id_ws)) {\n\t\t\t\t\t\tif (this.getEnableDebug()) {\n\t\t\t\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Unsub WS', this._mainServer.getWS(loggedInUser.id_ws)['user'], this._mainServer.getWS(loggedInUser.id_ws)['id_socket'], 2);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthis.unsubscribeAll(this._mainServer.getWS(loggedInUser.id_ws));\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tthis._subscriptions.forEach(sub => {\n\t\t\t\t\t\t\tfor (let j = sub.clients.length - 1; j >= 0; j--) {\n\t\t\t\t\t\t\t\tlet client = sub.clients[j];\n\n\t\t\t\t\t\t\t\tif (client.id_socket === loggedInUser.id_ws) {\n\t\t\t\t\t\t\t\t\tsub.clients.splice(j, 1);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tLoggedInUsers.deleteOne({_id: loggedInUser._id});\n\n\t\t\t\t\t\tif (this._loggedInUsers.findIndex(a => a._id === loggedInUser._id) >= 0) {\n\t\t\t\t\t\t\tthis._loggedInUsers.splice(this._loggedInUsers.findIndex(a => a._id === loggedInUser._id), 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (let i = 0; i < this._subscriptions.length; i++) {\n\t\t\t\tlet sub = this._subscriptions[i];\n\n\t\t\t\tfor (let j = sub.clients.length - 1; j >= 0; j--) {\n\t\t\t\t\tlet client = sub.clients[j];\n\n\t\t\t\t\tif (!this._loggedInUsers.some(a => a.id_ws === client.id_socket)) {\n\t\t\t\t\t\tsub.clients.splice(j, 1);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}, 30000);\n\n\t\tFlags.findOne({type: 'Enable Debug'}).then(flag => {\n\t\t\tif (flag && flag.value) {\n\t\t\t\tthis._enableDebug = true;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthis._enableDebug = false;\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate addToQueue(mongoQueue: MongoQueueModel) {\n\t\t// let startDate = new Date();\n\n\t\tlet _mongoQueue = this._mongoQueue.filter(a => a.subscription.publication === mongoQueue.subscription.publication && JSON.stringify(a.subscription.subscriptionData) === JSON.stringify(mongoQueue.subscription.subscriptionData))[0];\n\t\t\n\t\tif (_mongoQueue) {\n\t\t\tif (_mongoQueue.running) {\n\t\t\t\t_mongoQueue.run_again = true;\n\n\t\t\t\t// let endDate = new Date();\n\t\t\t\t// this.currentPerfomanceMonitor.push({\n\t\t\t\t// \t_id: this.idPerformance++,\n\t\t\t\t// \tfunction: 'addToQueue',\n\t\t\t\t// \tpublication: mongoQueue.subscription.publication,\n\t\t\t\t// // \tsubscriptionData: mongoQueue.subscription.subscriptionData,\n\t\t\t\t// \tsubscriptionData: [],\n\t\t\t\t// \tdate_start: startDate,\n\t\t\t\t// \tdate_end: endDate,\n\t\t\t\t// \tduration: moment(endDate).diff(moment(startDate), 'milliseconds', false),\n\t\t\t\t// \tresult: 'Run Again'\n\t\t\t\t// });\n\t\t\t}\n\t\t\t// else {\n\t\t\t// \tlet endDate = new Date();\n\t\t\t// \tthis.currentPerfomanceMonitor.push({\n\t\t\t// \t\t_id: this.idPerformance++,\n\t\t\t// \t\tfunction: 'addToQueue',\n\t\t\t// \t\tpublication: mongoQueue.subscription.publication,\n\t\t\t// // \tsubscriptionData: mongoQueue.subscription.subscriptionData,\n\t\t\t// \t\tsubscriptionData: [],\n\t\t\t// \t\tdate_start: startDate,\n\t\t\t// \t\tdate_end: endDate,\n\t\t\t// \t\tduration: moment(endDate).diff(moment(startDate), 'milliseconds', false),\n\t\t\t// \t\tresult: 'Not Running Yet'\n\t\t\t// \t});\n\t\t\t// }\n\t\t}\n\t\telse {\n\t\t\tmongoQueue._id = this._mongoQueueId;\n\t\t\tthis._mongoQueueId += 1;\n\n\t\t\tthis._mongoQueue.splice(0, 0, mongoQueue);\n\t\t\t\n\t\t\t// let endDate = new Date();\n\t\t\t// this.currentPerfomanceMonitor.push({\n\t\t\t// \t_id: this.idPerformance++,\n\t\t\t// \tfunction: 'addToQueue',\n\t\t\t// \tpublication: mongoQueue.subscription.publication,\n\t\t\t// // \tsubscriptionData: mongoQueue.subscription.subscriptionData,\n\t\t\t// \tsubscriptionData: [],\n\t\t\t// \tdate_start: startDate,\n\t\t\t// \tdate_end: endDate,\n\t\t\t// \tduration: moment(endDate).diff(moment(startDate), 'milliseconds', false),\n\t\t\t// \tresult: 'Add to Queue'\n\t\t\t// });\n\t\t}\n\t}\n\n\tpublic invalidatePubsCache(collection, type) {\n\t\t// let startDate = new Date();\n\n\t\tResolveIOServer.getMongoManager().invalidateQueryCache(collection);\n\t\t\n\t\tlet collSubs = this._subscriptions.filter(a => a.collections.includes(collection));\n\n\t\tfor (let i = collSubs.length - 1; i >= 0; i--) {\n\t\t\tlet sub = collSubs[i];\n\t\t\t\n\t\t\tthis.addToQueue({\n\t\t\t\t_id: 0,\n\t\t\t\ttype: type,\n\t\t\t\tcollection: collection,\n\t\t\t\tsubscription: sub,\n\t\t\t\trunning: false,\n\t\t\t\trun_again: false\n\t\t\t});\n\t\t}\n\n\t\t// let endDate = new Date();\n\t\t// this.currentPerfomanceMonitor.push({\n\t\t// \t_id: this.idPerformance++,\n\t\t// \tfunction: 'invalidatePubsCache',\n\t\t// \tpublication: collection,\n\t\t// \tsubscriptionData: [],\n\t\t// \tdate_start: startDate,\n\t\t// \tdate_end: endDate,\n\t\t// \tduration: moment(endDate).diff(moment(startDate), 'milliseconds', false),\n\t\t// \tresult: 'Done'\n\t\t// });\n\t}\n\n\t// Add all files to publications private object\n\tpublic publications(method: SubscriptionModel) {\n\t\tthis._publications = Object.assign(this._publications, method);\n\t}\n\n\tpublic loggedInLatency(ws: WebSocket) {\n\t\tlet loggedInUser = this._loggedInUsers.filter(a => a.id_ws === ws['id_socket'])[0];\n\n\t\tif (loggedInUser) {\n\t\t\tloggedInUser.date = new Date();\n\n\t\t\tLoggedInUsers.updateOne({id_ws: ws['id_socket']}, {$set: {latency: ws['latency'], date: loggedInUser.date}}).then(res => {\n\t\t\t\tif (!res) {\n\t\t\t\t\tthis.unsubscribeAll(ws);\n\t\t\t\t\tif (this.getEnableDebug()) {\n\t\t\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Unsub WS', ws['user'], ws['id_socket'], 3);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}, () => {\n\t\t\t\tthis.unsubscribeAll(ws);\n\t\t\t\tif (this.getEnableDebug()) {\n\t\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Unsub WS', ws['user'], ws['id_socket'], 4);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\t// Subscribe to publication\n\tpublic subscribe(messageRoute: string, messageDate: Date, ws: WebSocket, messageId: number, publication: string, subscriptionData: any[]) {\n\t\t// let startDate = new Date();\n\t\tthis._debugSubHits += 1;\n\n\t\tif (!this._debugSubCollections.some(a => a.publication === publication)) {\n\t\t\tthis._debugSubCollections.push({\n\t\t\t\tpublication: publication,\n\t\t\t\thits: 1\n\t\t\t});\n\t\t}\n\t\telse {\n\t\t\tthis._debugSubCollections.filter(a => a.publication === publication)[0].hits += 1;\n\t\t}\n\n\t\tlet pub = this._publications[publication];\n\n\t\tif (!pub) {\n\t\t\tconsole.error(new Date(), 'No Publication: ' + publication);\n\t\t\treturn;\n\t\t}\n\t\telse {\n\t\t\tif (subscriptionData.length > 1 || subscriptionData[0]) {\n\t\t\t\tif (!pub.check) {\n\t\t\t\t\tconsole.error(new Date(), 'No Check Function For Pub ' + publication);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\telse if (!pub.check._schema) {\n\t\t\t\t\tconsole.error(new Date(), 'No Check Schema For Pub ' + publication);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet valObj = {};\n\t\t\t\t\tlet valKeys = Object.keys(pub.check._schema);\n\n\t\t\t\t\tlet rootKeys = valKeys.filter(a => !a.includes('.'));\n\t\t\t\t\t\n\t\t\t\t\tfor (let i = 0; i < subscriptionData.length; i++) {\n\t\t\t\t\t\tvalObj[rootKeys[i]] = subscriptionData[i];\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tpub.check.validate(valObj);\n\t\t\t\t\t}\n\t\t\t\t\tcatch (errors) {\n\t\t\t\t\t\tif (errors) {\n\t\t\t\t\t\t\tconsole.error(new Date(), 'Error in Pub Check (' + publication + ')', errors);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (messageRoute !== 'Bypass') {\n\t\t\t\tlet urlData = messageRoute.split('/');\n\t\t\t\tlet urlModule = '';\n\t\t\t\tlet urlNext = urlData[0];\n\t\t\t\t\n\t\t\t\tif (urlData[0] === '') {\n\t\t\t\t\turlModule = '/';\n\t\t\t\t\turlNext = urlData[1];\n\t\t\t\t}\n\n\t\t\t\turlModule += urlNext;\n\n\t\t\t\tif (urlData.length > 1) {\n\t\t\t\t\turlModule += '/';\n\t\t\t\t}\n\n\t\t\t\tlet otherRouteSubs = this._subscriptions.filter(a => a.clients.some(b => b.id_socket === ws['id_socket'] && b.messageRoute !== 'Bypass' && b.messageRoute !== '/' && b.messageRoute !== messageRoute && !b.messageRoute.startsWith(urlModule)));\n\t\t\t\n\t\t\t\tif (otherRouteSubs.length) {\n\t\t\t\t\tthis._mainServer.getMethodManager().sendEmail('dev@resolveio.com', 'SERVER - Detected Undestroyed Subscription - ' + this.serverConfig['CLIENT_NAME'], 'USER: ' + ws['user'] + ' (Socket: ' + ws['id_socket'] + ') ' + ' is on route: ' + messageRoute + ' but has the following subscriptions on other routes:' + JSON.stringify(otherRouteSubs, null, 2));\n\n\t\t\t\t\totherRouteSubs.forEach(otherSub => {\n\t\t\t\t\t\totherSub.clients.filter(a => a.id_socket === ws['id_socket']).forEach(client => {\n\t\t\t\t\t\t\tthis.unsubscribe(client.messageRoute, new Date(), ws, client.messageId, otherSub.publication, otherSub.subscriptionData);\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet sub = this._subscriptions.filter(a => a.publication === publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscriptionData))[0];\n\n\t\t\t// If sub found (another user watching same data), add client to same sub\n\t\t\tif (sub) {\n\t\t\t\tif (!sub.clients.some(a => a.id_socket === ws['id_socket'] && a.messageId === messageId)) {\n\t\t\t\t\tsub.clients.push({\n\t\t\t\t\t\tid_user: ws['id_user'],\n\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\tid_socket: ws['id_socket'],\n\t\t\t\t\t\tmessageRoute: messageRoute\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\t// If sub not found, create new sub\n\t\t\telse {\n\t\t\t\tthis._subscriptions.push({\n\t\t\t\t\tpublication: publication,\n\t\t\t\t\tsubscriptionData: subscriptionData,\n\t\t\t\t\tcollections: this.getPublicationCollections(publication),\n\t\t\t\t\tclients: [{\n\t\t\t\t\t\tid_user: ws['id_user'],\n\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\tid_socket: ws['id_socket'],\n\t\t\t\t\t\tmessageRoute: messageRoute\n\t\t\t\t\t}],\n\t\t\t\t\tcacheId: 0\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (!sub) {\n\t\t\t\tsub = this._subscriptions.filter(a => a.publication === publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscriptionData))[0];\n\t\t\t}\n\n\t\t\tif (!sub.cacheId && !this._mongoQueue.some(a => a.subscription.publication === sub.publication && JSON.stringify(a.subscription.subscriptionData) === JSON.stringify(sub.subscriptionData))) {\n\t\t\t\tthis.addToQueue({\n\t\t\t\t\t_id: 0,\n\t\t\t\t\ttype: 'newSub',\n\t\t\t\t\tcollection: '',\n\t\t\t\t\tsubscription: sub,\n\t\t\t\t\trunning: false,\n\t\t\t\t\trun_again: false\n\t\t\t\t});\n\n\t\t\t\t// let endDate = new Date();\n\t\t\t\t// this.currentPerfomanceMonitor.push({\n\t\t\t\t// \t_id: this.idPerformance++,\n\t\t\t\t// \tfunction: 'subscribe',\n\t\t\t\t// \tpublication: publication,\n\t\t\t\t// // \tsubscriptionData: subscriptionData,\n\t\t\t\t// \tsubscriptionData: [],\n\t\t\t\t// \tdate_start: startDate,\n\t\t\t\t// \tdate_end: endDate,\n\t\t\t\t// \tduration: moment(endDate).diff(moment(startDate), 'milliseconds', false),\n\t\t\t\t// \tresult: 'Add to Queue'\n\t\t\t\t// });\n\t\t\t}\n\t\t\telse if (sub.cacheId) {\n\t\t\t\tthis.sendDataToOne(ws, messageId, sub, 'newSub', publication);\n\n\t\t\t\t// let endDate = new Date();\n\t\t\t\t// this.currentPerfomanceMonitor.push({\n\t\t\t\t// \t_id: this.idPerformance++,\n\t\t\t\t// \tfunction: 'subscribe',\n\t\t\t\t// \tpublication: publication,\n\t\t\t\t// // \tsubscriptionData: subscriptionData,\n\t\t\t\t// \tsubscriptionData: [],\n\t\t\t\t// \tdate_start: startDate,\n\t\t\t\t// \tdate_end: endDate,\n\t\t\t\t// \tduration: moment(endDate).diff(moment(startDate), 'milliseconds', false),\n\t\t\t\t// \tresult: 'Send Pub Data Once'\n\t\t\t\t// });\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic async createLoggedInUser(id_ws: string): Promise<LoggedInUserModel> {\n\t\treturn new Promise(async (resolve, reject) => {\n\t\t\tlet ws = this._mainServer.getWS(id_ws);\n\n\t\t\tif (ws) {\n\t\t\t\tlet user = {\n\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t__v: 0,\n\t\t\t\t\tdate: new Date(),\n\t\t\t\t\tid_user: ws['id_user'],\n\t\t\t\t\tuser: ws['user'],\n\t\t\t\t\tid_ws: ws['id_socket']\n\t\t\t\t};\n\t\t\t\t\n\t\t\t\tthis._loggedInUsers.push(user);\n\t\t\t\tLoggedInUsers.insertOne(user);\n\t\t\t\t\n\t\t\t\tresolve(user);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tresolve(null);\n\t\t\t}\n\t\t});\n\t}\n\n\t// Unsubscribe from publication \n\tpublic unsubscribe(messageRoute: string, messageDate: Date, ws: WebSocket, messageId: number, publication: string, subscriptionData: any[]) {\n\t\tthis._debugUnSubHits += 1;\n\t\t// let startDate = new Date();\n\t\t// console.log('Before');\n\t\t// console.dir(this._subscriptions.map(a => a.publication));\n\n\t\tif (!this._publications[publication]) {\n\t\t\tconsole.log('No Publication: ' + publication);\n\t\t\treturn;\n\t\t}\n\t\telse {\n\t\t\tlet sub = this._subscriptions.filter(a => a.publication === publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscriptionData))[0];\n\n\t\t\tif (sub) {\n\t\t\t\tfor (let i = sub.clients.length - 1; i >= 0; i--) {\n\t\t\t\t\tif (sub.clients[i].id_user === ws['id_user'] && sub.clients[i].messageId === messageId && sub.clients[i].id_socket === ws['id_socket']) {\n\t\t\t\t\t\tsub.clients.splice(i, 1);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// let endDate = new Date();\n\t\t// this.currentPerfomanceMonitor.push({\n\t\t// \t_id: this.idPerformance++,\n\t\t// \tfunction: 'unsubscribe',\n\t\t// \tpublication: publication,\n\t\t// // \tsubscriptionData: subscriptionData,\n\t\t// \tsubscriptionData: [],\n\t\t// \tdate_start: startDate,\n\t\t// \tdate_end: endDate,\n\t\t// \tduration: moment(endDate).diff(moment(startDate), 'milliseconds', false),\n\t\t// \tresult: 'Done'\n\t\t// });\n\t}\n\n\t// Unsubscribe from publication\n\tpublic async unsubscribeAll(ws: WebSocket) {\n\t\tthis._debugUnSubAllHits += 1;\n\t\t// console.log('Before');\n\t\t// console.dir(this._subscriptions.map(a => a.publication));\n\n\t\t// let startDate = new Date();\n\n\t\tif (ws) {\n\t\t\tlet loggedInUser = await LoggedInUsers.findOne({id_ws: ws['id_socket']});\n\n\t\t\tif (loggedInUser) {\t\n\t\t\t\tif (this._loggedInUsers.map(a => a._id).indexOf(loggedInUser._id) >= 0) {\n\t\t\t\t\tthis._loggedInUsers.splice(this._loggedInUsers.map(a => a._id).indexOf(loggedInUser._id), 1);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tLoggedInUsers.deleteOne({_id: loggedInUser._id});\n\t\t\t}\n\n\t\t\tlet userSubs = this._subscriptions.filter(a => a.clients.some(b => b.id_user === ws['id_user'] && b.id_socket === ws['id_socket']));\n\n\t\t\tfor (let i = userSubs.length - 1; i >= 0; i--) {\n\t\t\t\tlet sub = userSubs[i];\n\n\t\t\t\tfor (let j = sub.clients.length - 1; j >= 0; j--) {\n\t\t\t\t\tif (sub.clients[j].id_socket === ws['id_socket']) {\n\t\t\t\t\t\tsub.clients.splice(j, 1);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tws.close();\n\n\t\t\tprocess.nextTick(() => {\n\t\t\t\tif ([ws.OPEN, ws.CLOSING].includes(<any>ws.readyState)) {\n\t\t\t\t\t// Socket still hangs, hard close\n\t\t\t\t\tws.terminate();\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// let endDate = new Date();\n\t\t\t// this.currentPerfomanceMonitor.push({\n\t\t\t// \t_id: this.idPerformance++,\n\t\t\t// \tfunction: 'unsubscribeAll',\n\t\t\t// \tpublication: '',\n\t\t\t// \tsubscriptionData: [],\n\t\t\t// \tdate_start: startDate,\n\t\t\t// \tdate_end: endDate,\n\t\t\t// \tduration: moment(endDate).diff(moment(startDate), 'milliseconds', false),\n\t\t\t// \tresult: 'Done'\n\t\t\t// });\n\t\t}\n\n\t\t// console.log('After');\n\t\t// console.dir(this._subscriptions.map(a => a.publication));\n\t}\n\n\tpublic getActiveSubscriptions() {\n\t\treturn this._subscriptions;\n\t}\n\n\t// Get publication collection\n\tprivate getPublicationCollections(publication: string) {\n\t\treturn this._publications[publication].collections;\n\t}\n\n\t// Watch (tail) Mongo's operation log on the entire database (all insert/modify/delete will trigger this function)\n\tprivate async tailOpLog(resumeToken?: ResumeToken) {\n\t\tif (this._oplog$ && !this._oplog$.closed) {\n\t\t\tthis._oplog$.removeAllListeners();\n\t\t\tthis._oplog$.close();\n\t\t\tthis._oplog$ = null;\n\t\t}\n\t\n\t\tawait new Promise(resolve => setTimeout(resolve, 1000));\n\n\t\tif (!this._oplog$ || this._oplog$.closed) {\n\t\t\tthis._oplogRetryCount += 1;\n\n\t\t\tif (this._oplogRetryCount > 5) {\n\t\t\t\tconsole.error('****************** TAIL OPLOG ERROR, RETRYING A BUNCH OF TIMES, KILLING PROCESS **************************')\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\n\t\t\tlet lastResumeToken: ResumeToken;\n\n\t\t\tif (resumeToken) {\n\t\t\t\tlastResumeToken = resumeToken;\n\t\t\t\ttry {\n\t\t\t\t\tthis._oplog$ = ResolveIOServer.getMainDB().watch([], {resumeAfter: resumeToken});\n\t\t\t\t}\n\t\t\t\tcatch(errOp) {\n\t\t\t\t\tif (this._oplog$) {\n\t\t\t\t\t\tthis._oplog$.removeAllListeners();\n\t\t\t\t\t\tthis._oplog$.close();\n\t\t\t\t\t\tthis._oplog$ = null;\n\t\t\t\t\t}\n\t\t\t\t\tthis.tailOpLog(resumeToken);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthis._oplog$ = ResolveIOServer.getMainDB().watch();\n\t\t\t}\n\n\t\t\tconsole.log(new Date(), 'oplog started');\n\n\t\t\tthis._oplog$.on('change', (doc: ChangeStreamInsertDocument | ChangeStreamUpdateDocument | ChangeStreamReplaceDocument | ChangeStreamDeleteDocument) => {\n\t\t\t\t// let startDate = new Date();\n\n\t\t\t\tif (doc.ns) {\n\t\t\t\t\tlet collection = doc.ns.coll;\n\n\t\t\t\t\tif (!this._debugOplogCollections.some(a => a.collection === doc.ns.coll && a.type === doc.operationType)) {\n\t\t\t\t\t\tthis._debugOplogCollections.push({\n\t\t\t\t\t\t\tcollection: doc.ns.coll,\n\t\t\t\t\t\t\ttype: doc.operationType,\n\t\t\t\t\t\t\thits: 1\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tthis._debugOplogCollections.filter(a => a.collection === doc.ns.coll && a.type === doc.operationType)[0].hits += 1;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t// console.log(new Date(), 'Op log doc', doc.operationType, collection);\n\n\t\t\t\t\tif (collection && !collection.endsWith('.versions') && !collection.startsWith('monitor-') && collection !== 'logs' && collection !== 'log-method-latencies' && collection !== 'log-subscriptions') {\n\t\t\t\t\t\tthis._debugOplogHits += 1;\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (doc.operationType === 'insert') {\n\t\t\t\t\t\t\tif (collection === 'support-tickets') {\n\t\t\t\t\t\t\t\tif (this.serverConfig['ROOT_URL'] === 'https://resolveio.com') {\n\t\t\t\t\t\t\t\t\tthis._mainServer.getMethodManager().callMethodInternal.call(this._mainServer.getMethodManager(), 'sendSupportTicketEmail', doc.documentKey['_id']);\n\t\t\t\t\t\t\t\t\tthis.invalidatePubsCache(collection, 'insert');\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (collection !== 'method-responses') {\n\t\t\t\t\t\t\t\tthis.invalidatePubsCache(collection, 'insert');\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// let endDate = new Date();\n\t\t\t\t\t\t\t// this.currentPerfomanceMonitor.push({\n\t\t\t\t\t\t\t// \t_id: this.idPerformance++,\n\t\t\t\t\t\t\t// \tfunction: 'oplog',\n\t\t\t\t\t\t\t// \tpublication: collection,\n\t\t\t\t\t\t\t// \tsubscriptionData: [],\n\t\t\t\t\t\t\t// \tdate_start: startDate,\n\t\t\t\t\t\t\t// \tdate_end: endDate,\n\t\t\t\t\t\t\t// \tduration: moment(endDate).diff(moment(startDate), 'milliseconds', false),\n\t\t\t\t\t\t\t// \tresult: 'Insert'\n\t\t\t\t\t\t\t// });\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (doc.operationType === 'update' || doc.operationType === 'replace') {\n\t\t\t\t\t\t\tif (collection !== 'method-responses') {\n\t\t\t\t\t\t\t\tthis.invalidatePubsCache(collection, 'update');\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// let endDate = new Date();\n\t\t\t\t\t\t\t// this.currentPerfomanceMonitor.push({\n\t\t\t\t\t\t\t// \t_id: this.idPerformance++,\n\t\t\t\t\t\t\t// \tfunction: 'oplog',\n\t\t\t\t\t\t\t// \tpublication: collection,\n\t\t\t\t\t\t\t// \tsubscriptionData: [],\n\t\t\t\t\t\t\t// \tdate_start: startDate,\n\t\t\t\t\t\t\t// \tdate_end: endDate,\n\t\t\t\t\t\t\t// \tduration: moment(endDate).diff(moment(startDate), 'milliseconds', false),\n\t\t\t\t\t\t\t// \tresult: 'Update'\n\t\t\t\t\t\t\t// });\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (doc.operationType === 'delete') {\n\t\t\t\t\t\t\tif (collection !== 'method-responses') {\n\t\t\t\t\t\t\t\tthis.invalidatePubsCache(collection, 'delete');\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// let endDate = new Date();\n\t\t\t\t\t\t\t// this.currentPerfomanceMonitor.push({\n\t\t\t\t\t\t\t// \t_id: this.idPerformance++,\n\t\t\t\t\t\t\t// \tfunction: 'oplog',\n\t\t\t\t\t\t\t// \tpublication: collection,\n\t\t\t\t\t\t\t// \tsubscriptionData: [],\n\t\t\t\t\t\t\t// \tdate_start: startDate,\n\t\t\t\t\t\t\t// \tdate_end: endDate,\n\t\t\t\t\t\t\t// \tduration: moment(endDate).diff(moment(startDate), 'milliseconds', false),\n\t\t\t\t\t\t\t// \tresult: 'Delete'\n\t\t\t\t\t\t\t// });\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (collection === 'flags') {\n\t\t\t\t\t\tFlags.findOne({type: 'Enable Debug'}).then(flag => {\n\t\t\t\t\t\t\tif (flag && flag.value) {\n\t\t\t\t\t\t\t\tthis._enableDebug = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tthis._enableDebug = false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tlastResumeToken = doc._id;\n\t\t\t\t}\n\t\t\t});\n\t\t\t\n\t\t\tthis._oplog$.on('error', error => {\n\t\t\t\tconsole.log(new Date(), 'oplog error', error);\n\t\t\t\tthis._oplog$.removeAllListeners();\n\t\t\t\tthis._oplog$.close();\n\t\t\t\tthis._oplog$ = null;\n\t\t\t\tthis.tailOpLog(lastResumeToken);\n\t\t\t});\n\n\t\t\tthis._oplog$.on('end', () => {\n\t\t\t\tconsole.log(new Date(), 'oplog end');\n\t\t\t\tthis._oplog$.removeAllListeners();\n\t\t\t\tthis._oplog$.close();\n\t\t\t\tthis._oplog$ = null;\n\t\t\t\tthis.tailOpLog(lastResumeToken);\n\t\t\t});\n\n\t\t\tthis._oplog$.on('close', () => {\n\t\t\t\tconsole.log(new Date(), 'oplog close');\n\t\t\t\tthis._oplog$.removeAllListeners();\n\t\t\t\tthis._oplog$ = null;\n\t\t\t\tthis.tailOpLog(lastResumeToken);\n\t\t\t});\n\t\t}\n\t}\n\n\t// Fetch pub once, send to all clients linked to this pub\n\tprivate sendDataToOne(ws: WebSocket, messageId: number, subscription: ActiveSubscriptionModel, type: string, collection: string) {\n\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t// let startDate = new Date();\n\n\t\t\tif (!this._publications[subscription.publication].user_specific) { // Same pub for all users\n\t\t\t\tif (subscription.cacheId) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tlet cacheData = JSON.parse(this._nodeCache.get(subscription.cacheId), dateReviver);\n\n\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\tdata: cacheData\n\t\t\t\t\t\t};\n\t\n\t\t\t\t\t\tthis.sendWS(ws, serverRes);\n\t\t\t\t\t}\n\t\t\t\t\tcatch(err) {\n\t\t\t\t\t\tthis._nodeCache.del(subscription.cacheId);\n\t\t\t\t\t\tsubscription.cacheId = 0;\n\n\t\t\t\t\t\tthis.addToQueue({\n\t\t\t\t\t\t\t_id: 0,\n\t\t\t\t\t\t\ttype: 'newSub',\n\t\t\t\t\t\t\tcollection: '',\n\t\t\t\t\t\t\tsubscription: subscription,\n\t\t\t\t\t\t\trunning: false,\n\t\t\t\t\t\t\trun_again: false\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\t// let endDate = new Date();\n\t\t\t\t\t// this.currentPerfomanceMonitor.push({\n\t\t\t\t\t// \t_id: this.idPerformance++,\n\t\t\t\t\t// \tfunction: 'sendDataToOne',\n\t\t\t\t\t// \tpublication: subscription.publication,\n\t\t\t\t\t// // \tsubscriptionData: subscription.subscriptionData,\n\t\t\t\t\t// \tsubscriptionData: [],\n\t\t\t\t\t// \tdate_start: startDate,\n\t\t\t\t\t// \tdate_end: endDate,\n\t\t\t\t\t// \tduration: moment(endDate).diff(moment(startDate), 'milliseconds', false),\n\t\t\t\t\t// \tresult: 'Send cache'\n\t\t\t\t\t// });\n\n\t\t\t\t\tresolve(true);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tthis._mainServer.getMethodManager().sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'Error Detected During sendDataToOne - No Cache! - ' + subscription.publication + '\\n\\nData \\n' + JSON.stringify(subscription.subscriptionData, null, 2));\n\n\t\t\t\t\tresolve(false);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse { // Pub is different for each user (Look at users publication) [MUCH SLOWER, RE-RUNS FOR EACH USER]\n\t\t\t\tlet monitor = this._monitorManagerFunction.startMonitorFunction('User Specific Publication', subscription.publication, '', '', subscription.subscriptionData);\n\t\t\t\tthis._publications[subscription.publication].function.call(Object.assign({}, this, SubscriptionManager.prototype), ws['id_user'], ...subscription.subscriptionData)\n\t\t\t\t.then(res => {\n\t\t\t\t\tthis._monitorManagerFunction.finishMonitorFunction(monitor);\n\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\tdata: res\n\t\t\t\t\t};\n\n\t\t\t\t\t// console.log('Send Pub Data Once 2', new Date(), 'Success', subscription);\n\n\t\t\t\t\tthis.sendWS(ws, serverRes);\n\n\t\t\t\t\t// let endDate = new Date();\n\t\t\t\t\t// this.currentPerfomanceMonitor.push({\n\t\t\t\t\t// \t_id: this.idPerformance++,\n\t\t\t\t\t// \tfunction: 'sendDataToOne',\n\t\t\t\t\t// \tpublication: subscription.publication,\n\t\t\t\t\t// // \tsubscriptionData: subscription.subscriptionData,\n\t\t\t\t\t// \tsubscriptionData: [],\n\t\t\t\t\t// \tdate_start: startDate,\n\t\t\t\t\t// \tdate_end: endDate,\n\t\t\t\t\t// \tduration: moment(endDate).diff(moment(startDate), 'milliseconds', false),\n\t\t\t\t\t// \tresult: 'Send ws spec data'\n\t\t\t\t\t// });\n\n\t\t\t\t\tresolve(true);\n\n\t\t\t\t}, err => {\n\t\t\t\t\tthis._monitorManagerFunction.finishMonitorFunction(monitor);\n\t\t\t\t\t\n\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\thasError: true,\n\t\t\t\t\t\tdata: err\n\t\t\t\t\t};\n\n\t\t\t\t\t// console.log('Send Pub Data Once 2', new Date(), 'Error', subscription);\n\n\t\t\t\t\tthis.sendWS(ws, serverRes);\n\n\t\t\t\t\tthis._mainServer.getMethodManager().sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'Error Detected During Subscription ' + subscription.publication + ' - (sendDataToOne - WS)\\n\\nData \\n' + JSON.stringify(subscription.subscriptionData, null, 2) + '\\n\\nErrors\\n' + JSON.stringify(err, null, 2));\n\n\t\t\t\t\treject(err);\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n\n\t// Fetch pub once, send to all clients linked to this pub\n\tprivate sendDataToAll(mongoQueue: MongoQueueModel) {\n\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t// let startDate = new Date();\n\t\t\tif (!mongoQueue.subscription.clients.length) {\t\t\t\t\n\t\t\t\tif (mongoQueue.subscription.cacheId) {\n\t\t\t\t\tthis._nodeCache.del(mongoQueue.subscription.cacheId);\n\t\t\t\t}\n\n\t\t\t\tif (this._subscriptions.findIndex(a => a.publication === mongoQueue.subscription.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(mongoQueue.subscription.subscriptionData)) >= 0) {\n\t\t\t\t\tthis._subscriptions.splice(this._subscriptions.findIndex(a => a.publication === mongoQueue.subscription.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(mongoQueue.subscription.subscriptionData)), 1);\n\t\t\t\t}\n\n\t\t\t\tresolve(false);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (mongoQueue.subscription.publication !== 'superadminAPM' && mongoQueue.subscription.publication !== 'loggedInUsers') {\n\t\t\t\t\tthis._mainServer.getMethodManager().callMethodInternal.call(this._mainServer.getMethodManager(), 'insertSubscriptionLog', mongoQueue.type, mongoQueue.subscription.publication, mongoQueue.collection, JSON.stringify(mongoQueue.subscription.subscriptionData));\n\t\t\t\t}\n\n\t\t\t\tlet monitor = this._monitorManagerFunction.startMonitorFunction('Publication', mongoQueue.subscription.publication, '', '', mongoQueue.subscription.subscriptionData);\n\t\t\t\tthis._publications[mongoQueue.subscription.publication].function.call(Object.assign({}, this, SubscriptionManager.prototype), ...mongoQueue.subscription.subscriptionData)\n\t\t\t\t.then(res => {\n\t\t\t\t\tthis._monitorManagerFunction.finishMonitorFunction(monitor);\n\t\t\t\t\tif (!mongoQueue.subscription.clients.length) {\n\t\t\t\t\t\tlet nodeCacheSize = this._nodeCache.getStats().vsize;\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (nodeCacheSize > this._heapLimit) {\n\t\t\t\t\t\t\tlet deleteCount = 0;\n\n\t\t\t\t\t\t\tconst subArr = this._subscriptions.filter(a => a.cacheId && !a.clients.length);\n\n\t\t\t\t\t\t\tfor (let zz = 0; zz < subArr.length; zz++) {\n\t\t\t\t\t\t\t\tthis._debugRemoveCacheHits += 1;\n\n\t\t\t\t\t\t\t\tthis._nodeCache.del(subArr[zz].cacheId);\n\t\t\t\t\t\t\t\tsubArr[zz].cacheId = 0;\n\n\t\t\t\t\t\t\t\tdeleteCount += 1;\n\n\t\t\t\t\t\t\t\tnodeCacheSize = this._nodeCache.getStats().vsize;\n\n\t\t\t\t\t\t\t\tif (nodeCacheSize < this._heapLimit * 0.75) {\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tconsole.log('Sub Cache: ' + 'Too Big - ' + mongoQueue.subscription.publication + ' - Deleted: ' + deleteCount + ' - ' + nodeCacheSize);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (mongoQueue.subscription.cacheId) {\n\t\t\t\t\t\t\tthis._nodeCache.del(mongoQueue.subscription.cacheId);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet cacheId = this._cacheId;\n\t\t\t\t\t\tthis._cacheId += 1;\n\n\t\t\t\t\t\tthis._nodeCache.set(cacheId, JSON.stringify(res));\n\t\t\t\t\t\tmongoQueue.subscription.cacheId = cacheId;\n\n\t\t\t\t\t\t// let endDate = new Date();\n\t\t\t\t\t\t// this.currentPerfomanceMonitor.push({\n\t\t\t\t\t\t// \t_id: this.idPerformance++,\n\t\t\t\t\t\t// \tfunction: 'sendPubData',\n\t\t\t\t\t\t// \tpublication: subscription.publication,\n\t\t\t\t\t\t// // \tsubscriptionData: subscription.subscriptionData,\n\t\t\t\t\t\t// \tsubscriptionData: [],\n\t\t\t\t\t\t// \tdate_start: startDate,\n\t\t\t\t\t\t// \tdate_end: endDate,\n\t\t\t\t\t\t// \tduration: moment(endDate).diff(moment(startDate), 'milliseconds', false),\n\t\t\t\t\t\t// \tresult: 'No clients'\n\t\t\t\t\t\t// });\n\n\t\t\t\t\t\tresolve(false);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tif (!mongoQueue.subscription.cacheId || this._nodeCache.get(mongoQueue.subscription.cacheId) !== JSON.stringify(res)) {\n\t\t\t\t\t\t\tmongoQueue.subscription.clients.forEach(client => {\n\t\t\t\t\t\t\t\tlet ws = this._mainServer.getWS(client.id_socket);\n\n\t\t\t\t\t\t\t\tif (ws) {\n\t\t\t\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\t\t\t\tmessageId: client.messageId,\n\t\t\t\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\t\t\t\tdata: res\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\n\t\t\t\t\t\t\t\t\tthis.sendWS(ws, serverRes);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\n\t\t\t\t\t\t\tlet nodeCacheSize = this._nodeCache.getStats().vsize;\n\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (nodeCacheSize > this._heapLimit) {\n\t\t\t\t\t\t\t\tlet deleteCount = 0;\n\n\t\t\t\t\t\t\t\tconst subArr = this._subscriptions.filter(a => a.cacheId && !a.clients.length);\n\t\n\t\t\t\t\t\t\t\tfor (let zz = 0; zz < subArr.length; zz++) {\n\t\t\t\t\t\t\t\t\tthis._nodeCache.del(subArr[zz].cacheId);\n\t\t\t\t\t\t\t\t\tsubArr[zz].cacheId = 0;\n\t\n\t\t\t\t\t\t\t\t\tdeleteCount += 1;\n\n\t\t\t\t\t\t\t\t\tnodeCacheSize = this._nodeCache.getStats().vsize;\n\t\n\t\t\t\t\t\t\t\t\tif (nodeCacheSize < this._heapLimit * 0.75) {\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tconsole.log('Sub Cache: ' + 'Too Big - ' + mongoQueue.subscription.publication + ' - Deleted: ' + deleteCount + ' - ' + nodeCacheSize);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (mongoQueue.subscription.cacheId) {\n\t\t\t\t\t\t\t\tthis._nodeCache.del(mongoQueue.subscription.cacheId);\n\t\t\t\t\t\t\t}\n\t\n\t\t\t\t\t\t\tlet cacheId = this._cacheId;\n\t\t\t\t\t\t\tthis._cacheId += 1;\n\n\t\t\t\t\t\t\tthis._nodeCache.set(cacheId, JSON.stringify(res));\n\t\t\t\t\t\t\tmongoQueue.subscription.cacheId = cacheId;\n\n\t\t\t\t\t\t\t// let endDate = new Date();\n\t\t\t\t\t\t\t// this.currentPerfomanceMonitor.push({\n\t\t\t\t\t\t\t// \t_id: this.idPerformance++,\n\t\t\t\t\t\t\t// \tfunction: 'sendPubData',\n\t\t\t\t\t\t\t// \tpublication: subscription.publication,\n\t\t\t\t\t\t\t// // \tsubscriptionData: subscription.subscriptionData,\n\t\t\t\t\t\t\t// \tsubscriptionData: [],\n\t\t\t\t\t\t\t// \tdate_start: startDate,\n\t\t\t\t\t\t\t// \tdate_end: endDate,\n\t\t\t\t\t\t\t// \tduration: moment(endDate).diff(moment(startDate), 'milliseconds', false),\n\t\t\t\t\t\t\t// \tresult: 'Same data'\n\t\t\t\t\t\t\t// });\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tresolve(true);\n\t\t\t\t\t}\n\t\t\t\t}, err => {\n\t\t\t\t\tthis._monitorManagerFunction.finishMonitorFunction(monitor);\n\t\t\t\t\tthis._mainServer.getMethodManager().sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'Error Detected During Subscription ' + mongoQueue.subscription.publication + ' - (sendPubData)\\n\\nData \\n' + JSON.stringify(mongoQueue.subscription.subscriptionData, null, 2) + '\\n\\nErrors\\n' + JSON.stringify(err, null, 2));\n\n\t\t\t\t\tmongoQueue.subscription.clients.forEach(client => {\n\t\t\t\t\t\tlet ws = this._mainServer.getWS(client.id_socket);\n\n\t\t\t\t\t\tif (ws) {\n\t\t\t\t\t\t\tif (ws['id_socket'] === client.id_socket) {\n\t\t\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\t\t\tmessageId: client.messageId,\n\t\t\t\t\t\t\t\t\thasError: true,\n\t\t\t\t\t\t\t\t\tdata: err\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tthis.sendWS(ws, serverRes);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\treject(err);\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate sendWS(ws: WebSocket, data: ServerResponseModel) {\n\t\tthis._sendQueue.splice(0, 0, {\n\t\t\tid_ws: ws['id_socket'],\n\t\t\tdata: data\n\t\t});\n\t}\n\n\tpublic getEnableDebug() {\n\t\treturn this._enableDebug;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/managers/subscription.manager.ts"],"names":["logs_1","require","app_status_1","files_1","super_admin_1","logged_in_users_collection_1","cron_jobs_1","flags_1","method_responses_1","index_1","notifications_1","report_builder_reports_1","report_builder_libraries_1","user_groups_1","user_guides_1","report_builder_dashboard_builders_1","mongo_manager_1","common_1","NodeCache","flag_collection_1","os_1","numCPUs","cpus","length","v8","SubscriptionManager","mainServer","wss","serverConfig","monitorManagerFunction","_this","this","_publications","_subscriptions","_loggedInUsers","_mongoQueue","_mongoQueueId","_sendQueue","_runningQueue","_cacheId","_heapStats","getHeapStatistics","_heapLimit","heap_size_limit","_enableDebug","_debugOplogCollections","_debugOplogHits","_debugSubCollections","_debugSubHits","_debugUnSubHits","_debugUnSubAllHits","_debugMongoQueueHits","_debugMongoQueueCollections","_debugSendQueueHits","_debugRemoveCacheHits","_oplogRetryCount","_mainServer","_monitorManagerFunction","_nodeCache","stdTTL","checkperiod","_wss","loadSuperAdminPublications","loadAppStatusPublications","loadLogPublications","loadFilePublications","loadCronJobPublications","loadFlagsPublications","loadMethodResponsePublications","loadNotificationPublications","loadReportBuilderReportPublications","loadReportBuilderLibraryPublications","loadUserGroupPublications","loadUserGuidePublications","loadReportBuilderDashboardBuilderPublications","tailOpLog","setInterval","getEnableDebug","console","log","Date","JSON","stringify","sort","a","b","collection","localeCompare","publication","type","__awaiter","i","this_1","sendItem","ws","getWS","id_ws","readyState","OPEN","bufferedAmount","pop","send","data","error","unsubscribeAll","splice","queueArr","filter","running","forEach","entry","this_2","mongoQueue","some","subscription","hits","push","user_specific","promises","j","clients","client","id_socket","sendDataToOne","messageId","catch","err","getMethodManager","sendEmail","id_user","Promise","all","then","run_again","map","_id","indexOf","sendDataToAll","_a","LoggedInUsers","find","_b","sent","userCopy","deepCopy","loggedInUser","date","now","getTime","this_3","sub","deleteOne","findIndex","this_4","Flags","findOne","flag","value","prototype","addToQueue","subscriptionData","invalidatePubsCache","ResolveIOServer","getMongoManager","invalidateQueryCache","collSubs","collections","includes","publications","method","Object","assign","loggedInLatency","updateOne","$set","latency","res","subscribe","messageRoute","messageDate","pub","check","_schema","valObj","rootKeys","keys","validate","errors","urlData","split","urlModule_1","urlNext","otherRouteSubs","startsWith","otherSub","unsubscribe","sub_1","getPublicationCollections","cacheId","createLoggedInUser","resolve","reject","user","objectIdHexString","__v","insertOne","userSubs","close","process","nextTick","CLOSING","terminate","getActiveSubscriptions","resumeToken","_oplog$","closed","removeAllListeners","setTimeout","exit","lastResumeToken_1","getMainDB","watch","resumeAfter","errOp","on","doc","ns","coll","operationType","endsWith","callMethodInternal","call","documentKey","monitor_1","startMonitorFunction","function","apply","__spreadArray","finishMonitorFunction","sendWS","hasError","cacheData","parse","get","dateReviver","serverRes","del","monitor_2","nodeCacheSize","getStats","vsize","deleteCount","subArr","zz","set","exports"],"mappings":"knDAGAA,Q,0FAAAC,QAAA,sBAAA,GACAC,aAAAD,QAAA,4BAAA,EACAE,QAAAF,QAAA,uBAAA,EACAG,cAAAH,QAAA,6BAAA,EACAI,6BAAAJ,QAAA,2CAAA,EACAK,YAAAL,QAAA,2BAAA,EACAM,QAAAN,QAAA,uBAAA,EACAO,mBAAAP,QAAA,kCAAA,EAEAQ,QAAAR,QAAA,UAAA,EACAS,gBAAAT,QAAA,+BAAA,EACAU,yBAAAV,QAAA,wCAAA,EAIAW,2BAAAX,QAAA,0CAAA,EACAY,cAAAZ,QAAA,6BAAA,EACAa,cAAAb,QAAA,6BAAA,EACAc,oCAAAd,QAAA,mDAAA,EACAe,gBAAAf,QAAA,iBAAA,EACAgB,SAAAhB,QAAA,gBAAA,EACAiB,UAAAjB,QAAA,YAAA,EAEAkB,kBAAAlB,QAAA,gCAAA,EACAmB,KAA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U4C,EAAK,KAAM,CAAC,CAAC,EAEnWd,EAAWE,aAAaM,QAAQX,QAAQ,SAAAY,GACvC,IAAI3B,EAAKhE,EAAK0B,YAAYuC,MAAM0B,EAAOC,SAAS,EAE5C5B,GACCA,EAAc,YAAM2B,EAAOC,YAC1B2H,EAAiC,CACpCzH,UAAWH,EAAOG,UAClBoH,SAAU,CAAA,EACV1I,KAAMwB,C,EAGPhG,EAAKiN,OAAOjJ,EAAIuJ,CAAS,EAG5B,CAAC,EAED5C,EAAO3E,CAAG,CACX,CAAC,IA5JGd,EAAWE,aAAaoF,SAC3BvK,KAAK2B,WAAW4L,IAAItI,EAAWE,aAAaoF,OAAO,EAGgJ,GAAhMvK,KAAKE,eAAeuH,UAAU,SAAApE,GAAK,OAAAA,EAAEI,cAAgBwB,EAAWE,aAAa1B,aAAeP,KAAKC,UAAUE,EAAE4E,gBAAgB,IAAM/E,KAAKC,UAAU8B,EAAWE,aAAa8C,gBAAgB,CAAvJ,CAAwJ,GAC9LjI,KAAKE,eAAewE,OAAO1E,KAAKE,eAAeuH,UAAU,SAAApE,GAAK,OAAAA,EAAEI,cAAgBwB,EAAWE,aAAa1B,aAAeP,KAAKC,UAAUE,EAAE4E,gBAAgB,IAAM/E,KAAKC,UAAU8B,EAAWE,aAAa8C,gBAAgB,CAAvJ,CAAwJ,EAAG,CAAC,EAG3NwC,EAAQ,CAAA,CAAK,G,QAsJd,CACF,EAEQ/K,EAAAqI,UAAAiF,OAAR,SAAejJ,EAAeQ,GAC7BvE,KAAKM,WAAWoE,OAAO,EAAG,EAAG,CAC5BT,MAAOF,EAAc,UACrBQ,KAAMA,C,CACN,CACF,EAEO7E,EAAAqI,UAAAjF,eAAP,WACC,OAAO9C,KAAKa,YACb,EACDnB,CAAA,EAAC,EA/nCYsO,QAAAtO,oBAAAA","file":"subscription.manager.js","sourcesContent":["import { ServerResponseModel } from '../models/server-response.model';\nimport { ActiveSubscriptionModel, SubscriptionModel } from '../models/subscription.model';\nimport * as WebSocket from 'ws';\nimport { loadLogPublications } from '../publications/logs';\nimport { loadAppStatusPublications } from '../publications/app-status';\nimport { loadFilePublications } from '../publications/files';\nimport { loadSuperAdminPublications } from '../publications/super-admin';\nimport { LoggedInUsers } from '../collections/logged-in-users.collection';\nimport { loadCronJobPublications } from '../publications/cron-jobs';\nimport { loadFlagsPublications } from '../publications/flags';\nimport { loadMethodResponsePublications } from '../publications/method-responses';\nimport ResolveIOMainServer from '../server-app';\nimport { ResolveIOServer } from '../index';\nimport { loadNotificationPublications } from '../publications/notifications';\nimport { loadReportBuilderReportPublications } from '../publications/report-builder-reports';\nimport { LoggedInUserModel } from '../models/logged-in-users.model';\n\nimport { ChangeStream, ChangeStreamDeleteDocument, ChangeStreamDocument, ChangeStreamInsertDocument, ChangeStreamReplaceDocument, ChangeStreamUpdateDocument, ResumeToken } from 'mongodb';\nimport { loadReportBuilderLibraryPublications } from '../publications/report-builder-libraries';\nimport { loadUserGroupPublications } from '../publications/user-groups';\nimport { loadUserGuidePublications } from '../publications/user-guides';\nimport { loadReportBuilderDashboardBuilderPublications } from '../publications/report-builder-dashboard-builders';\nimport { objectIdHexString } from './mongo.manager';\nimport { dateReviver, deepCopy } from '../util/common';\nimport * as NodeCache from 'node-cache';\nimport { MonitorManagerFunction } from './monitor.manager';\nimport { Flags } from '../collections/flag.collection';\nimport { cpus } from 'os';\nconst numCPUs = cpus().length;\nconst v8 = require('v8');\n\n// Performance Dependencies\n// import * as path from 'path';\n// import { Worker } from 'worker_threads';\n\ninterface MongoQueueModel {\n\t_id: number,\n\ttype: string;\n\tcollection: string;\n\tsubscription: ActiveSubscriptionModel;\n\trunning: boolean;\n\trun_again: boolean;\n}\n\n// interface CurrentPerformanceMonitor {\n// \t_id: number;\n// \tfunction: string;\n// \tpublication: string;\n// \tsubscriptionData: any[];\n// \tdate_start: Date;\n// \tdate_end: Date;\n// \tduration: number;\n// \tresult: string;\n// }\n\nexport class SubscriptionManager {\n\n\tprivate _mainServer: ResolveIOMainServer;\n\tprivate _publications: SubscriptionModel = {};\n\tprivate _subscriptions: ActiveSubscriptionModel[] = [];\n\tprivate _wss: WebSocket.Server;\n\tprivate _loggedInUsers: LoggedInUserModel[] = [];\n\n\tprivate _mongoQueue: MongoQueueModel[] = [];\n\tprivate _mongoQueueId = 0;\n\n\tprivate _sendQueue = [];\n\tprivate _runningQueue = false;\n\t\n\tprivate _oplog$: ChangeStream;\n\n\tprivate _nodeCache;\n\tprivate _cacheId = 1;\n\n\tprivate serverConfig;\n\n\tprivate _heapStats = v8.getHeapStatistics();\n\tprivate _heapLimit = this._heapStats.heap_size_limit / numCPUs / 8;\n\n\tprivate _monitorManagerFunction: MonitorManagerFunction;\n\n\tprivate _enableDebug = false;\n\tprivate _debugOplogCollections = [];\n\tprivate _debugOplogHits = 0;\n\tprivate _debugSubCollections = [];\n\tprivate _debugSubHits = 0;\n\tprivate _debugUnSubHits = 0;\n\tprivate _debugUnSubAllHits = 0;\n\tprivate _debugMongoQueueHits = 0;\n\tprivate _debugMongoQueueCollections = [];\n\tprivate _debugSendQueueHits = 0;\n\tprivate _debugRemoveCacheHits = 0;\n\n\tprivate _oplogRetryCount = 0;\n\n\t// private currentPerfomanceMonitor: CurrentPerformanceMonitor[] = [];\n\t// private idPerformance: number = 0;\n\t// private performanceThread;\n\n\tconstructor(mainServer, wss: WebSocket.Server, serverConfig, monitorManagerFunction: MonitorManagerFunction) {\n\t\tthis._mainServer = mainServer;\n\t\tthis._monitorManagerFunction = monitorManagerFunction;\n\n\t\tthis._nodeCache = new NodeCache( { stdTTL: 0, checkperiod: 0 } );\n\n\t\t// setTimeout(() => {\n\t\t// \tconsole.log('Setting up performance thread');\n\n\t\t// \tthis.performanceThread = new Worker(path.join(__dirname, './subscription.performance.js'));\n\n\t\t// \tthis.performanceThread.on('exit', code => {\n\t\t// \t\tconsole.error(new Date(), 'THREAD EXITED!!!!!!!!!!!!!!!!!!', code);\n\t\t// \t});\n\n\t\t// \tthis.performanceThread.on('error', code => {\n\t\t// \t\tconsole.error(new Date(), 'THREAD RECV ERROR !!!!!!!!!!!!!!!!!!', code);\n\t\t// \t});\n\t\t// }, 5000);\n\n\t\t// setInterval(() => {\n\t\t// \tconsole.log('Post thread msg');\n\t\t// \tthis.performanceThread.postMessage(this.currentPerfomanceMonitor);\n\t\t// \tthis.currentPerfomanceMonitor = [];\n\t\t// }, 10000);\n\n\t\tthis.serverConfig = serverConfig;\n\t\tthis._wss = wss;\n\n\t\t// Publications\n\t\tloadSuperAdminPublications(this);\n\t\tloadAppStatusPublications(this);\n\t\tloadLogPublications(this);\n\t\tloadFilePublications(this);\n\t\tloadCronJobPublications(this);\n\t\tloadFlagsPublications(this);\n\t\tloadMethodResponsePublications(this);\n\t\tloadNotificationPublications(this);\n\t\tloadReportBuilderReportPublications(this);\n\t\tloadReportBuilderLibraryPublications(this);\n\t\tloadUserGroupPublications(this);\n\t\tloadUserGuidePublications(this);\n\t\tloadReportBuilderDashboardBuilderPublications(this);\n\n\t\tthis.tailOpLog();\n\n\t\tsetInterval(() => {\n\t\t\tthis._oplogRetryCount = 0;\n\t\t}, 15000);\n\n\t\tsetInterval(() => {\n\t\t\tif (this.getEnableDebug()) {\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Subs', this._subscriptions.length);\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Logged In Users', this._loggedInUsers.length);\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Mongo Queue', this._mongoQueue.length);\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Mongo Queue Hits', this._debugMongoQueueHits);\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Mongo Queue Collections', JSON.stringify(this._debugMongoQueueCollections.sort((a, b) => a.collection.localeCompare(b.collection) || a.publication.localeCompare(b.publication)), null, 2));\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Oplog Hits', this._debugOplogHits);\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Oplog Collections', JSON.stringify(this._debugOplogCollections.sort((a, b) => a.collection.localeCompare(b.collection) || a.type.localeCompare(b.type)), null, 2));\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Send Queue Hits', this._debugSendQueueHits);\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Sub Hits', this._debugSubHits);\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Sub Collections', JSON.stringify(this._debugSubCollections.sort((a, b) => a.publication.localeCompare(b.publication)), null, 2));\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Unsub Hits', this._debugUnSubHits);\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Unsub All Hits', this._debugUnSubAllHits);\n\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Cache Cleanup Hits', this._debugRemoveCacheHits);\n\t\t\t}\n\t\t\t\n\t\t\tthis._debugOplogHits = 0;\n\t\t\tthis._debugOplogCollections = [];\n\t\t\tthis._debugSubCollections = [];\n\t\t\tthis._debugMongoQueueHits = 0;\n\t\t\tthis._debugMongoQueueCollections = [];\n\t\t\tthis._debugSendQueueHits = 0;\n\t\t\tthis._debugSubHits = 0;\n\t\t\tthis._debugUnSubHits = 0;\n\t\t\tthis._debugUnSubAllHits = 0;\n\t\t\tthis._debugRemoveCacheHits = 0;\n\t\t}, 60000);\n\n\t\tsetInterval(async () => {\n\t\t\tif (!this._runningQueue) {\n\t\t\t\tthis._runningQueue = true;\n\n\t\t\t\tif (this._sendQueue.length) {\n\t\t\t\t\t// let startDate = new Date();\n\t\t\t\t\tfor (let i = this._sendQueue.length - 1; i >= 0; i--) {\n\t\t\t\t\t\tthis._debugSendQueueHits += 1;\n\n\t\t\t\t\t\tlet ws = this._mainServer.getWS(this._sendQueue[i].id_ws);\n\t\t\t\t\t\tif (ws && ws.readyState === ws.OPEN) {\n\t\t\t\t\t\t\tif (ws.bufferedAmount < 20480) {\n\t\t\t\t\t\t\t\tlet sendItem = this._sendQueue.pop();\n\t\t\t\t\t\t\t\tws.send(JSON.stringify(sendItem.data), (error) => {\n\t\t\t\t\t\t\t\t\tif (error) {\n\t\t\t\t\t\t\t\t\t\tif (this.getEnableDebug()) {\n\t\t\t\t\t\t\t\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Unsub WS', ws['user'], ws['id_socket'], 1);\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tthis.unsubscribeAll(ws);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tthis._sendQueue.splice(i, 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// let endDate = new Date();\n\t\t\t\t\t// this.currentPerfomanceMonitor.push({\n\t\t\t\t\t// \t_id: this.idPerformance++,\n\t\t\t\t\t// \tfunction: 'sendInterval',\n\t\t\t\t\t// \tpublication: '',\n\t\t\t\t\t// \tsubscriptionData: [],\n\t\t\t\t\t// \tdate_start: startDate,\n\t\t\t\t\t// \tdate_end: endDate,\n\t\t\t\t\t// \tduration: moment(endDate).diff(moment(startDate), 'milliseconds', false),\n\t\t\t\t\t// \tresult: 'Done'\n\t\t\t\t\t// });\n\t\t\t\t}\n\n\t\t\t\tconst queueArr = this._mongoQueue.filter(a => !a.running);\n\t\t\t\tif (queueArr.length) {\n\t\t\t\t\tqueueArr.forEach(entry => {\n\t\t\t\t\t\tentry.running = true;\n\t\t\t\t\t});\n\n\t\t\t\t\tfor (let i = queueArr.length - 1; i >= 0; i--) {\n\t\t\t\t\t\tthis._debugMongoQueueHits += 1;\n\t\t\t\t\t\t\n\t\t\t\t\t\tlet mongoQueue = queueArr[i];\n\n\t\t\t\t\t\tif (!this._debugMongoQueueCollections.some(a => a.collection === mongoQueue.collection && a.publication === mongoQueue.subscription.publication)) {\n\t\t\t\t\t\t\tthis._debugMongoQueueCollections.push({\n\t\t\t\t\t\t\t\tcollection: mongoQueue.collection,\n\t\t\t\t\t\t\t\tpublication: mongoQueue.subscription.publication,\n\t\t\t\t\t\t\t\thits: 1\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tthis._debugMongoQueueCollections.filter(a => a.collection === mongoQueue.collection && a.publication === mongoQueue.subscription.publication)[0].hits += 1;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (this._publications[mongoQueue.subscription.publication].user_specific) {\n\t\t\t\t\t\t\tlet promises = [];\n\t\t\t\t\t\t\tfor (let j = 0; j < mongoQueue.subscription.clients.length; j++) {\n\t\t\t\t\t\t\t\tlet client = mongoQueue.subscription.clients[j];\n\t\t\t\t\t\t\t\tlet ws = this._mainServer.getWS(client.id_socket);\n\t\t\t\t\t\t\t\tif (ws && ws['id_socket'] === client.id_socket) {\n\t\t\t\t\t\t\t\t\tpromises.push(this.sendDataToOne(ws, client.messageId, mongoQueue.subscription, mongoQueue.type, mongoQueue.collection).catch((err) => {\n\t\t\t\t\t\t\t\t\t\tthis._mainServer.getMethodManager().sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'Error Detected During sendDataToOne - User Specific - Socket: ' + client.id_socket + ', User: ' + client.id_user + ', MessageId: ' + client.messageId + ', Pub: ' + mongoQueue.subscription.publication + ', Err: ' + JSON.stringify(err, null, 2));\n\t\t\t\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tPromise.all(promises).then(() => {\n\t\t\t\t\t\t\t\tif (mongoQueue.run_again) {\n\t\t\t\t\t\t\t\t\tmongoQueue.running = false;\n\t\t\t\t\t\t\t\t\tmongoQueue.run_again = false;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tif (this._mongoQueue.map(a => a._id).indexOf(mongoQueue._id) >= 0) {\n\t\t\t\t\t\t\t\t\t\tthis._mongoQueue.splice(this._mongoQueue.map(a => a._id).indexOf(mongoQueue._id), 1);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tthis.sendDataToAll(mongoQueue).then(() => {\n\t\t\t\t\t\t\t\tif (mongoQueue.run_again) {\n\t\t\t\t\t\t\t\t\tmongoQueue.running = false;\n\t\t\t\t\t\t\t\t\tmongoQueue.run_again = false;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tif (this._mongoQueue.map(a => a._id).indexOf(mongoQueue._id) >= 0) {\n\t\t\t\t\t\t\t\t\t\tthis._mongoQueue.splice(this._mongoQueue.map(a => a._id).indexOf(mongoQueue._id), 1);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}, () => {\n\t\t\t\t\t\t\t\tif (this._mongoQueue.map(a => a._id).indexOf(mongoQueue._id) >= 0) {\n\t\t\t\t\t\t\t\t\tthis._mongoQueue.splice(this._mongoQueue.map(a => a._id).indexOf(mongoQueue._id), 1);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// let endDate = new Date();\n\t\t\t\t\t\n\t\t\t\t\t// this.currentPerfomanceMonitor.push({\n\t\t\t\t\t// \t_id: this.idPerformance++,\n\t\t\t\t\t// \tfunction: 'mongoQueue',\n\t\t\t\t\t// \tpublication: '',\n\t\t\t\t\t// \tsubscriptionData: [],\n\t\t\t\t\t// \tdate_start: startDate,\n\t\t\t\t\t// \tdate_end: endDate,\n\t\t\t\t\t// \tduration: moment(endDate).diff(moment(startDate), 'milliseconds', false),\n\t\t\t\t\t// \tresult: 'Done'\n\t\t\t\t\t// });\n\t\t\t\t}\t\n\n\t\t\t\tthis._runningQueue = false;\n\t\t\t}\n\t\t}, 25);\n\n\t\tsetInterval(async () => {\n\t\t\tthis._loggedInUsers = await LoggedInUsers.find();\n\t\n\t\t\tlet userCopy = deepCopy(this._loggedInUsers);\n\t\t\tfor (let i = this._loggedInUsers.length - 1; i >= 0; i--) {\n\t\t\t\tlet loggedInUser = userCopy[i];\n\n\t\t\t\tif (!loggedInUser.date || Date.now() - loggedInUser.date.getTime() > 120000) {\n\t\t\t\t\tif (this._mainServer.getWS(loggedInUser.id_ws)) {\n\t\t\t\t\t\tif (this.getEnableDebug()) {\n\t\t\t\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Unsub WS', this._mainServer.getWS(loggedInUser.id_ws)['user'], this._mainServer.getWS(loggedInUser.id_ws)['id_socket'], 2);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthis.unsubscribeAll(this._mainServer.getWS(loggedInUser.id_ws));\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tthis._subscriptions.forEach(sub => {\n\t\t\t\t\t\t\tfor (let j = sub.clients.length - 1; j >= 0; j--) {\n\t\t\t\t\t\t\t\tlet client = sub.clients[j];\n\n\t\t\t\t\t\t\t\tif (client.id_socket === loggedInUser.id_ws) {\n\t\t\t\t\t\t\t\t\tsub.clients.splice(j, 1);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tLoggedInUsers.deleteOne({_id: loggedInUser._id});\n\n\t\t\t\t\t\tif (this._loggedInUsers.findIndex(a => a._id === loggedInUser._id) >= 0) {\n\t\t\t\t\t\t\tthis._loggedInUsers.splice(this._loggedInUsers.findIndex(a => a._id === loggedInUser._id), 1);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (let i = 0; i < this._subscriptions.length; i++) {\n\t\t\t\tlet sub = this._subscriptions[i];\n\n\t\t\t\tfor (let j = sub.clients.length - 1; j >= 0; j--) {\n\t\t\t\t\tlet client = sub.clients[j];\n\n\t\t\t\t\tif (!this._loggedInUsers.some(a => a.id_ws === client.id_socket)) {\n\t\t\t\t\t\tsub.clients.splice(j, 1);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}, 30000);\n\n\t\tFlags.findOne({type: 'Enable Debug'}).then(flag => {\n\t\t\tif (flag && flag.value) {\n\t\t\t\tthis._enableDebug = true;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthis._enableDebug = false;\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate addToQueue(mongoQueue: MongoQueueModel) {\n\t\t// let startDate = new Date();\n\n\t\tlet _mongoQueue = this._mongoQueue.filter(a => a.subscription.publication === mongoQueue.subscription.publication && JSON.stringify(a.subscription.subscriptionData) === JSON.stringify(mongoQueue.subscription.subscriptionData))[0];\n\t\t\n\t\tif (_mongoQueue) {\n\t\t\tif (_mongoQueue.running) {\n\t\t\t\t_mongoQueue.run_again = true;\n\n\t\t\t\t// let endDate = new Date();\n\t\t\t\t// this.currentPerfomanceMonitor.push({\n\t\t\t\t// \t_id: this.idPerformance++,\n\t\t\t\t// \tfunction: 'addToQueue',\n\t\t\t\t// \tpublication: mongoQueue.subscription.publication,\n\t\t\t\t// // \tsubscriptionData: mongoQueue.subscription.subscriptionData,\n\t\t\t\t// \tsubscriptionData: [],\n\t\t\t\t// \tdate_start: startDate,\n\t\t\t\t// \tdate_end: endDate,\n\t\t\t\t// \tduration: moment(endDate).diff(moment(startDate), 'milliseconds', false),\n\t\t\t\t// \tresult: 'Run Again'\n\t\t\t\t// });\n\t\t\t}\n\t\t\t// else {\n\t\t\t// \tlet endDate = new Date();\n\t\t\t// \tthis.currentPerfomanceMonitor.push({\n\t\t\t// \t\t_id: this.idPerformance++,\n\t\t\t// \t\tfunction: 'addToQueue',\n\t\t\t// \t\tpublication: mongoQueue.subscription.publication,\n\t\t\t// // \tsubscriptionData: mongoQueue.subscription.subscriptionData,\n\t\t\t// \t\tsubscriptionData: [],\n\t\t\t// \t\tdate_start: startDate,\n\t\t\t// \t\tdate_end: endDate,\n\t\t\t// \t\tduration: moment(endDate).diff(moment(startDate), 'milliseconds', false),\n\t\t\t// \t\tresult: 'Not Running Yet'\n\t\t\t// \t});\n\t\t\t// }\n\t\t}\n\t\telse {\n\t\t\tmongoQueue._id = this._mongoQueueId;\n\t\t\tthis._mongoQueueId += 1;\n\n\t\t\tthis._mongoQueue.splice(0, 0, mongoQueue);\n\t\t\t\n\t\t\t// let endDate = new Date();\n\t\t\t// this.currentPerfomanceMonitor.push({\n\t\t\t// \t_id: this.idPerformance++,\n\t\t\t// \tfunction: 'addToQueue',\n\t\t\t// \tpublication: mongoQueue.subscription.publication,\n\t\t\t// // \tsubscriptionData: mongoQueue.subscription.subscriptionData,\n\t\t\t// \tsubscriptionData: [],\n\t\t\t// \tdate_start: startDate,\n\t\t\t// \tdate_end: endDate,\n\t\t\t// \tduration: moment(endDate).diff(moment(startDate), 'milliseconds', false),\n\t\t\t// \tresult: 'Add to Queue'\n\t\t\t// });\n\t\t}\n\t}\n\n\tpublic invalidatePubsCache(collection, type) {\n\t\t// let startDate = new Date();\n\n\t\tResolveIOServer.getMongoManager().invalidateQueryCache(collection);\n\t\t\n\t\tlet collSubs = this._subscriptions.filter(a => a.collections.includes(collection));\n\n\t\tfor (let i = collSubs.length - 1; i >= 0; i--) {\n\t\t\tlet sub = collSubs[i];\n\t\t\t\n\t\t\tthis.addToQueue({\n\t\t\t\t_id: 0,\n\t\t\t\ttype: type,\n\t\t\t\tcollection: collection,\n\t\t\t\tsubscription: sub,\n\t\t\t\trunning: false,\n\t\t\t\trun_again: false\n\t\t\t});\n\t\t}\n\n\t\t// let endDate = new Date();\n\t\t// this.currentPerfomanceMonitor.push({\n\t\t// \t_id: this.idPerformance++,\n\t\t// \tfunction: 'invalidatePubsCache',\n\t\t// \tpublication: collection,\n\t\t// \tsubscriptionData: [],\n\t\t// \tdate_start: startDate,\n\t\t// \tdate_end: endDate,\n\t\t// \tduration: moment(endDate).diff(moment(startDate), 'milliseconds', false),\n\t\t// \tresult: 'Done'\n\t\t// });\n\t}\n\n\t// Add all files to publications private object\n\tpublic publications(method: SubscriptionModel) {\n\t\tthis._publications = Object.assign(this._publications, method);\n\t}\n\n\tpublic loggedInLatency(ws: WebSocket) {\n\t\tlet loggedInUser = this._loggedInUsers.filter(a => a.id_ws === ws['id_socket'])[0];\n\n\t\tif (loggedInUser) {\n\t\t\tloggedInUser.date = new Date();\n\n\t\t\tLoggedInUsers.updateOne({id_ws: ws['id_socket']}, {$set: {latency: ws['latency'], date: loggedInUser.date}}).then(res => {\n\t\t\t\tif (!res) {\n\t\t\t\t\tthis.unsubscribeAll(ws);\n\t\t\t\t\tif (this.getEnableDebug()) {\n\t\t\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Unsub WS', ws['user'], ws['id_socket'], 3);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}, () => {\n\t\t\t\tthis.unsubscribeAll(ws);\n\t\t\t\tif (this.getEnableDebug()) {\n\t\t\t\t\tconsole.log(new Date(), 'Sub Manager', 'Unsub WS', ws['user'], ws['id_socket'], 4);\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\t// Subscribe to publication\n\tpublic subscribe(messageRoute: string, messageDate: Date, ws: WebSocket, messageId: number, publication: string, subscriptionData: any[]) {\n\t\t// let startDate = new Date();\n\t\tthis._debugSubHits += 1;\n\n\t\tif (!this._debugSubCollections.some(a => a.publication === publication)) {\n\t\t\tthis._debugSubCollections.push({\n\t\t\t\tpublication: publication,\n\t\t\t\thits: 1\n\t\t\t});\n\t\t}\n\t\telse {\n\t\t\tthis._debugSubCollections.filter(a => a.publication === publication)[0].hits += 1;\n\t\t}\n\n\t\tlet pub = this._publications[publication];\n\n\t\tif (!pub) {\n\t\t\tconsole.error(new Date(), 'No Publication: ' + publication);\n\t\t\treturn;\n\t\t}\n\t\telse {\n\t\t\tif (subscriptionData.length > 1 || subscriptionData[0]) {\n\t\t\t\tif (!pub.check) {\n\t\t\t\t\tconsole.error(new Date(), 'No Check Function For Pub ' + publication);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\telse if (!pub.check._schema) {\n\t\t\t\t\tconsole.error(new Date(), 'No Check Schema For Pub ' + publication);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet valObj = {};\n\t\t\t\t\tlet valKeys = Object.keys(pub.check._schema);\n\n\t\t\t\t\tlet rootKeys = valKeys.filter(a => !a.includes('.'));\n\t\t\t\t\t\n\t\t\t\t\tfor (let i = 0; i < subscriptionData.length; i++) {\n\t\t\t\t\t\tvalObj[rootKeys[i]] = subscriptionData[i];\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tpub.check.validate(valObj);\n\t\t\t\t\t}\n\t\t\t\t\tcatch (errors) {\n\t\t\t\t\t\tif (errors) {\n\t\t\t\t\t\t\tconsole.error(new Date(), 'Error in Pub Check (' + publication + ')', errors);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (messageRoute !== 'Bypass') {\n\t\t\t\tlet urlData = messageRoute.split('/');\n\t\t\t\tlet urlModule = '';\n\t\t\t\tlet urlNext = urlData[0];\n\t\t\t\t\n\t\t\t\tif (urlData[0] === '') {\n\t\t\t\t\turlModule = '/';\n\t\t\t\t\turlNext = urlData[1];\n\t\t\t\t}\n\n\t\t\t\turlModule += urlNext;\n\n\t\t\t\tif (urlData.length > 1) {\n\t\t\t\t\turlModule += '/';\n\t\t\t\t}\n\n\t\t\t\tlet otherRouteSubs = this._subscriptions.filter(a => a.clients.some(b => b.id_socket === ws['id_socket'] && b.messageRoute !== 'Bypass' && b.messageRoute !== '/' && b.messageRoute !== messageRoute && !b.messageRoute.startsWith(urlModule)));\n\t\t\t\n\t\t\t\tif (otherRouteSubs.length) {\n\t\t\t\t\tthis._mainServer.getMethodManager().sendEmail('dev@resolveio.com', 'SERVER - Detected Undestroyed Subscription - ' + this.serverConfig['CLIENT_NAME'], 'USER: ' + ws['user'] + ' (Socket: ' + ws['id_socket'] + ') ' + ' is on route: ' + messageRoute + ' but has the following subscriptions on other routes:' + JSON.stringify(otherRouteSubs, null, 2));\n\n\t\t\t\t\totherRouteSubs.forEach(otherSub => {\n\t\t\t\t\t\totherSub.clients.filter(a => a.id_socket === ws['id_socket']).forEach(client => {\n\t\t\t\t\t\t\tthis.unsubscribe(client.messageRoute, new Date(), ws, client.messageId, otherSub.publication, otherSub.subscriptionData);\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet sub = this._subscriptions.filter(a => a.publication === publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscriptionData))[0];\n\n\t\t\t// If sub found (another user watching same data), add client to same sub\n\t\t\tif (sub) {\n\t\t\t\tif (!sub.clients.some(a => a.id_socket === ws['id_socket'] && a.messageId === messageId)) {\n\t\t\t\t\tsub.clients.push({\n\t\t\t\t\t\tid_user: ws['id_user'],\n\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\tid_socket: ws['id_socket'],\n\t\t\t\t\t\tmessageRoute: messageRoute\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\t// If sub not found, create new sub\n\t\t\telse {\n\t\t\t\tthis._subscriptions.push({\n\t\t\t\t\tpublication: publication,\n\t\t\t\t\tsubscriptionData: subscriptionData,\n\t\t\t\t\tcollections: this.getPublicationCollections(publication),\n\t\t\t\t\tclients: [{\n\t\t\t\t\t\tid_user: ws['id_user'],\n\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\tid_socket: ws['id_socket'],\n\t\t\t\t\t\tmessageRoute: messageRoute\n\t\t\t\t\t}],\n\t\t\t\t\tcacheId: 0\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (!sub) {\n\t\t\t\tsub = this._subscriptions.filter(a => a.publication === publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscriptionData))[0];\n\t\t\t}\n\n\t\t\tif (!sub.cacheId && !this._mongoQueue.some(a => a.subscription.publication === sub.publication && JSON.stringify(a.subscription.subscriptionData) === JSON.stringify(sub.subscriptionData))) {\n\t\t\t\tthis.addToQueue({\n\t\t\t\t\t_id: 0,\n\t\t\t\t\ttype: 'newSub',\n\t\t\t\t\tcollection: '',\n\t\t\t\t\tsubscription: sub,\n\t\t\t\t\trunning: false,\n\t\t\t\t\trun_again: false\n\t\t\t\t});\n\n\t\t\t\t// let endDate = new Date();\n\t\t\t\t// this.currentPerfomanceMonitor.push({\n\t\t\t\t// \t_id: this.idPerformance++,\n\t\t\t\t// \tfunction: 'subscribe',\n\t\t\t\t// \tpublication: publication,\n\t\t\t\t// // \tsubscriptionData: subscriptionData,\n\t\t\t\t// \tsubscriptionData: [],\n\t\t\t\t// \tdate_start: startDate,\n\t\t\t\t// \tdate_end: endDate,\n\t\t\t\t// \tduration: moment(endDate).diff(moment(startDate), 'milliseconds', false),\n\t\t\t\t// \tresult: 'Add to Queue'\n\t\t\t\t// });\n\t\t\t}\n\t\t\telse if (sub.cacheId) {\n\t\t\t\tthis.sendDataToOne(ws, messageId, sub, 'newSub', publication);\n\n\t\t\t\t// let endDate = new Date();\n\t\t\t\t// this.currentPerfomanceMonitor.push({\n\t\t\t\t// \t_id: this.idPerformance++,\n\t\t\t\t// \tfunction: 'subscribe',\n\t\t\t\t// \tpublication: publication,\n\t\t\t\t// // \tsubscriptionData: subscriptionData,\n\t\t\t\t// \tsubscriptionData: [],\n\t\t\t\t// \tdate_start: startDate,\n\t\t\t\t// \tdate_end: endDate,\n\t\t\t\t// \tduration: moment(endDate).diff(moment(startDate), 'milliseconds', false),\n\t\t\t\t// \tresult: 'Send Pub Data Once'\n\t\t\t\t// });\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic async createLoggedInUser(id_ws: string): Promise<LoggedInUserModel> {\n\t\treturn new Promise(async (resolve, reject) => {\n\t\t\tlet ws = this._mainServer.getWS(id_ws);\n\n\t\t\tif (ws) {\n\t\t\t\tlet user = {\n\t\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t\t__v: 0,\n\t\t\t\t\tdate: new Date(),\n\t\t\t\t\tid_user: ws['id_user'],\n\t\t\t\t\tuser: ws['user'],\n\t\t\t\t\tid_ws: ws['id_socket']\n\t\t\t\t};\n\t\t\t\t\n\t\t\t\tthis._loggedInUsers.push(user);\n\t\t\t\tLoggedInUsers.insertOne(user);\n\t\t\t\t\n\t\t\t\tresolve(user);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tresolve(null);\n\t\t\t}\n\t\t});\n\t}\n\n\t// Unsubscribe from publication \n\tpublic unsubscribe(messageRoute: string, messageDate: Date, ws: WebSocket, messageId: number, publication: string, subscriptionData: any[]) {\n\t\tthis._debugUnSubHits += 1;\n\t\t// let startDate = new Date();\n\t\t// console.log('Before');\n\t\t// console.dir(this._subscriptions.map(a => a.publication));\n\n\t\tif (!this._publications[publication]) {\n\t\t\tconsole.log('No Publication: ' + publication);\n\t\t\treturn;\n\t\t}\n\t\telse {\n\t\t\tlet sub = this._subscriptions.filter(a => a.publication === publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscriptionData))[0];\n\n\t\t\tif (sub) {\n\t\t\t\tfor (let i = sub.clients.length - 1; i >= 0; i--) {\n\t\t\t\t\tif (sub.clients[i].id_user === ws['id_user'] && sub.clients[i].messageId === messageId && sub.clients[i].id_socket === ws['id_socket']) {\n\t\t\t\t\t\tsub.clients.splice(i, 1);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// let endDate = new Date();\n\t\t// this.currentPerfomanceMonitor.push({\n\t\t// \t_id: this.idPerformance++,\n\t\t// \tfunction: 'unsubscribe',\n\t\t// \tpublication: publication,\n\t\t// // \tsubscriptionData: subscriptionData,\n\t\t// \tsubscriptionData: [],\n\t\t// \tdate_start: startDate,\n\t\t// \tdate_end: endDate,\n\t\t// \tduration: moment(endDate).diff(moment(startDate), 'milliseconds', false),\n\t\t// \tresult: 'Done'\n\t\t// });\n\t}\n\n\t// Unsubscribe from publication\n\tpublic async unsubscribeAll(ws: WebSocket) {\n\t\tthis._debugUnSubAllHits += 1;\n\t\t// console.log('Before');\n\t\t// console.dir(this._subscriptions.map(a => a.publication));\n\n\t\t// let startDate = new Date();\n\n\t\tif (ws) {\n\t\t\tlet loggedInUser = await LoggedInUsers.findOne({id_ws: ws['id_socket']});\n\n\t\t\tif (loggedInUser) {\t\n\t\t\t\tif (this._loggedInUsers.map(a => a._id).indexOf(loggedInUser._id) >= 0) {\n\t\t\t\t\tthis._loggedInUsers.splice(this._loggedInUsers.map(a => a._id).indexOf(loggedInUser._id), 1);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tLoggedInUsers.deleteOne({_id: loggedInUser._id});\n\t\t\t}\n\n\t\t\tlet userSubs = this._subscriptions.filter(a => a.clients.some(b => b.id_user === ws['id_user'] && b.id_socket === ws['id_socket']));\n\n\t\t\tfor (let i = userSubs.length - 1; i >= 0; i--) {\n\t\t\t\tlet sub = userSubs[i];\n\n\t\t\t\tfor (let j = sub.clients.length - 1; j >= 0; j--) {\n\t\t\t\t\tif (sub.clients[j].id_socket === ws['id_socket']) {\n\t\t\t\t\t\tsub.clients.splice(j, 1);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tws.close();\n\n\t\t\tprocess.nextTick(() => {\n\t\t\t\tif ([ws.OPEN, ws.CLOSING].includes(<any>ws.readyState)) {\n\t\t\t\t\t// Socket still hangs, hard close\n\t\t\t\t\tws.terminate();\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// let endDate = new Date();\n\t\t\t// this.currentPerfomanceMonitor.push({\n\t\t\t// \t_id: this.idPerformance++,\n\t\t\t// \tfunction: 'unsubscribeAll',\n\t\t\t// \tpublication: '',\n\t\t\t// \tsubscriptionData: [],\n\t\t\t// \tdate_start: startDate,\n\t\t\t// \tdate_end: endDate,\n\t\t\t// \tduration: moment(endDate).diff(moment(startDate), 'milliseconds', false),\n\t\t\t// \tresult: 'Done'\n\t\t\t// });\n\t\t}\n\n\t\t// console.log('After');\n\t\t// console.dir(this._subscriptions.map(a => a.publication));\n\t}\n\n\tpublic getActiveSubscriptions() {\n\t\treturn this._subscriptions;\n\t}\n\n\t// Get publication collection\n\tprivate getPublicationCollections(publication: string) {\n\t\treturn this._publications[publication].collections;\n\t}\n\n\t// Watch (tail) Mongo's operation log on the entire database (all insert/modify/delete will trigger this function)\n\tprivate async tailOpLog(resumeToken?: ResumeToken) {\n\t\tif (this._oplog$ && !this._oplog$.closed) {\n\t\t\tthis._oplog$.removeAllListeners();\n\t\t\tthis._oplog$.close();\n\t\t\tthis._oplog$ = null;\n\t\t}\n\t\n\t\tawait new Promise(resolve => setTimeout(resolve, 1000));\n\n\t\tif (!this._oplog$ || this._oplog$.closed) {\n\t\t\tthis._oplogRetryCount += 1;\n\n\t\t\tif (this._oplogRetryCount > 5) {\n\t\t\t\tconsole.error('****************** TAIL OPLOG ERROR, RETRYING A BUNCH OF TIMES, KILLING PROCESS **************************')\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\n\t\t\tlet lastResumeToken: ResumeToken;\n\n\t\t\tif (resumeToken) {\n\t\t\t\tlastResumeToken = resumeToken;\n\t\t\t\ttry {\n\t\t\t\t\tthis._oplog$ = ResolveIOServer.getMainDB().watch([], {resumeAfter: resumeToken});\n\t\t\t\t}\n\t\t\t\tcatch(errOp) {\n\t\t\t\t\tif (this._oplog$) {\n\t\t\t\t\t\tthis._oplog$.removeAllListeners();\n\t\t\t\t\t\tthis._oplog$.close();\n\t\t\t\t\t\tthis._oplog$ = null;\n\t\t\t\t\t}\n\t\t\t\t\tthis.tailOpLog(resumeToken);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthis._oplog$ = ResolveIOServer.getMainDB().watch();\n\t\t\t}\n\n\t\t\tconsole.log(new Date(), 'oplog started');\n\n\t\t\tthis._oplog$.on('change', (doc: ChangeStreamInsertDocument | ChangeStreamUpdateDocument | ChangeStreamReplaceDocument | ChangeStreamDeleteDocument) => {\n\t\t\t\t// let startDate = new Date();\n\n\t\t\t\tif (doc.ns) {\n\t\t\t\t\tlet collection = doc.ns.coll;\n\n\t\t\t\t\tif (!this._debugOplogCollections.some(a => a.collection === doc.ns.coll && a.type === doc.operationType)) {\n\t\t\t\t\t\tthis._debugOplogCollections.push({\n\t\t\t\t\t\t\tcollection: doc.ns.coll,\n\t\t\t\t\t\t\ttype: doc.operationType,\n\t\t\t\t\t\t\thits: 1\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tthis._debugOplogCollections.filter(a => a.collection === doc.ns.coll && a.type === doc.operationType)[0].hits += 1;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\t// console.log(new Date(), 'Op log doc', doc.operationType, collection);\n\n\t\t\t\t\tif (collection && !collection.endsWith('.versions') && !collection.startsWith('monitor-') && collection !== 'logs' && collection !== 'log-method-latencies' && collection !== 'log-subscriptions') {\n\t\t\t\t\t\tthis._debugOplogHits += 1;\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (doc.operationType === 'insert') {\n\t\t\t\t\t\t\tif (collection === 'support-tickets') {\n\t\t\t\t\t\t\t\tif (this.serverConfig['ROOT_URL'] === 'https://resolveio.com') {\n\t\t\t\t\t\t\t\t\tthis._mainServer.getMethodManager().callMethodInternal.call(this._mainServer.getMethodManager(), 'sendSupportTicketEmail', doc.documentKey['_id']);\n\t\t\t\t\t\t\t\t\tthis.invalidatePubsCache(collection, 'insert');\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (collection !== 'method-responses') {\n\t\t\t\t\t\t\t\tthis.invalidatePubsCache(collection, 'insert');\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// let endDate = new Date();\n\t\t\t\t\t\t\t// this.currentPerfomanceMonitor.push({\n\t\t\t\t\t\t\t// \t_id: this.idPerformance++,\n\t\t\t\t\t\t\t// \tfunction: 'oplog',\n\t\t\t\t\t\t\t// \tpublication: collection,\n\t\t\t\t\t\t\t// \tsubscriptionData: [],\n\t\t\t\t\t\t\t// \tdate_start: startDate,\n\t\t\t\t\t\t\t// \tdate_end: endDate,\n\t\t\t\t\t\t\t// \tduration: moment(endDate).diff(moment(startDate), 'milliseconds', false),\n\t\t\t\t\t\t\t// \tresult: 'Insert'\n\t\t\t\t\t\t\t// });\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (doc.operationType === 'update' || doc.operationType === 'replace') {\n\t\t\t\t\t\t\tif (collection !== 'method-responses') {\n\t\t\t\t\t\t\t\tthis.invalidatePubsCache(collection, 'update');\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// let endDate = new Date();\n\t\t\t\t\t\t\t// this.currentPerfomanceMonitor.push({\n\t\t\t\t\t\t\t// \t_id: this.idPerformance++,\n\t\t\t\t\t\t\t// \tfunction: 'oplog',\n\t\t\t\t\t\t\t// \tpublication: collection,\n\t\t\t\t\t\t\t// \tsubscriptionData: [],\n\t\t\t\t\t\t\t// \tdate_start: startDate,\n\t\t\t\t\t\t\t// \tdate_end: endDate,\n\t\t\t\t\t\t\t// \tduration: moment(endDate).diff(moment(startDate), 'milliseconds', false),\n\t\t\t\t\t\t\t// \tresult: 'Update'\n\t\t\t\t\t\t\t// });\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (doc.operationType === 'delete') {\n\t\t\t\t\t\t\tif (collection !== 'method-responses') {\n\t\t\t\t\t\t\t\tthis.invalidatePubsCache(collection, 'delete');\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// let endDate = new Date();\n\t\t\t\t\t\t\t// this.currentPerfomanceMonitor.push({\n\t\t\t\t\t\t\t// \t_id: this.idPerformance++,\n\t\t\t\t\t\t\t// \tfunction: 'oplog',\n\t\t\t\t\t\t\t// \tpublication: collection,\n\t\t\t\t\t\t\t// \tsubscriptionData: [],\n\t\t\t\t\t\t\t// \tdate_start: startDate,\n\t\t\t\t\t\t\t// \tdate_end: endDate,\n\t\t\t\t\t\t\t// \tduration: moment(endDate).diff(moment(startDate), 'milliseconds', false),\n\t\t\t\t\t\t\t// \tresult: 'Delete'\n\t\t\t\t\t\t\t// });\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (collection === 'flags') {\n\t\t\t\t\t\tFlags.findOne({type: 'Enable Debug'}).then(flag => {\n\t\t\t\t\t\t\tif (flag && flag.value) {\n\t\t\t\t\t\t\t\tthis._enableDebug = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tthis._enableDebug = false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tlastResumeToken = doc._id;\n\t\t\t\t}\n\t\t\t});\n\t\t\t\n\t\t\tthis._oplog$.on('error', error => {\n\t\t\t\tconsole.log(new Date(), 'oplog error', error);\n\t\t\t\tthis._oplog$.removeAllListeners();\n\t\t\t\tthis._oplog$.close();\n\t\t\t\tthis._oplog$ = null;\n\t\t\t\tthis.tailOpLog(lastResumeToken);\n\t\t\t});\n\n\t\t\tthis._oplog$.on('end', () => {\n\t\t\t\tconsole.log(new Date(), 'oplog end');\n\t\t\t\tthis._oplog$.removeAllListeners();\n\t\t\t\tthis._oplog$.close();\n\t\t\t\tthis._oplog$ = null;\n\t\t\t\tthis.tailOpLog(lastResumeToken);\n\t\t\t});\n\n\t\t\tthis._oplog$.on('close', () => {\n\t\t\t\tconsole.log(new Date(), 'oplog close');\n\t\t\t\tthis._oplog$.removeAllListeners();\n\t\t\t\tthis._oplog$ = null;\n\t\t\t\tthis.tailOpLog(lastResumeToken);\n\t\t\t});\n\t\t}\n\t}\n\n\t// Fetch pub once, send to all clients linked to this pub\n\tprivate sendDataToOne(ws: WebSocket, messageId: number, subscription: ActiveSubscriptionModel, type: string, collection: string) {\n\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t// let startDate = new Date();\n\n\t\t\tif (!this._publications[subscription.publication].user_specific) { // Same pub for all users\n\t\t\t\tif (subscription.cacheId) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tlet cacheData = JSON.parse(this._nodeCache.get(subscription.cacheId), dateReviver);\n\n\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\tdata: cacheData\n\t\t\t\t\t\t};\n\t\n\t\t\t\t\t\tthis.sendWS(ws, serverRes);\n\t\t\t\t\t}\n\t\t\t\t\tcatch(err) {\n\t\t\t\t\t\tthis._nodeCache.del(subscription.cacheId);\n\t\t\t\t\t\tsubscription.cacheId = 0;\n\n\t\t\t\t\t\tthis.addToQueue({\n\t\t\t\t\t\t\t_id: 0,\n\t\t\t\t\t\t\ttype: 'newSub',\n\t\t\t\t\t\t\tcollection: '',\n\t\t\t\t\t\t\tsubscription: subscription,\n\t\t\t\t\t\t\trunning: false,\n\t\t\t\t\t\t\trun_again: false\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\t// let endDate = new Date();\n\t\t\t\t\t// this.currentPerfomanceMonitor.push({\n\t\t\t\t\t// \t_id: this.idPerformance++,\n\t\t\t\t\t// \tfunction: 'sendDataToOne',\n\t\t\t\t\t// \tpublication: subscription.publication,\n\t\t\t\t\t// // \tsubscriptionData: subscription.subscriptionData,\n\t\t\t\t\t// \tsubscriptionData: [],\n\t\t\t\t\t// \tdate_start: startDate,\n\t\t\t\t\t// \tdate_end: endDate,\n\t\t\t\t\t// \tduration: moment(endDate).diff(moment(startDate), 'milliseconds', false),\n\t\t\t\t\t// \tresult: 'Send cache'\n\t\t\t\t\t// });\n\n\t\t\t\t\tresolve(true);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tthis._mainServer.getMethodManager().sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'Error Detected During sendDataToOne - No Cache! - ' + subscription.publication + '\\n\\nData \\n' + JSON.stringify(subscription.subscriptionData, null, 2));\n\n\t\t\t\t\tresolve(false);\n\t\t\t\t}\n\t\t\t}\n\t\t\telse { // Pub is different for each user (Look at users publication) [MUCH SLOWER, RE-RUNS FOR EACH USER]\n\t\t\t\tlet monitor = this._monitorManagerFunction.startMonitorFunction('User Specific Publication', subscription.publication, '', '', subscription.subscriptionData);\n\t\t\t\tthis._publications[subscription.publication].function.call(Object.assign({}, this, SubscriptionManager.prototype), ws['id_user'], ...subscription.subscriptionData)\n\t\t\t\t.then(res => {\n\t\t\t\t\tthis._monitorManagerFunction.finishMonitorFunction(monitor);\n\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\tdata: res\n\t\t\t\t\t};\n\n\t\t\t\t\t// console.log('Send Pub Data Once 2', new Date(), 'Success', subscription);\n\n\t\t\t\t\tthis.sendWS(ws, serverRes);\n\n\t\t\t\t\t// let endDate = new Date();\n\t\t\t\t\t// this.currentPerfomanceMonitor.push({\n\t\t\t\t\t// \t_id: this.idPerformance++,\n\t\t\t\t\t// \tfunction: 'sendDataToOne',\n\t\t\t\t\t// \tpublication: subscription.publication,\n\t\t\t\t\t// // \tsubscriptionData: subscription.subscriptionData,\n\t\t\t\t\t// \tsubscriptionData: [],\n\t\t\t\t\t// \tdate_start: startDate,\n\t\t\t\t\t// \tdate_end: endDate,\n\t\t\t\t\t// \tduration: moment(endDate).diff(moment(startDate), 'milliseconds', false),\n\t\t\t\t\t// \tresult: 'Send ws spec data'\n\t\t\t\t\t// });\n\n\t\t\t\t\tresolve(true);\n\n\t\t\t\t}, err => {\n\t\t\t\t\tthis._monitorManagerFunction.finishMonitorFunction(monitor);\n\t\t\t\t\t\n\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\tmessageId: messageId,\n\t\t\t\t\t\thasError: true,\n\t\t\t\t\t\tdata: err\n\t\t\t\t\t};\n\n\t\t\t\t\t// console.log('Send Pub Data Once 2', new Date(), 'Error', subscription);\n\n\t\t\t\t\tthis.sendWS(ws, serverRes);\n\n\t\t\t\t\tthis._mainServer.getMethodManager().sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'Error Detected During Subscription ' + subscription.publication + ' - (sendDataToOne - WS)\\n\\nData \\n' + JSON.stringify(subscription.subscriptionData, null, 2) + '\\n\\nErrors\\n' + JSON.stringify(err, null, 2));\n\n\t\t\t\t\treject(err);\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n\n\t// Fetch pub once, send to all clients linked to this pub\n\tprivate sendDataToAll(mongoQueue: MongoQueueModel) {\n\t\treturn new Promise(async (resolve, reject) => {\n\t\t\t// let startDate = new Date();\n\t\t\tif (!mongoQueue.subscription.clients.length) {\t\t\t\t\n\t\t\t\tif (mongoQueue.subscription.cacheId) {\n\t\t\t\t\tthis._nodeCache.del(mongoQueue.subscription.cacheId);\n\t\t\t\t}\n\n\t\t\t\tif (this._subscriptions.findIndex(a => a.publication === mongoQueue.subscription.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(mongoQueue.subscription.subscriptionData)) >= 0) {\n\t\t\t\t\tthis._subscriptions.splice(this._subscriptions.findIndex(a => a.publication === mongoQueue.subscription.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(mongoQueue.subscription.subscriptionData)), 1);\n\t\t\t\t}\n\n\t\t\t\tresolve(false);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (mongoQueue.subscription.publication !== 'superadminAPM' && mongoQueue.subscription.publication !== 'loggedInUsers') {\n\t\t\t\t\tthis._mainServer.getMethodManager().callMethodInternal.call(this._mainServer.getMethodManager(), 'insertSubscriptionLog', mongoQueue.type, mongoQueue.subscription.publication, mongoQueue.collection, JSON.stringify(mongoQueue.subscription.subscriptionData));\n\t\t\t\t}\n\n\t\t\t\tlet monitor = this._monitorManagerFunction.startMonitorFunction('Publication', mongoQueue.subscription.publication, '', '', mongoQueue.subscription.subscriptionData);\n\t\t\t\tthis._publications[mongoQueue.subscription.publication].function.call(Object.assign({}, this, SubscriptionManager.prototype), ...mongoQueue.subscription.subscriptionData)\n\t\t\t\t.then(res => {\n\t\t\t\t\tthis._monitorManagerFunction.finishMonitorFunction(monitor);\n\t\t\t\t\tif (!mongoQueue.subscription.clients.length) {\n\t\t\t\t\t\tlet nodeCacheSize = this._nodeCache.getStats().vsize;\n\t\t\t\t\t\t\n\t\t\t\t\t\tif (nodeCacheSize > this._heapLimit) {\n\t\t\t\t\t\t\tlet deleteCount = 0;\n\n\t\t\t\t\t\t\tconst subArr = this._subscriptions.filter(a => a.cacheId && !a.clients.length);\n\n\t\t\t\t\t\t\tfor (let zz = 0; zz < subArr.length; zz++) {\n\t\t\t\t\t\t\t\tthis._debugRemoveCacheHits += 1;\n\n\t\t\t\t\t\t\t\tthis._nodeCache.del(subArr[zz].cacheId);\n\t\t\t\t\t\t\t\tsubArr[zz].cacheId = 0;\n\n\t\t\t\t\t\t\t\tdeleteCount += 1;\n\n\t\t\t\t\t\t\t\tnodeCacheSize = this._nodeCache.getStats().vsize;\n\n\t\t\t\t\t\t\t\tif (nodeCacheSize < this._heapLimit * 0.75) {\n\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tconsole.log('Sub Cache: ' + 'Too Big - ' + mongoQueue.subscription.publication + ' - Deleted: ' + deleteCount + ' - ' + nodeCacheSize);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (mongoQueue.subscription.cacheId) {\n\t\t\t\t\t\t\tthis._nodeCache.del(mongoQueue.subscription.cacheId);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet cacheId = this._cacheId;\n\t\t\t\t\t\tthis._cacheId += 1;\n\n\t\t\t\t\t\tthis._nodeCache.set(cacheId, JSON.stringify(res));\n\t\t\t\t\t\tmongoQueue.subscription.cacheId = cacheId;\n\n\t\t\t\t\t\t// let endDate = new Date();\n\t\t\t\t\t\t// this.currentPerfomanceMonitor.push({\n\t\t\t\t\t\t// \t_id: this.idPerformance++,\n\t\t\t\t\t\t// \tfunction: 'sendPubData',\n\t\t\t\t\t\t// \tpublication: subscription.publication,\n\t\t\t\t\t\t// // \tsubscriptionData: subscription.subscriptionData,\n\t\t\t\t\t\t// \tsubscriptionData: [],\n\t\t\t\t\t\t// \tdate_start: startDate,\n\t\t\t\t\t\t// \tdate_end: endDate,\n\t\t\t\t\t\t// \tduration: moment(endDate).diff(moment(startDate), 'milliseconds', false),\n\t\t\t\t\t\t// \tresult: 'No clients'\n\t\t\t\t\t\t// });\n\n\t\t\t\t\t\tresolve(false);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tif (!mongoQueue.subscription.cacheId || this._nodeCache.get(mongoQueue.subscription.cacheId) !== JSON.stringify(res)) {\n\t\t\t\t\t\t\tmongoQueue.subscription.clients.forEach(client => {\n\t\t\t\t\t\t\t\tlet ws = this._mainServer.getWS(client.id_socket);\n\n\t\t\t\t\t\t\t\tif (ws) {\n\t\t\t\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\t\t\t\tmessageId: client.messageId,\n\t\t\t\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\t\t\t\tdata: res\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\n\t\t\t\t\t\t\t\t\tthis.sendWS(ws, serverRes);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\n\t\t\t\t\t\t\tlet nodeCacheSize = this._nodeCache.getStats().vsize;\n\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (nodeCacheSize > this._heapLimit) {\n\t\t\t\t\t\t\t\tlet deleteCount = 0;\n\n\t\t\t\t\t\t\t\tconst subArr = this._subscriptions.filter(a => a.cacheId && !a.clients.length);\n\t\n\t\t\t\t\t\t\t\tfor (let zz = 0; zz < subArr.length; zz++) {\n\t\t\t\t\t\t\t\t\tthis._nodeCache.del(subArr[zz].cacheId);\n\t\t\t\t\t\t\t\t\tsubArr[zz].cacheId = 0;\n\t\n\t\t\t\t\t\t\t\t\tdeleteCount += 1;\n\n\t\t\t\t\t\t\t\t\tnodeCacheSize = this._nodeCache.getStats().vsize;\n\t\n\t\t\t\t\t\t\t\t\tif (nodeCacheSize < this._heapLimit * 0.75) {\n\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tconsole.log('Sub Cache: ' + 'Too Big - ' + mongoQueue.subscription.publication + ' - Deleted: ' + deleteCount + ' - ' + nodeCacheSize);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (mongoQueue.subscription.cacheId) {\n\t\t\t\t\t\t\t\tthis._nodeCache.del(mongoQueue.subscription.cacheId);\n\t\t\t\t\t\t\t}\n\t\n\t\t\t\t\t\t\tlet cacheId = this._cacheId;\n\t\t\t\t\t\t\tthis._cacheId += 1;\n\n\t\t\t\t\t\t\tthis._nodeCache.set(cacheId, JSON.stringify(res));\n\t\t\t\t\t\t\tmongoQueue.subscription.cacheId = cacheId;\n\n\t\t\t\t\t\t\t// let endDate = new Date();\n\t\t\t\t\t\t\t// this.currentPerfomanceMonitor.push({\n\t\t\t\t\t\t\t// \t_id: this.idPerformance++,\n\t\t\t\t\t\t\t// \tfunction: 'sendPubData',\n\t\t\t\t\t\t\t// \tpublication: subscription.publication,\n\t\t\t\t\t\t\t// // \tsubscriptionData: subscription.subscriptionData,\n\t\t\t\t\t\t\t// \tsubscriptionData: [],\n\t\t\t\t\t\t\t// \tdate_start: startDate,\n\t\t\t\t\t\t\t// \tdate_end: endDate,\n\t\t\t\t\t\t\t// \tduration: moment(endDate).diff(moment(startDate), 'milliseconds', false),\n\t\t\t\t\t\t\t// \tresult: 'Same data'\n\t\t\t\t\t\t\t// });\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tresolve(true);\n\t\t\t\t\t}\n\t\t\t\t}, err => {\n\t\t\t\t\tthis._monitorManagerFunction.finishMonitorFunction(monitor);\n\t\t\t\t\tthis._mainServer.getMethodManager().sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'Error Detected During Subscription ' + mongoQueue.subscription.publication + ' - (sendPubData)\\n\\nData \\n' + JSON.stringify(mongoQueue.subscription.subscriptionData, null, 2) + '\\n\\nErrors\\n' + JSON.stringify(err, null, 2));\n\n\t\t\t\t\tmongoQueue.subscription.clients.forEach(client => {\n\t\t\t\t\t\tlet ws = this._mainServer.getWS(client.id_socket);\n\n\t\t\t\t\t\tif (ws) {\n\t\t\t\t\t\t\tif (ws['id_socket'] === client.id_socket) {\n\t\t\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\t\t\tmessageId: client.messageId,\n\t\t\t\t\t\t\t\t\thasError: true,\n\t\t\t\t\t\t\t\t\tdata: err\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tthis.sendWS(ws, serverRes);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\treject(err);\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate sendWS(ws: WebSocket, data: ServerResponseModel) {\n\t\tthis._sendQueue.splice(0, 0, {\n\t\t\tid_ws: ws['id_socket'],\n\t\t\tdata: data\n\t\t});\n\t}\n\n\tpublic getEnableDebug() {\n\t\treturn this._enableDebug;\n\t}\n}\n"]}
|
|
@@ -1,103 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var worker_threads_1 = require("worker_threads");
|
|
4
|
-
var totalPerfomanceMonitor = [];
|
|
5
|
-
worker_threads_1.parentPort.on('message', function (msg) {
|
|
6
|
-
console.log('Recv Msg');
|
|
7
|
-
processMsg(msg);
|
|
8
|
-
});
|
|
9
|
-
function processMsg(msg) {
|
|
10
|
-
if (totalPerfomanceMonitor.length) {
|
|
11
|
-
totalPerfomanceMonitor.forEach(function (total) {
|
|
12
|
-
var currents = msg.filter(function (a) { return a.function === total.function && a.publication === total.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(total.subscriptionData); });
|
|
13
|
-
if (currents.length) {
|
|
14
|
-
total.data = total.data.concat(currents);
|
|
15
|
-
total.duration_total_max = Math.max.apply(Math, total.data.map(function (a) { return a.duration; }));
|
|
16
|
-
total.duration_total_min = Math.min.apply(Math, total.data.map(function (a) { return a.duration; }));
|
|
17
|
-
total.duration_total_avg = Math.round(total.data.map(function (a) { return a.duration; }).reduce(function (a, b) { return a + b; }, 0) / total.data.length);
|
|
18
|
-
total.hits_total = total.data.length;
|
|
19
|
-
total.duration_current_max = Math.max.apply(Math, currents.map(function (a) { return a.duration; }));
|
|
20
|
-
total.duration_current_min = Math.min.apply(Math, currents.map(function (a) { return a.duration; }));
|
|
21
|
-
total.duration_current_avg = Math.round(currents.map(function (a) { return a.duration; }).reduce(function (a, b) { return a + b; }, 0) / currents.length);
|
|
22
|
-
total.hits_current = currents.length;
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
total.duration_current_max = 0;
|
|
26
|
-
total.duration_current_min = 0;
|
|
27
|
-
total.duration_current_avg = 0;
|
|
28
|
-
total.hits_current = 0;
|
|
29
|
-
}
|
|
30
|
-
currents.forEach(function (current) {
|
|
31
|
-
msg.splice(msg.findIndex(function (a) { return a._id === current._id; }), 1);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
msg.forEach(function (entry) {
|
|
35
|
-
var total = totalPerfomanceMonitor.filter(function (a) { return a.function === entry.function && a.publication === entry.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(entry.subscriptionData); })[0];
|
|
36
|
-
if (total) {
|
|
37
|
-
total.data.push(entry);
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
totalPerfomanceMonitor.push({
|
|
41
|
-
function: entry.function,
|
|
42
|
-
publication: entry.publication,
|
|
43
|
-
subscriptionData: entry.subscriptionData,
|
|
44
|
-
data: [entry],
|
|
45
|
-
duration_total_max: 0,
|
|
46
|
-
duration_total_min: 0,
|
|
47
|
-
duration_total_avg: 0,
|
|
48
|
-
hits_total: 0,
|
|
49
|
-
duration_current_max: 0,
|
|
50
|
-
duration_current_min: 0,
|
|
51
|
-
duration_current_avg: 0,
|
|
52
|
-
hits_current: 0
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
msg.forEach(function (entry) {
|
|
59
|
-
var total = totalPerfomanceMonitor.filter(function (a) { return a.function === entry.function && a.publication === entry.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(entry.subscriptionData); })[0];
|
|
60
|
-
if (total) {
|
|
61
|
-
total.data.push(entry);
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
totalPerfomanceMonitor.push({
|
|
65
|
-
function: entry.function,
|
|
66
|
-
publication: entry.publication,
|
|
67
|
-
subscriptionData: entry.subscriptionData,
|
|
68
|
-
data: [entry],
|
|
69
|
-
duration_total_max: 0,
|
|
70
|
-
duration_total_min: 0,
|
|
71
|
-
duration_total_avg: 0,
|
|
72
|
-
hits_total: 0,
|
|
73
|
-
duration_current_max: 0,
|
|
74
|
-
duration_current_min: 0,
|
|
75
|
-
duration_current_avg: 0,
|
|
76
|
-
hits_current: 0
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
totalPerfomanceMonitor.forEach(function (total) {
|
|
81
|
-
total.duration_total_max = Math.max.apply(Math, total.data.map(function (a) { return a.duration; }));
|
|
82
|
-
total.duration_total_min = Math.min.apply(Math, total.data.map(function (a) { return a.duration; }));
|
|
83
|
-
total.duration_total_avg = Math.round(total.data.map(function (a) { return a.duration; }).reduce(function (a, b) { return a + b; }, 0) / total.data.length);
|
|
84
|
-
total.hits_total = total.data.length;
|
|
85
|
-
total.duration_current_max = Math.max.apply(Math, total.data.map(function (a) { return a.duration; }));
|
|
86
|
-
total.duration_current_min = Math.min.apply(Math, total.data.map(function (a) { return a.duration; }));
|
|
87
|
-
total.duration_current_avg = Math.round(total.data.map(function (a) { return a.duration; }).reduce(function (a, b) { return a + b; }, 0) / total.data.length);
|
|
88
|
-
total.hits_current = total.data.length;
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
console.log('---------------------------------------------------------------------------------');
|
|
92
|
-
console.log('---------------------------------------------------------------------------------');
|
|
93
|
-
console.log('Performance', new Date());
|
|
94
|
-
console.log('---------------------------------------------------------------------------------');
|
|
95
|
-
console.log('Function, Publication, Hits Total, Dur Tot Max, Dur Tot Min, Dur Tot Avg, Hits Current, Dur Curr Max, Dur Curr Min, Dur Curr Avg, Sub Data');
|
|
96
|
-
totalPerfomanceMonitor.sort(function (a, b) { return b.hits_total - a.hits_total; }).forEach(function (total) {
|
|
97
|
-
console.log(total.function + ',' + total.publication + ',' + total.hits_total + ',' + total.duration_total_max + ',' + total.duration_total_min + ',' + total.duration_total_avg + ',' + total.hits_current + ',' + total.duration_current_max + ',' + total.duration_current_min + ',' + total.duration_current_avg + ',' + JSON.stringify(total.subscriptionData));
|
|
98
|
-
});
|
|
99
|
-
console.log('---------------------------------------------------------------------------------');
|
|
100
|
-
console.log('---------------------------------------------------------------------------------');
|
|
101
|
-
}
|
|
102
|
-
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var worker_threads_1=require("worker_threads"),totalPerfomanceMonitor=[];function processMsg(a){totalPerfomanceMonitor.length?(totalPerfomanceMonitor.forEach(function(n){var t=a.filter(function(t){return t.function===n.function&&t.publication===n.publication&&JSON.stringify(t.subscriptionData)===JSON.stringify(n.subscriptionData)});t.length?(n.data=n.data.concat(t),n.duration_total_max=Math.max.apply(Math,n.data.map(function(t){return t.duration})),n.duration_total_min=Math.min.apply(Math,n.data.map(function(t){return t.duration})),n.duration_total_avg=Math.round(n.data.map(function(t){return t.duration}).reduce(function(t,n){return t+n},0)/n.data.length),n.hits_total=n.data.length,n.duration_current_max=Math.max.apply(Math,t.map(function(t){return t.duration})),n.duration_current_min=Math.min.apply(Math,t.map(function(t){return t.duration})),n.duration_current_avg=Math.round(t.map(function(t){return t.duration}).reduce(function(t,n){return t+n},0)/t.length),n.hits_current=t.length):(n.duration_current_max=0,n.duration_current_min=0,n.duration_current_avg=0,n.hits_current=0),t.forEach(function(n){a.splice(a.findIndex(function(t){return t._id===n._id}),1)})}),a.forEach(function(n){var t=totalPerfomanceMonitor.filter(function(t){return t.function===n.function&&t.publication===n.publication&&JSON.stringify(t.subscriptionData)===JSON.stringify(n.subscriptionData)})[0];t?t.data.push(n):totalPerfomanceMonitor.push({function:n.function,publication:n.publication,subscriptionData:n.subscriptionData,data:[n],duration_total_max:0,duration_total_min:0,duration_total_avg:0,hits_total:0,duration_current_max:0,duration_current_min:0,duration_current_avg:0,hits_current:0})})):(a.forEach(function(n){var t=totalPerfomanceMonitor.filter(function(t){return t.function===n.function&&t.publication===n.publication&&JSON.stringify(t.subscriptionData)===JSON.stringify(n.subscriptionData)})[0];t?t.data.push(n):totalPerfomanceMonitor.push({function:n.function,publication:n.publication,subscriptionData:n.subscriptionData,data:[n],duration_total_max:0,duration_total_min:0,duration_total_avg:0,hits_total:0,duration_current_max:0,duration_current_min:0,duration_current_avg:0,hits_current:0})}),totalPerfomanceMonitor.forEach(function(t){t.duration_total_max=Math.max.apply(Math,t.data.map(function(t){return t.duration})),t.duration_total_min=Math.min.apply(Math,t.data.map(function(t){return t.duration})),t.duration_total_avg=Math.round(t.data.map(function(t){return t.duration}).reduce(function(t,n){return t+n},0)/t.data.length),t.hits_total=t.data.length,t.duration_current_max=Math.max.apply(Math,t.data.map(function(t){return t.duration})),t.duration_current_min=Math.min.apply(Math,t.data.map(function(t){return t.duration})),t.duration_current_avg=Math.round(t.data.map(function(t){return t.duration}).reduce(function(t,n){return t+n},0)/t.data.length),t.hits_current=t.data.length})),console.log("---------------------------------------------------------------------------------"),console.log("---------------------------------------------------------------------------------"),console.log("Performance",new Date),console.log("---------------------------------------------------------------------------------"),console.log("Function, Publication, Hits Total, Dur Tot Max, Dur Tot Min, Dur Tot Avg, Hits Current, Dur Curr Max, Dur Curr Min, Dur Curr Avg, Sub Data"),totalPerfomanceMonitor.sort(function(t,n){return n.hits_total-t.hits_total}).forEach(function(t){console.log(t.function+","+t.publication+","+t.hits_total+","+t.duration_total_max+","+t.duration_total_min+","+t.duration_total_avg+","+t.hits_current+","+t.duration_current_max+","+t.duration_current_min+","+t.duration_current_avg+","+JSON.stringify(t.subscriptionData))}),console.log("---------------------------------------------------------------------------------"),console.log("---------------------------------------------------------------------------------")}worker_threads_1.parentPort.on("message",function(t){console.log("Recv Msg"),processMsg(t)});
|
|
103
2
|
//# sourceMappingURL=subscription.performance.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/managers/subscription.performance.ts"],"names":[],"mappings":";;AAAA,iDAA4C;AA4B5C,IAAI,sBAAsB,GAA8B,EAAE,CAAC;AAE3D,2BAAU,CAAC,EAAE,CAAC,SAAS,EAAE,UAAA,GAAG;IACxB,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC3B,UAAU,CAAC,GAAG,CAAC,CAAC;AACjB,CAAC,CAAC,CAAC;AAEH,SAAS,UAAU,CAAC,GAAgC;IACnD,IAAI,sBAAsB,CAAC,MAAM,EAAE;QAC5B,sBAAsB,CAAC,OAAO,CAAC,UAAA,KAAK;YAChC,IAAI,QAAQ,GAAG,GAA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,CAAC,WAAW,GAAG,GAAG,GAAG,KAAK,CAAC,UAAU,GAAG,GAAG,GAAG,KAAK,CAAC,kBAAkB,GAAG,GAAG,GAAG,KAAK,CAAC,kBAAkB,GAAG,GAAG,GAAG,KAAK,CAAC,kBAAkB,GAAG,GAAG,GAAG,KAAK,CAAC,YAAY,GAAG,GAAG,GAAG,KAAK,CAAC,oBAAoB,GAAG,GAAG,GAAG,KAAK,CAAC,oBAAoB,GAAG,GAAG,GAAG,KAAK,CAAC,oBAAoB,GAAG,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACzW,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,CAAC,mFAAmF,CAAC,CAAC;IACjG,OAAO,CAAC,GAAG,CAAC,mFAAmF,CAAC,CAAC;AACrG,CAAC","file":"subscription.performance.js","sourcesContent":["import { parentPort } from 'worker_threads';\n\ninterface CurrentPerformanceMonitor {\n\t_id: number;\n\tfunction: string;\n\tpublication: string;\n\tsubscriptionData: any[];\n\tdate_start: Date;\n\tdate_end: Date;\n\tduration: number;\n\tresult: string;\n}\n\ninterface TotalPerformanceMonitor {\n\tfunction: string;\n\tpublication: string;\n\tsubscriptionData: any[];\n\tdata: CurrentPerformanceMonitor[];\n\tduration_total_max: number;\n\tduration_total_min: number;\n\tduration_total_avg: number;\n\thits_total: number;\n\tduration_current_max: number;\n\tduration_current_min: number;\n\tduration_current_avg: number;\n\thits_current: number;\n}\n\nlet totalPerfomanceMonitor: TotalPerformanceMonitor[] = [];\n\nparentPort.on('message', msg => {\n console.log('Recv Msg');\n\tprocessMsg(msg);\n});\n\nfunction processMsg(msg: CurrentPerformanceMonitor[]) {\n\tif (totalPerfomanceMonitor.length) {\n totalPerfomanceMonitor.forEach(total => {\n let currents = msg.filter(a => a.function === total.function && a.publication === total.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(total.subscriptionData));\n\n if (currents.length) {\n total.data = total.data.concat(currents);\n total.duration_total_max = Math.max(...total.data.map(a => a.duration));\n total.duration_total_min = Math.min(...total.data.map(a => a.duration));\n total.duration_total_avg = Math.round(total.data.map(a => a.duration).reduce((a, b) => a + b, 0) / total.data.length);\n total.hits_total = total.data.length;\n total.duration_current_max = Math.max(...currents.map(a => a.duration));\n total.duration_current_min = Math.min(...currents.map(a => a.duration));\n total.duration_current_avg = Math.round(currents.map(a => a.duration).reduce((a, b) => a + b, 0) / currents.length);\n total.hits_current = currents.length;\n }\n else {\n total.duration_current_max = 0;\n total.duration_current_min = 0;\n total.duration_current_avg = 0;\n total.hits_current = 0;\n }\n\n currents.forEach(current => {\n msg.splice(msg.findIndex(a => a._id === current._id), 1);\n });\n });\n\n msg.forEach(entry => {\n let total = totalPerfomanceMonitor.filter(a => a.function === entry.function && a.publication === entry.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(entry.subscriptionData))[0];\n if (total) {\n total.data.push(entry);\n }\n else {\n totalPerfomanceMonitor.push({\n function: entry.function,\n publication: entry.publication,\n subscriptionData: entry.subscriptionData,\n data: [entry],\n duration_total_max: 0,\n duration_total_min: 0,\n duration_total_avg: 0,\n hits_total: 0,\n duration_current_max: 0,\n duration_current_min: 0,\n duration_current_avg: 0,\n hits_current: 0\n });\n }\n });\n }\n else {\n msg.forEach(entry => {\n let total = totalPerfomanceMonitor.filter(a => a.function === entry.function && a.publication === entry.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(entry.subscriptionData))[0];\n if (total) {\n total.data.push(entry);\n }\n else {\n totalPerfomanceMonitor.push({\n function: entry.function,\n publication: entry.publication,\n subscriptionData: entry.subscriptionData,\n data: [entry],\n duration_total_max: 0,\n duration_total_min: 0,\n duration_total_avg: 0,\n hits_total: 0,\n duration_current_max: 0,\n duration_current_min: 0,\n duration_current_avg: 0,\n hits_current: 0\n });\n }\n });\n\n totalPerfomanceMonitor.forEach(total => {\n total.duration_total_max = Math.max(...total.data.map(a => a.duration));\n total.duration_total_min = Math.min(...total.data.map(a => a.duration));\n total.duration_total_avg = Math.round(total.data.map(a => a.duration).reduce((a, b) => a + b, 0) / total.data.length);\n total.hits_total = total.data.length;\n total.duration_current_max = Math.max(...total.data.map(a => a.duration));\n total.duration_current_min = Math.min(...total.data.map(a => a.duration));\n total.duration_current_avg = Math.round(total.data.map(a => a.duration).reduce((a, b) => a + b, 0) / total.data.length);\n total.hits_current = total.data.length;\n });\n }\n\n console.log('---------------------------------------------------------------------------------');\n console.log('---------------------------------------------------------------------------------');\n\n console.log('Performance', new Date());\n console.log('---------------------------------------------------------------------------------');\n\n\n console.log('Function, Publication, Hits Total, Dur Tot Max, Dur Tot Min, Dur Tot Avg, Hits Current, Dur Curr Max, Dur Curr Min, Dur Curr Avg, Sub Data');\n\n totalPerfomanceMonitor.sort((a, b) => b.hits_total - a.hits_total).forEach(total => {\n console.log(total.function + ',' + total.publication + ',' + total.hits_total + ',' + total.duration_total_max + ',' + total.duration_total_min + ',' + total.duration_total_avg + ',' + total.hits_current + ',' + total.duration_current_max + ',' + total.duration_current_min + ',' + total.duration_current_avg + ',' + JSON.stringify(total.subscriptionData));\n });\n\n console.log('---------------------------------------------------------------------------------');\n console.log('---------------------------------------------------------------------------------');\n}"]}
|
|
1
|
+
{"version":3,"sources":["../../src/managers/subscription.performance.ts"],"names":["worker_threads_1","require","totalPerfomanceMonitor","processMsg","msg","length","forEach","total","currents","filter","a","function","publication","JSON","stringify","subscriptionData","data","concat","duration_total_max","Math","max","apply","map","duration","duration_total_min","min","duration_total_avg","round","reduce","b","hits_total","duration_current_max","duration_current_min","duration_current_avg","hits_current","current","splice","findIndex","_id","entry","push","console","log","Date","sort","parentPort","on"],"mappings":"oEAAA,IAAAA,iBAAAC,QAAA,gBAAA,EA4BIC,uBAAoD,GAOxD,SAASC,WAAWC,GACfF,uBAAuBG,QACpBH,uBAAuBI,QAAQ,SAAAC,GAC3B,IAAIC,EAAWJ,EAAIK,OAAO,SAAAC,GAAK,OAAAA,EAAEC,WAAaJ,EAAMI,UA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GAAM,OAAAA,EAAEC,WAAapB,EAAEoB,UAAjB,CAA2B,EAAExB,QAAQ,SAAAC,GACvEkC,QAAQC,IAAInC,EAAMI,SAAW,IAAMJ,EAAMK,YAAc,IAAML,EAAMuB,WAAa,IAAMvB,EAAMW,mBAAqB,IAAMX,EAAMiB,mBAAqB,IAAMjB,EAAMmB,mBAAqB,IAAMnB,EAAM2B,aAAe,IAAM3B,EAAMwB,qBAAuB,IAAMxB,EAAMyB,qBAAuB,IAAMzB,EAAM0B,qBAAuB,IAAMpB,KAAKC,UAAUP,EAAMQ,gBAAgB,CAAC,CACvW,CAAC,EAED0B,QAAQC,IAAI,mFAAmF,EAC/FD,QAAQC,IAAI,mFAAmF,CACnG,CA3GA1C,iBAAA6C,WAAWC,GAAG,UAAW,SAAA1C,GACrBqC,QAAQC,IAAI,UAAU,EACzBvC,WAAWC,CAAG,CACf,CAAC","file":"subscription.performance.js","sourcesContent":["import { parentPort } from 'worker_threads';\n\ninterface CurrentPerformanceMonitor {\n\t_id: number;\n\tfunction: string;\n\tpublication: string;\n\tsubscriptionData: any[];\n\tdate_start: Date;\n\tdate_end: Date;\n\tduration: number;\n\tresult: string;\n}\n\ninterface TotalPerformanceMonitor {\n\tfunction: string;\n\tpublication: string;\n\tsubscriptionData: any[];\n\tdata: CurrentPerformanceMonitor[];\n\tduration_total_max: number;\n\tduration_total_min: number;\n\tduration_total_avg: number;\n\thits_total: number;\n\tduration_current_max: number;\n\tduration_current_min: number;\n\tduration_current_avg: number;\n\thits_current: number;\n}\n\nlet totalPerfomanceMonitor: TotalPerformanceMonitor[] = [];\n\nparentPort.on('message', msg => {\n console.log('Recv Msg');\n\tprocessMsg(msg);\n});\n\nfunction processMsg(msg: CurrentPerformanceMonitor[]) {\n\tif (totalPerfomanceMonitor.length) {\n totalPerfomanceMonitor.forEach(total => {\n let currents = msg.filter(a => a.function === total.function && a.publication === total.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(total.subscriptionData));\n\n if (currents.length) {\n total.data = total.data.concat(currents);\n total.duration_total_max = Math.max(...total.data.map(a => a.duration));\n total.duration_total_min = Math.min(...total.data.map(a => a.duration));\n total.duration_total_avg = Math.round(total.data.map(a => a.duration).reduce((a, b) => a + b, 0) / total.data.length);\n total.hits_total = total.data.length;\n total.duration_current_max = Math.max(...currents.map(a => a.duration));\n total.duration_current_min = Math.min(...currents.map(a => a.duration));\n total.duration_current_avg = Math.round(currents.map(a => a.duration).reduce((a, b) => a + b, 0) / currents.length);\n total.hits_current = currents.length;\n }\n else {\n total.duration_current_max = 0;\n total.duration_current_min = 0;\n total.duration_current_avg = 0;\n total.hits_current = 0;\n }\n\n currents.forEach(current => {\n msg.splice(msg.findIndex(a => a._id === current._id), 1);\n });\n });\n\n msg.forEach(entry => {\n let total = totalPerfomanceMonitor.filter(a => a.function === entry.function && a.publication === entry.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(entry.subscriptionData))[0];\n if (total) {\n total.data.push(entry);\n }\n else {\n totalPerfomanceMonitor.push({\n function: entry.function,\n publication: entry.publication,\n subscriptionData: entry.subscriptionData,\n data: [entry],\n duration_total_max: 0,\n duration_total_min: 0,\n duration_total_avg: 0,\n hits_total: 0,\n duration_current_max: 0,\n duration_current_min: 0,\n duration_current_avg: 0,\n hits_current: 0\n });\n }\n });\n }\n else {\n msg.forEach(entry => {\n let total = totalPerfomanceMonitor.filter(a => a.function === entry.function && a.publication === entry.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(entry.subscriptionData))[0];\n if (total) {\n total.data.push(entry);\n }\n else {\n totalPerfomanceMonitor.push({\n function: entry.function,\n publication: entry.publication,\n subscriptionData: entry.subscriptionData,\n data: [entry],\n duration_total_max: 0,\n duration_total_min: 0,\n duration_total_avg: 0,\n hits_total: 0,\n duration_current_max: 0,\n duration_current_min: 0,\n duration_current_avg: 0,\n hits_current: 0\n });\n }\n });\n\n totalPerfomanceMonitor.forEach(total => {\n total.duration_total_max = Math.max(...total.data.map(a => a.duration));\n total.duration_total_min = Math.min(...total.data.map(a => a.duration));\n total.duration_total_avg = Math.round(total.data.map(a => a.duration).reduce((a, b) => a + b, 0) / total.data.length);\n total.hits_total = total.data.length;\n total.duration_current_max = Math.max(...total.data.map(a => a.duration));\n total.duration_current_min = Math.min(...total.data.map(a => a.duration));\n total.duration_current_avg = Math.round(total.data.map(a => a.duration).reduce((a, b) => a + b, 0) / total.data.length);\n total.hits_current = total.data.length;\n });\n }\n\n console.log('---------------------------------------------------------------------------------');\n console.log('---------------------------------------------------------------------------------');\n\n console.log('Performance', new Date());\n console.log('---------------------------------------------------------------------------------');\n\n\n console.log('Function, Publication, Hits Total, Dur Tot Max, Dur Tot Min, Dur Tot Avg, Hits Current, Dur Curr Max, Dur Curr Min, Dur Curr Avg, Sub Data');\n\n totalPerfomanceMonitor.sort((a, b) => b.hits_total - a.hits_total).forEach(total => {\n console.log(total.function + ',' + total.publication + ',' + total.hits_total + ',' + total.duration_total_max + ',' + total.duration_total_min + ',' + total.duration_total_avg + ',' + total.hits_current + ',' + total.duration_current_max + ',' + total.duration_current_min + ',' + total.duration_current_avg + ',' + JSON.stringify(total.subscriptionData));\n });\n\n console.log('---------------------------------------------------------------------------------');\n console.log('---------------------------------------------------------------------------------');\n}"]}
|