@resolveio/server-lib 9.1.43 → 9.2.0
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/managers/mongo.manager.js +1 -1
- package/managers/mongo.manager.js.map +1 -1
- package/managers/queue-method.manager.js +1 -1
- package/managers/queue-method.manager.js.map +1 -1
- package/managers/subscription.manager.js +281 -98
- package/managers/subscription.manager.js.map +1 -1
- package/managers/subscription.performance.d.ts +27 -0
- package/managers/subscription.performance.js +101 -0
- package/managers/subscription.performance.js.map +1 -0
- package/package.json +1 -1
- package/server-app.d.ts +1 -1
- package/server-app.js +4 -11
- package/server-app.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/managers/subscription.manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,6CAA2D;AAC3D,yDAAuE;AACvE,2DAAyE;AACzE,+CAA6D;AAC7D,2DAAyE;AACzE,wFAA0E;AAC1E,uDAAoE;AACpE,+CAA8D;AAC9D,6DAA2E;AAC3E,qEAAkF;AAElF,kCAA2C;AAC3C,+DAA6E;AAC7E,iFAA6F;AAI7F,qFAAgG;AAChG,2DAAwE;AACxE,2DAAwE;AACxE,uGAAkH;AAClH,iDAAoD;AACpD,yCAAyD;AACzD,+BAAiC;AACjC,sCAAwC;AAWxC;IAqBC,6BAAY,UAAU,EAAE,GAAqB,EAAE,YAAY;QAA3D,iBAkIC;QApJO,kBAAa,GAAsB,EAAE,CAAC;QACtC,mBAAc,GAA8B,EAAE,CAAC;QAE/C,mBAAc,GAAwB,EAAE,CAAC;QAEzC,gBAAW,GAAsB,EAAE,CAAC;QACpC,kBAAa,GAAG,CAAC,CAAC;QAElB,eAAU,GAAG,EAAE,CAAC;QAChB,kBAAa,GAAG,KAAK,CAAC;QAKtB,aAAQ,GAAG,CAAC,CAAC;QAKpB,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;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I,CAAC;iCAC/B;6BACD;4BAED,OAAO,CAAC,IAAI,CAAC,CAAC;yBACd;oBACF,CAAC,EAAE,UAAA,GAAG;wBACL,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,UAAA,MAAM;4BAClC,KAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,UAAA,EAAE;gCAC3B,IAAI,EAAE,CAAC,WAAW,CAAC,KAAK,MAAM,CAAC,SAAS,EAAE;oCACzC,IAAI,SAAS,GAAwB;wCACpC,SAAS,EAAE,MAAM,CAAC,SAAS;wCAC3B,QAAQ,EAAE,IAAI;wCACd,IAAI,EAAE,GAAG;qCACT,CAAC;oCAEF,KAAI,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;iCAC3B;4BACF,CAAC,CAAC,CAAC;wBACJ,CAAC,CAAC,CAAC;wBAEH,MAAM,CAAC,GAAG,CAAC,CAAC;oBACb,CAAC,CAAC,CAAC;iBACH;;;aACD,CAAC,CAAC;IACJ,CAAC;IAEO,oCAAM,GAAd,UAAe,EAAa,EAAE,IAAyB;QACtD,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE;YAC5B,KAAK,EAAE,EAAE,CAAC,WAAW,CAAC;YACtB,IAAI,EAAE,IAAI;SACV,CAAC,CAAC;IACJ,CAAC;IACF,0BAAC;AAAD,CA9nBA,AA8nBC,IAAA;AA9nBY,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 { loadAppVersionPublications } from '../publications/app-version';\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 { loadMethodCallsPublications } from '../publications/method-calls';\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 } 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 { deepCopy, getBinarySize } from '../util/common';\nimport * as moment from 'moment';\nimport * as NodeCache from 'node-cache';\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\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\tconstructor(mainServer, wss: WebSocket.Server, serverConfig) {\n\t\tthis._mainServer = mainServer;\n\n\t\tthis._nodeCache = new NodeCache( { stdTTL: 0, checkperiod: 0 } );\n\n\t\tthis.serverConfig = serverConfig;\n\t\tthis._wss = wss;\n\n\t\t// Publications\n\t\tloadSuperAdminPublications(this);\n\t\tloadAppVersionPublications(this);\n\t\tloadAppStatusPublications(this);\n\t\tloadLogPublications(this);\n\t\tloadFilePublications(this);\n\t\tloadCronJobPublications(this);\n\t\tloadFlagsPublications(this);\n\t\tloadMethodCallsPublications(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(async () => {\n\t\t\tif (!this._runningQueue) {\n\t\t\t\tif (this._sendQueue.length) {\n\t\t\t\t\tthis._runningQueue = true;\n\t\t\t\t\tfor (let i = this._sendQueue.length - 1; i >= 0; i--) {\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\tconsole.log('Error on WS: ', error);\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\tthis._runningQueue = false;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst queueArr = this._mongoQueue.filter(a => !a.running);\n\t\t\tif (queueArr.length) {\n\t\t\t\tfor (let i = 0; i < queueArr.length; i++) {\n\t\t\t\t\tlet mongoQueue = queueArr[i];\n\n\t\t\t\t\tmongoQueue.running = true;\n\n\t\t\t\t\tif (this._publications[mongoQueue.subscription.publication].ws_specific) {\n\t\t\t\t\t\tfor (let j = 0; j < mongoQueue.subscription.clients.length; j++) {\n\t\t\t\t\t\t\tlet client = mongoQueue.subscription.clients[j];\n\t\t\t\t\t\t\tfor (let k = 0; k < this._wss.clients.size; k++) {\n\t\t\t\t\t\t\t\tlet ws = Array.from(this._wss.clients)[k];\n\t\t\t\t\t\t\t\tif (ws['id_socket'] === client.id_socket) {\n\t\t\t\t\t\t\t\t\tawait this.sendPubDataOnce(ws, client.messageId, mongoQueue.subscription, mongoQueue.type, mongoQueue.collection);\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\t\t\t\t\telse {\n\t\t\t\t\t\tawait this.sendPubData(mongoQueue.subscription, mongoQueue.type, mongoQueue.collection);\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tif (mongoQueue.run_again) {\n\t\t\t\t\t\tmongoQueue.running = false;\n\t\t\t\t\t\tmongoQueue.run_again = false;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tqueueArr.splice(queueArr.map(a => a._id).indexOf(mongoQueue._id), 1);\n\t\t\t\t\t\tthis._mongoQueue.splice(this._mongoQueue.map(a => a._id).indexOf(mongoQueue._id), 1);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}, 1);\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 || moment().diff(moment(loggedInUser.date), 'seconds') >= 60) {\n\t\t\t\t\tif (this._mainServer.getWS(loggedInUser.id_ws)) {\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}, 60000);\n\t}\n\n\tprivate addToQueue(mongoQueue: MongoQueueModel) {\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\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.push(mongoQueue);\n\t\t}\n\t}\n\n\tprivate invalidatePubsCache(collection, type) {\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\n\t\t\tsub.cacheValid = false;\n\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\tResolveIOServer.getMongoManager().invalidateQueryCache(collection);\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 async loggedInLatency(ws: WebSocket) {\n\t\tlet date = new Date();\n\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 = date;\n\t\t}\n\n\t\tLoggedInUsers.findOneAndUpdate({id_ws: ws['id_socket']}, {$set: {latency: ws['latency'], date: date}}).then(res => {\n\t\t\tif (!res) {\n\t\t\t\tthis.unsubscribeAll(ws);\n\t\t\t}\n\t\t}, () => {\n\t\t\tthis.unsubscribeAll(ws);\n\t\t});\n\t}\n\n\t// Subscribe to publication\n\tpublic async subscribe(messageDate: Date, ws: WebSocket, messageId: number, publication: string, ...subscriptionData: any[]) {\n\t\tlet pub = this._publications[publication];\n\n\t\tif (!pub) {\n\t\t\tconsole.error('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('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('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('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\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});\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}],\n\t\t\t\t\tcacheId: 0,\n\t\t\t\t\tcacheValid: false\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\t\t\t}\n\t\t\telse if (sub.cacheValid) {\n\t\t\t\tthis.sendPubDataOnce(ws, messageId, sub, 'newSub', publication);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tlet intervalCnt = 0;\n\t\t\t\tlet subInterval = setInterval(() => {\n\t\t\t\t\tif (sub.cacheValid) {\n\t\t\t\t\t\tthis.sendPubDataOnce(ws, messageId, sub, 'newSub', publication);\n\t\t\t\t\t\tclearInterval(subInterval);\n\t\t\t\t\t\tintervalCnt++;\n\n\t\t\t\t\t\tif (intervalCnt > 100) {\n\t\t\t\t\t\t\tthis._mainServer.getMethodManager().sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'Error Detected During Subscribe - Waiting and No Cache! - ' + publication + '\\n\\nData \\n' + JSON.stringify(sub.subscriptionData, null, 2));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}, 10);\n\t\t\t}\n\t\t}\n\n\t\tif (publication === 'appversion') {\n\t\t\tlet newLoggedInUser = {\n\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t__v: 0,\n\t\t\t\tdate: new Date(),\n\t\t\t\tid_user: ws['id_user'],\n\t\t\t\tuser: ws['user'],\n\t\t\t\tid_ws: ws['id_socket']\n\t\t\t};\n\n\t\t\tthis._loggedInUsers.push(newLoggedInUser);\n\n\t\t\tLoggedInUsers.insertOne(newLoggedInUser);\n\n\t\t\tif (ws['user'] !== 'Admin' && this.serverConfig['CLIENT_NAME'] !== 'ResolveIO') {\n\t\t\t\tthis._mainServer.getMethodManager().callMethodInternal('supportCreateBillingUser', {\n\t\t\t\t\tid_user: ws['id_user'],\n\t\t\t\t\tuser: ws['user'],\n\t\t\t\t\tdate: new Date(),\n\t\t\t\t\tclient: ResolveIOServer.getClientName()\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\t// Unsubscribe from publication \n\tpublic async unsubscribe(messageDate: Date, ws: WebSocket, messageId: number, publication: string, ...subscriptionData: any[]) {\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\t}\n\n\t// Unsubscribe from publication\n\tpublic async unsubscribeAll(ws: WebSocket) {\n\t\t// console.log('Before');\n\t\t// console.dir(this._subscriptions.map(a => a.publication));\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.terminate();\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\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 tailOpLog() {\n\t\tthis._oplog = ResolveIOServer.getMainDB().watch();\n\n\t\tthis._oplog.on('change', (doc: any) => {\n\t\t\tlet collection = doc.ns.coll;\n\n\t\t\tif (collection && !collection.endsWith('.versions') && !collection.startsWith('monitor-') && collection !== 'logs' && collection !== 'log-method-latencies' && collection !== 'log-subscriptions') {\n\t\t\t\tif (doc.operationType === 'insert') {\n\t\t\t\t\tif (collection === 'queue-methods') {\n\t\t\t\t\t\tthis._mainServer.getQueueManager().runMethodQueue();\n\t\t\t\t\t}\n\t\t\t\t\telse if (collection === 'queue-responses') {\n\t\t\t\t\t\tthis._mainServer.getQueueManager().runMethodResponse();\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tif (collection === 'cron-jobs') {\n\t\t\t\t\t\t\tthis._mainServer.getCronManager().checkCronJobsForUpdates();\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (collection === 'support-tickets') {\n\t\t\t\t\t\t\tif (this.serverConfig['ROOT_URL'] === 'https://resolveio.com') {\n\t\t\t\t\t\t\t\tthis._mainServer.getMethodManager().callMethodInternal('sendSupportTicketEmail', doc.documentKey._id);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tthis.invalidatePubsCache(collection, 'insert');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (doc.operationType === 'update' || doc.operationType === 'replace') {\n\t\t\t\t\tif (collection === 'cron-jobs') {\n\t\t\t\t\t\tthis._mainServer.getCronManager().checkCronJobsForUpdates();\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.invalidatePubsCache(collection, 'update');\n\t\t\t\t}\n\t\t\t\telse if (doc.operationType === 'delete') {\n\t\t\t\t\tif (collection === 'cron-jobs') {\n\t\t\t\t\t\tthis._mainServer.getCronManager().checkCronJobsForUpdates();\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.invalidatePubsCache(collection, 'delete');\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\t\n\t\tthis._oplog.on('error', error => {\n\t\t\tconsole.log('oplog error', error);\n\n\t\t\tprocess.exit();\n\t\t});\n\t\t\n\t\tthis._oplog.on('end', () => {\n\t\t\tconsole.log('oplog ended');\n\n\t\t\tprocess.exit();\n\t\t});\n\t}\n\n\t// Fetch pub once, send to all clients linked to this pub\n\tprivate sendPubDataOnce(ws: WebSocket, messageId: number, subscription: ActiveSubscriptionModel, type: string, collection: string) {\n\t\treturn new Promise(async (resolve, reject) => {\n\t\t\tif (!this._publications[subscription.publication].ws_specific) { // Same pub for all users\n\t\t\t\tif (subscription.cacheId && subscription.cacheValid) {\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: this._nodeCache.get(subscription.cacheId)\n\t\t\t\t\t};\n\n\t\t\t\t\tif (serverRes.data === undefined) {\n\t\t\t\t\t\tsubscription.cacheId = 0;\n\t\t\t\t\t\tsubscription.cacheValid = false;\n\t\t\t\t\t\tthis._mainServer.getMethodManager().sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'Error Detected During SendPubDataOnce - Invalid Cache! - ' + subscription.publication + '\\n\\nData \\n' + JSON.stringify(subscription.subscriptionData, null, 2));\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.sendWS(ws, serverRes);\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 SendPubDataOnce - 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\tthis._publications[subscription.publication].function.call(Object.assign({}, this, SubscriptionManager.prototype), ws['id_user'], ...subscription.subscriptionData)\n\t\t\t\t.catch(methodErrs => {\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 + ' - (sendPubDataOnce - WS)\\n\\nData \\n' + JSON.stringify(subscription.subscriptionData, null, 2) + '\\n\\nErrors\\n' + JSON.stringify(methodErrs, null, 2));\n\t\t\t\t})\n\t\t\t\t.then(res => {\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\tresolve(true);\n\n\t\t\t\t}, err => {\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\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 sendPubData(subscription: ActiveSubscriptionModel, type: string, collection: string) {\n\t\treturn new Promise(async (resolve, reject) => {\n\t\t\tif (!subscription.clients.length) {\n\t\t\t\tif (subscription.cacheId) {\n\t\t\t\t\tthis._nodeCache.del(subscription.cacheId);\n\t\t\t\t}\n\n\t\t\t\tthis._subscriptions.splice(this._subscriptions.findIndex(a => a.publication === subscription.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscription.subscriptionData)), 1);\n\n\t\t\t\tresolve(false);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (subscription.publication !== 'superadminAPM' && subscription.publication !== 'loggedInUsers') {\n\t\t\t\t\tthis._mainServer.getMethodManager().callMethodInternal('insertSubscriptionLog', type, subscription.publication, collection, JSON.stringify(subscription.subscriptionData));\n\t\t\t\t}\n\n\t\t\t\tthis._publications[subscription.publication].function.call(Object.assign({}, this, SubscriptionManager.prototype), ...subscription.subscriptionData)\n\t\t\t\t.catch(methodErrs => {\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 + ' - (sendPubData)\\n\\nData \\n' + JSON.stringify(subscription.subscriptionData, null, 2) + '\\n\\nErrors\\n' + JSON.stringify(methodErrs, null, 2));\n\t\t\t\t})\n\t\t\t\t.then(res => {\n\t\t\t\t\tif (!subscription.clients.length) {\n\t\t\t\t\t\tif (subscription.cacheId) {\n\t\t\t\t\t\t\tthis._nodeCache.del(subscription.cacheId);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tthis._subscriptions.splice(this._subscriptions.findIndex(a => a.publication === subscription.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscription.subscriptionData)), 1);\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 (subscription.cacheId && JSON.stringify(this._nodeCache.get(subscription.cacheId)) === JSON.stringify(res)) {\n\t\t\t\t\t\t\tsubscription.cacheValid = true;\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tsubscription.clients.forEach(client => {\n\t\t\t\t\t\t\t\tthis._wss.clients.forEach(ws => {\n\t\t\t\t\t\t\t\t\tif (ws['id_socket'] === client.id_socket) {\n\t\t\t\t\t\t\t\t\t\tlet serverRes: ServerResponseModel = {\n\t\t\t\t\t\t\t\t\t\t\tmessageId: client.messageId,\n\t\t\t\t\t\t\t\t\t\t\thasError: false,\n\t\t\t\t\t\t\t\t\t\t\tdata: res\n\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\n\t\t\t\t\t\t\t\t\t\tthis.sendWS(ws, serverRes);\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\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 > 250000000) {\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);\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\tsubscription.cacheId = 0;\n\t\t\t\t\t\t\t\t\tsubscription.cacheValid = false;\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 < 250000000) {\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 - ' + subscription.publication + ' - Deleted: ' + deleteCount + ' - ' + nodeCacheSize);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (subscription.cacheId) {\n\t\t\t\t\t\t\t\tthis._nodeCache.del(subscription.cacheId);\n\t\t\t\t\t\t\t}\n\t\n\t\t\t\t\t\t\tif (collection !== 'cron-jobs' && collection !== 'logs' && collection !== 'logged-in-users') {\n\t\t\t\t\t\t\t\tlet cacheId = this._cacheId;\n\t\t\t\t\t\t\t\tthis._cacheId += 1;\n\n\t\t\t\t\t\t\t\tthis._nodeCache.set(cacheId, res);\n\t\t\t\t\t\t\t\tsubscription.cacheId = cacheId;\n\t\t\t\t\t\t\t\tsubscription.cacheValid = true;\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\tsubscription.clients.forEach(client => {\n\t\t\t\t\t\tthis._wss.clients.forEach(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"]}
|
|
1
|
+
{"version":3,"sources":["../../src/managers/subscription.manager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,6CAA2D;AAC3D,yDAAuE;AACvE,2DAAyE;AACzE,+CAA6D;AAC7D,2DAAyE;AACzE,wFAA0E;AAC1E,uDAAoE;AACpE,+CAA8D;AAC9D,6DAA2E;AAC3E,qEAAkF;AAElF,kCAA2C;AAC3C,+DAA6E;AAC7E,iFAA6F;AAI7F,qFAAgG;AAChG,2DAAwE;AACxE,2DAAwE;AACxE,uGAAkH;AAClH,iDAAoD;AACpD,yCAA0C;AAC1C,+BAAiC;AACjC,sCAAwC;AAexC,wCAAwC;AACxC,gBAAgB;AAChB,qBAAqB;AACrB,wBAAwB;AACxB,4BAA4B;AAC5B,qBAAqB;AACrB,mBAAmB;AACnB,qBAAqB;AACrB,mBAAmB;AACnB,IAAI;AAEJ;IAqBC,sEAAsE;IACtE,qCAAqC;IACrC,6BAA6B;IAE7B,6BAAY,UAAU,EAAE,GAAqB,EAAE,YAAY;QAA3D,iBAkLC;QAxMO,kBAAa,GAAsB,EAAE,CAAC;QACtC,mBAAc,GAA8B,EAAE,CAAC;QAE/C,mBAAc,GAAwB,EAAE,CAAC;QAEzC,gBAAW,GAAsB,EAAE,CAAC;QACpC,kBAAa,GAAG,CAAC,CAAC;QAElB,eAAU,GAAG,EAAE,CAAC;QAChB,kBAAa,GAAG,KAAK,CAAC;QAKtB,aAAQ,GAAG,CAAC,CAAC;QASpB,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAE9B,IAAI,CAAC,UAAU,GAAG,IAAI,SAAS,CAAE,EAAE,MAAM,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,CAAE,CAAC;QAEjE,qBAAqB;QACrB,iDAAiD;Q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BAClC,IAAI,EAAE,GAAG,KAAI,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;4BAElD,IAAI,EAAE,EAAE;gCACP,IAAI,EAAE,CAAC,WAAW,CAAC,KAAK,MAAM,CAAC,SAAS,EAAE;oCACzC,IAAI,SAAS,GAAwB;wCACpC,SAAS,EAAE,MAAM,CAAC,SAAS;wCAC3B,QAAQ,EAAE,IAAI;wCACd,IAAI,EAAE,GAAG;qCACT,CAAC;oCAEF,KAAI,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC;iCAC3B;6BACD;wBACF,CAAC,CAAC,CAAC;wBAEH,MAAM,CAAC,GAAG,CAAC,CAAC;oBACb,CAAC,CAAC,CAAC;iBACH;;;aACD,CAAC,CAAC;IACJ,CAAC;IAEO,oCAAM,GAAd,UAAe,EAAa,EAAE,IAAyB;QACtD,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE;YAC5B,KAAK,EAAE,EAAE,CAAC,WAAW,CAAC;YACtB,IAAI,EAAE,IAAI;SACV,CAAC,CAAC;IACJ,CAAC;IACF,0BAAC;AAAD,CAz3BA,AAy3BC,IAAA;AAz3BY,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 { loadAppVersionPublications } from '../publications/app-version';\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 { loadMethodCallsPublications } from '../publications/method-calls';\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 } 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 { deepCopy } from '../util/common';\nimport * as moment from 'moment';\nimport * as NodeCache from 'node-cache';\n\n// Performance Dependencies\n// import * as path from 'path';\n// const { Worker } = require('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\t// private currentPerfomanceMonitor: CurrentPerformanceMonitor[] = [];\n\t// private idPerformance: number = 0;\n\t// private performanceThread;\n\n\tconstructor(mainServer, wss: WebSocket.Server, serverConfig) {\n\t\tthis._mainServer = mainServer;\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('THREAD EXITED!!!!!!!!!!!!!!!!!!', code);\n\t\t// \t});\n\n\t\t// \tthis.performanceThread.on('error', code => {\n\t\t// \t\tconsole.error('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\tloadAppVersionPublications(this);\n\t\tloadAppStatusPublications(this);\n\t\tloadLogPublications(this);\n\t\tloadFilePublications(this);\n\t\tloadCronJobPublications(this);\n\t\tloadFlagsPublications(this);\n\t\tloadMethodCallsPublications(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(async () => {\n\t\t\tif (!this._runningQueue) {\n\t\t\t\tif (this._sendQueue.length) {\n\t\t\t\t\t// let startDate = new Date();\n\n\t\t\t\t\tthis._runningQueue = true;\n\t\t\t\t\tfor (let i = this._sendQueue.length - 1; i >= 0; i--) {\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\tconsole.log('Error on WS: ', error);\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\tthis._runningQueue = false;\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\t\t\t}\n\n\t\t\tconst queueArr = this._mongoQueue.filter(a => !a.running);\n\t\t\tif (queueArr.length) {\n\t\t\t\tqueueArr.forEach(entry => {\n\t\t\t\t\tentry.running = true;\n\t\t\t\t});\n\n\t\t\t\t// let startDate = new Date();\n\n\t\t\t\tfor (let i = 0; i < queueArr.length; i++) {\n\t\t\t\t\tlet mongoQueue = queueArr[i];\n\n\t\t\t\t\tif (this._publications[mongoQueue.subscription.publication].ws_specific) {\n\t\t\t\t\t\tfor (let j = 0; j < mongoQueue.subscription.clients.length; j++) {\n\t\t\t\t\t\t\tlet client = mongoQueue.subscription.clients[j];\n\t\t\t\t\t\t\tlet ws = this._mainServer.getWS(client.id_socket);\n\t\t\t\t\t\t\tif (ws['id_socket'] === client.id_socket) {\n\t\t\t\t\t\t\t\tthis.sendPubDataOnce(ws, client.messageId, mongoQueue.subscription, mongoQueue.type, mongoQueue.collection);\n\t\t\t\t\t\t\t}\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.sendPubData(mongoQueue.subscription, mongoQueue.type, mongoQueue.collection);\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tif (mongoQueue.run_again) {\n\t\t\t\t\t\tmongoQueue.running = false;\n\t\t\t\t\t\tmongoQueue.run_again = false;\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tthis._mongoQueue.splice(this._mongoQueue.map(a => a._id).indexOf(mongoQueue._id), 1);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// let endDate = new Date();\n\t\t\t\t\n\t\t\t\t// this.currentPerfomanceMonitor.push({\n\t\t\t\t// \t_id: this.idPerformance++,\n\t\t\t\t// \tfunction: 'mongoQueue',\n\t\t\t\t// \tpublication: '',\n\t\t\t\t// \tsubscriptionData: queueArr,\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: 'Done'\n\t\t\t\t// });\n\t\t\t}\n\t\t}, 10);\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 || moment().diff(moment(loggedInUser.date), 'seconds') >= 60) {\n\t\t\t\t\tif (this._mainServer.getWS(loggedInUser.id_ws)) {\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}, 60000);\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// \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// \t\tsubscriptionData: mongoQueue.subscription.subscriptionData,\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.push(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// \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\tprivate invalidatePubsCache(collection, type) {\n\t\t// let startDate = new Date();\n\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\n\t\t\tsub.cacheValid = false;\n\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\tResolveIOServer.getMongoManager().invalidateQueryCache(collection);\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 async loggedInLatency(ws: WebSocket) {\n\t\tlet date = new Date();\n\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 = date;\n\t\t}\n\n\t\tLoggedInUsers.findOneAndUpdate({id_ws: ws['id_socket']}, {$set: {latency: ws['latency'], date: date}}).then(res => {\n\t\t\tif (!res) {\n\t\t\t\tthis.unsubscribeAll(ws);\n\t\t\t}\n\t\t}, () => {\n\t\t\tthis.unsubscribeAll(ws);\n\t\t});\n\t}\n\n\t// Subscribe to publication\n\tpublic async subscribe(messageDate: Date, ws: WebSocket, messageId: number, publication: string, ...subscriptionData: any[]) {\n\t\t// let startDate = new Date();\n\n\t\tlet pub = this._publications[publication];\n\n\t\tif (!pub) {\n\t\t\tconsole.error('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('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('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('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\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});\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}],\n\t\t\t\t\tcacheId: 0,\n\t\t\t\t\tcacheValid: false\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// \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.cacheValid) {\n\t\t\t\tthis.sendPubDataOnce(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// \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\n\t\tif (publication === 'appversion') {\n\t\t\tlet newLoggedInUser = {\n\t\t\t\t_id: objectIdHexString(),\n\t\t\t\t__v: 0,\n\t\t\t\tdate: new Date(),\n\t\t\t\tid_user: ws['id_user'],\n\t\t\t\tuser: ws['user'],\n\t\t\t\tid_ws: ws['id_socket']\n\t\t\t};\n\n\t\t\tthis._loggedInUsers.push(newLoggedInUser);\n\n\t\t\tLoggedInUsers.insertOne(newLoggedInUser);\n\n\t\t\tif (ws['user'] !== 'Admin' && this.serverConfig['CLIENT_NAME'] !== 'ResolveIO') {\n\t\t\t\tthis._mainServer.getMethodManager().callMethodInternal('supportCreateBillingUser', {\n\t\t\t\t\tid_user: ws['id_user'],\n\t\t\t\t\tuser: ws['user'],\n\t\t\t\t\tdate: new Date(),\n\t\t\t\t\tclient: ResolveIOServer.getClientName()\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\t// Unsubscribe from publication \n\tpublic async unsubscribe(messageDate: Date, ws: WebSocket, messageId: number, publication: string, ...subscriptionData: any[]) {\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// \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\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.terminate();\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: [ws['id_socket']],\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\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 tailOpLog() {\n\t\tthis._oplog = ResolveIOServer.getMainDB().watch();\n\n\t\tthis._oplog.on('change', (doc: any) => {\n\t\t\t// let startDate = new Date();\n\n\t\t\tlet collection = doc.ns.coll;\n\n\t\t\tif (collection && !collection.endsWith('.versions') && !collection.startsWith('monitor-') && collection !== 'logs' && collection !== 'log-method-latencies' && collection !== 'log-subscriptions') {\n\t\t\t\tif (doc.operationType === 'insert') {\n\t\t\t\t\tif (collection === 'queue-methods') {\n\t\t\t\t\t\tthis._mainServer.getQueueManager().runMethodQueue();\n\t\t\t\t\t}\n\t\t\t\t\telse if (collection === 'queue-responses') {\n\t\t\t\t\t\tthis._mainServer.getQueueManager().runMethodResponse();\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tif (collection === 'cron-jobs') {\n\t\t\t\t\t\t\tthis._mainServer.getCronManager().checkCronJobsForUpdates();\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (collection === 'support-tickets') {\n\t\t\t\t\t\t\tif (this.serverConfig['ROOT_URL'] === 'https://resolveio.com') {\n\t\t\t\t\t\t\t\tthis._mainServer.getMethodManager().callMethodInternal('sendSupportTicketEmail', doc.documentKey._id);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (collection !== 'method-responses' && collection !== 'method-calls') {\n\t\t\t\t\t\t\tthis.invalidatePubsCache(collection, 'insert');\n\t\t\t\t\t\t}\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: 'oplog',\n\t\t\t\t\t\t// \tpublication: collection,\n\t\t\t\t\t\t// \tsubscriptionData: [doc.documentKey._id],\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: 'Insert'\n\t\t\t\t\t\t// });\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (doc.operationType === 'update' || doc.operationType === 'replace') {\n\t\t\t\t\tif (collection === 'cron-jobs') {\n\t\t\t\t\t\tthis._mainServer.getCronManager().checkCronJobsForUpdates();\n\t\t\t\t\t}\n\t\t\t\t\telse if (collection !== 'queue-methods' && collection !== 'queue-responses' && collection !== 'method-responses' && collection !== 'method-calls') {\n\t\t\t\t\t\tthis.invalidatePubsCache(collection, 'update');\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: 'oplog',\n\t\t\t\t\t// \tpublication: collection,\n\t\t\t\t\t// \tsubscriptionData: [doc.documentKey._id],\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: 'Update'\n\t\t\t\t\t// });\n\t\t\t\t}\n\t\t\t\telse if (doc.operationType === 'delete') {\n\t\t\t\t\tif (collection === 'cron-jobs') {\n\t\t\t\t\t\tthis._mainServer.getCronManager().checkCronJobsForUpdates();\n\t\t\t\t\t}\n\t\t\t\t\telse if (collection !== 'queue-methods' && collection !== 'queue-responses' && collection !== 'method-responses' && collection !== 'method-calls') {\n\t\t\t\t\t\tthis.invalidatePubsCache(collection, 'delete');\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: 'oplog',\n\t\t\t\t\t// \tpublication: collection,\n\t\t\t\t\t// \tsubscriptionData: [doc.documentKey._id],\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: 'Delete'\n\t\t\t\t\t// });\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\t\n\t\tthis._oplog.on('error', error => {\n\t\t\tconsole.log('oplog error', error);\n\n\t\t\tprocess.exit();\n\t\t});\n\t\t\n\t\tthis._oplog.on('end', () => {\n\t\t\tconsole.log('oplog ended');\n\n\t\t\tprocess.exit();\n\t\t});\n\t}\n\n\t// Fetch pub once, send to all clients linked to this pub\n\tprivate sendPubDataOnce(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].ws_specific) { // Same pub for all users\n\t\t\t\tif (subscription.cacheId && subscription.cacheValid) {\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: this._nodeCache.get(subscription.cacheId)\n\t\t\t\t\t};\n\n\t\t\t\t\tif (serverRes.data === undefined) {\n\t\t\t\t\t\tsubscription.cacheId = 0;\n\t\t\t\t\t\tsubscription.cacheValid = false;\n\t\t\t\t\t\tthis._mainServer.getMethodManager().sendEmail('dev@resolveio.com', 'SERVER - Error Detected - ' + this.serverConfig['CLIENT_NAME'], 'Error Detected During SendPubDataOnce - Invalid Cache! - ' + subscription.publication + '\\n\\nData \\n' + JSON.stringify(subscription.subscriptionData, null, 2));\n\t\t\t\t\t}\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: 'sendPubDataOnce',\n\t\t\t\t\t// \tpublication: subscription.publication,\n\t\t\t\t\t// \tsubscriptionData: subscription.subscriptionData,\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 SendPubDataOnce - 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\tthis._publications[subscription.publication].function.call(Object.assign({}, this, SubscriptionManager.prototype), ws['id_user'], ...subscription.subscriptionData)\n\t\t\t\t.catch(methodErrs => {\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 + ' - (sendPubDataOnce - WS)\\n\\nData \\n' + JSON.stringify(subscription.subscriptionData, null, 2) + '\\n\\nErrors\\n' + JSON.stringify(methodErrs, null, 2));\n\t\t\t\t})\n\t\t\t\t.then(res => {\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: 'sendPubDataOnce',\n\t\t\t\t\t// \tpublication: subscription.publication,\n\t\t\t\t\t// \tsubscriptionData: subscription.subscriptionData,\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\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\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 sendPubData(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 (!subscription.clients.length) {\n\t\t\t\tif (subscription.cacheId) {\n\t\t\t\t\tthis._nodeCache.del(subscription.cacheId);\n\t\t\t\t}\n\n\t\t\t\tthis._subscriptions.splice(this._subscriptions.findIndex(a => a.publication === subscription.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscription.subscriptionData)), 1);\n\n\t\t\t\tresolve(false);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (subscription.publication !== 'superadminAPM' && subscription.publication !== 'loggedInUsers') {\n\t\t\t\t\tthis._mainServer.getMethodManager().callMethodInternal('insertSubscriptionLog', type, subscription.publication, collection, JSON.stringify(subscription.subscriptionData));\n\t\t\t\t}\n\n\t\t\t\tthis._publications[subscription.publication].function.call(Object.assign({}, this, SubscriptionManager.prototype), ...subscription.subscriptionData)\n\t\t\t\t.catch(methodErrs => {\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 + ' - (sendPubData)\\n\\nData \\n' + JSON.stringify(subscription.subscriptionData, null, 2) + '\\n\\nErrors\\n' + JSON.stringify(methodErrs, null, 2));\n\t\t\t\t})\n\t\t\t\t.then(res => {\n\t\t\t\t\tif (!subscription.clients.length) {\n\t\t\t\t\t\tif (subscription.cacheId) {\n\t\t\t\t\t\t\tthis._nodeCache.del(subscription.cacheId);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tthis._subscriptions.splice(this._subscriptions.findIndex(a => a.publication === subscription.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(subscription.subscriptionData)), 1);\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// \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 (subscription.cacheId && JSON.stringify(this._nodeCache.get(subscription.cacheId)) === JSON.stringify(res)) {\n\t\t\t\t\t\t\tsubscription.cacheValid = true;\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// \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 cache dont send'\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\tsubscription.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 > 250000000) {\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);\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\tsubscription.cacheId = 0;\n\t\t\t\t\t\t\t\t\tsubscription.cacheValid = false;\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 < 250000000) {\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 - ' + subscription.publication + ' - Deleted: ' + deleteCount + ' - ' + nodeCacheSize);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (subscription.cacheId) {\n\t\t\t\t\t\t\t\tthis._nodeCache.del(subscription.cacheId);\n\t\t\t\t\t\t\t}\n\t\n\t\t\t\t\t\t\tif (collection !== 'cron-jobs' && collection !== 'logs' && collection !== 'logged-in-users') {\n\t\t\t\t\t\t\t\tlet cacheId = this._cacheId;\n\t\t\t\t\t\t\t\tthis._cacheId += 1;\n\n\t\t\t\t\t\t\t\tthis._nodeCache.set(cacheId, res);\n\t\t\t\t\t\t\t\tsubscription.cacheId = cacheId;\n\t\t\t\t\t\t\t\tsubscription.cacheValid = true;\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: '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// \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\tsubscription.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"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
declare const parentPort: any;
|
|
2
|
+
interface CurrentPerformanceMonitor {
|
|
3
|
+
_id: number;
|
|
4
|
+
function: string;
|
|
5
|
+
publication: string;
|
|
6
|
+
subscriptionData: any[];
|
|
7
|
+
date_start: Date;
|
|
8
|
+
date_end: Date;
|
|
9
|
+
duration: number;
|
|
10
|
+
result: string;
|
|
11
|
+
}
|
|
12
|
+
interface TotalPerformanceMonitor {
|
|
13
|
+
function: string;
|
|
14
|
+
publication: string;
|
|
15
|
+
subscriptionData: any[];
|
|
16
|
+
data: CurrentPerformanceMonitor[];
|
|
17
|
+
duration_total_max: number;
|
|
18
|
+
duration_total_min: number;
|
|
19
|
+
duration_total_avg: number;
|
|
20
|
+
hits_total: number;
|
|
21
|
+
duration_current_max: number;
|
|
22
|
+
duration_current_min: number;
|
|
23
|
+
duration_current_avg: number;
|
|
24
|
+
hits_current: number;
|
|
25
|
+
}
|
|
26
|
+
declare let totalPerfomanceMonitor: TotalPerformanceMonitor[];
|
|
27
|
+
declare function processMsg(msg: CurrentPerformanceMonitor[]): void;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
var parentPort = require('worker_threads').parentPort;
|
|
2
|
+
var totalPerfomanceMonitor = [];
|
|
3
|
+
parentPort.on('message', function (msg) {
|
|
4
|
+
console.log('Recv Msg');
|
|
5
|
+
processMsg(msg);
|
|
6
|
+
});
|
|
7
|
+
function processMsg(msg) {
|
|
8
|
+
if (totalPerfomanceMonitor.length) {
|
|
9
|
+
totalPerfomanceMonitor.forEach(function (total) {
|
|
10
|
+
var currents = msg.filter(function (a) { return a.function === total.function && a.publication === total.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(total.subscriptionData); });
|
|
11
|
+
if (currents.length) {
|
|
12
|
+
total.data = total.data.concat(currents);
|
|
13
|
+
total.duration_total_max = Math.max.apply(Math, total.data.map(function (a) { return a.duration; }));
|
|
14
|
+
total.duration_total_min = Math.min.apply(Math, total.data.map(function (a) { return a.duration; }));
|
|
15
|
+
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);
|
|
16
|
+
total.hits_total = total.data.length;
|
|
17
|
+
total.duration_current_max = Math.max.apply(Math, currents.map(function (a) { return a.duration; }));
|
|
18
|
+
total.duration_current_min = Math.min.apply(Math, currents.map(function (a) { return a.duration; }));
|
|
19
|
+
total.duration_current_avg = Math.round(currents.map(function (a) { return a.duration; }).reduce(function (a, b) { return a + b; }, 0) / currents.length);
|
|
20
|
+
total.hits_current = currents.length;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
total.duration_current_max = 0;
|
|
24
|
+
total.duration_current_min = 0;
|
|
25
|
+
total.duration_current_avg = 0;
|
|
26
|
+
total.hits_current = 0;
|
|
27
|
+
}
|
|
28
|
+
currents.forEach(function (current) {
|
|
29
|
+
msg.splice(msg.findIndex(function (a) { return a._id === current._id; }), 1);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
msg.forEach(function (entry) {
|
|
33
|
+
var total = totalPerfomanceMonitor.filter(function (a) { return a.function === entry.function && a.publication === entry.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(entry.subscriptionData); })[0];
|
|
34
|
+
if (total) {
|
|
35
|
+
total.data.push(entry);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
totalPerfomanceMonitor.push({
|
|
39
|
+
function: entry.function,
|
|
40
|
+
publication: entry.publication,
|
|
41
|
+
subscriptionData: entry.subscriptionData,
|
|
42
|
+
data: [entry],
|
|
43
|
+
duration_total_max: 0,
|
|
44
|
+
duration_total_min: 0,
|
|
45
|
+
duration_total_avg: 0,
|
|
46
|
+
hits_total: 0,
|
|
47
|
+
duration_current_max: 0,
|
|
48
|
+
duration_current_min: 0,
|
|
49
|
+
duration_current_avg: 0,
|
|
50
|
+
hits_current: 0
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
msg.forEach(function (entry) {
|
|
57
|
+
var total = totalPerfomanceMonitor.filter(function (a) { return a.function === entry.function && a.publication === entry.publication && JSON.stringify(a.subscriptionData) === JSON.stringify(entry.subscriptionData); })[0];
|
|
58
|
+
if (total) {
|
|
59
|
+
total.data.push(entry);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
totalPerfomanceMonitor.push({
|
|
63
|
+
function: entry.function,
|
|
64
|
+
publication: entry.publication,
|
|
65
|
+
subscriptionData: entry.subscriptionData,
|
|
66
|
+
data: [entry],
|
|
67
|
+
duration_total_max: 0,
|
|
68
|
+
duration_total_min: 0,
|
|
69
|
+
duration_total_avg: 0,
|
|
70
|
+
hits_total: 0,
|
|
71
|
+
duration_current_max: 0,
|
|
72
|
+
duration_current_min: 0,
|
|
73
|
+
duration_current_avg: 0,
|
|
74
|
+
hits_current: 0
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
totalPerfomanceMonitor.forEach(function (total) {
|
|
79
|
+
total.duration_total_max = Math.max.apply(Math, total.data.map(function (a) { return a.duration; }));
|
|
80
|
+
total.duration_total_min = Math.min.apply(Math, total.data.map(function (a) { return a.duration; }));
|
|
81
|
+
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);
|
|
82
|
+
total.hits_total = total.data.length;
|
|
83
|
+
total.duration_current_max = Math.max.apply(Math, total.data.map(function (a) { return a.duration; }));
|
|
84
|
+
total.duration_current_min = Math.min.apply(Math, total.data.map(function (a) { return a.duration; }));
|
|
85
|
+
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);
|
|
86
|
+
total.hits_current = total.data.length;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
console.log('---------------------------------------------------------------------------------');
|
|
90
|
+
console.log('---------------------------------------------------------------------------------');
|
|
91
|
+
console.log('Performance', new Date());
|
|
92
|
+
console.log('---------------------------------------------------------------------------------');
|
|
93
|
+
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');
|
|
94
|
+
totalPerfomanceMonitor.sort(function (a, b) { return b.hits_total - a.hits_total; }).forEach(function (total) {
|
|
95
|
+
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));
|
|
96
|
+
});
|
|
97
|
+
console.log('---------------------------------------------------------------------------------');
|
|
98
|
+
console.log('---------------------------------------------------------------------------------');
|
|
99
|
+
}
|
|
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CAAC;QAC3C,CAAC,CAAC,CAAC;KACN;IAED,OAAO,CAAC,GAAG,CAAC,mFAAmF,CAAC,CAAC;IACjG,OAAO,CAAC,GAAG,CAAC,mFAAmF,CAAC,CAAC;IAEjG,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;IACvC,OAAO,CAAC,GAAG,CAAC,mFAAmF,CAAC,CAAC;IAGjG,OAAO,CAAC,GAAG,CAAC,4IAA4I,CAAC,CAAC;IAE1J,sBAAsB,CAAC,IAAI,CAAC,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,EAA3B,CAA2B,CAAC,CAAC,OAAO,CAAC,UAAA,KAAK;QAC5E,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,GAAG,GAAG,GAAG,KAAK,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":["const { parentPort } = require('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}"]}
|
package/package.json
CHANGED
package/server-app.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export default class ResolveIOMainServer {
|
|
|
28
28
|
private _serverStartTime;
|
|
29
29
|
private _lastErrorMsg;
|
|
30
30
|
constructor(mainServer: any, monitorAgent: any, serverConfig: any, clientRoutes: any, clientDir: any, sesMail: any, standardProgram: any);
|
|
31
|
-
getWS(id_ws: string):
|
|
31
|
+
getWS(id_ws: string): WebSocket;
|
|
32
32
|
getWSList(): any[];
|
|
33
33
|
getWSUserList(): any[];
|
|
34
34
|
getHTTPServer(): Server;
|
package/server-app.js
CHANGED
|
@@ -59,7 +59,6 @@ var mongo_manager_1 = require("./managers/mongo.manager");
|
|
|
59
59
|
var cron_manager_1 = require("./managers/cron.manager");
|
|
60
60
|
var method_manager_1 = require("./managers/method.manager");
|
|
61
61
|
var subscription_manager_1 = require("./managers/subscription.manager");
|
|
62
|
-
var queue_method_manager_1 = require("./managers/queue-method.manager");
|
|
63
62
|
var monitor_manager_1 = require("./managers/monitor.manager");
|
|
64
63
|
var method_call_collection_1 = require("./collections/method-call.collection");
|
|
65
64
|
var method_response_collection_1 = require("./collections/method-response.collection");
|
|
@@ -236,13 +235,7 @@ var ResolveIOMainServer = /** @class */ (function () {
|
|
|
236
235
|
}
|
|
237
236
|
}
|
|
238
237
|
ResolveIOMainServer.prototype.getWS = function (id_ws) {
|
|
239
|
-
|
|
240
|
-
this._wss.clients.forEach(function (ws) {
|
|
241
|
-
if (ws['id_socket'] === id_ws) {
|
|
242
|
-
res = ws;
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
return res;
|
|
238
|
+
return Array.from(this._wss.clients).filter(function (a) { return a['id_socket'] === id_ws; })[0];
|
|
246
239
|
};
|
|
247
240
|
ResolveIOMainServer.prototype.getWSList = function () {
|
|
248
241
|
var res = [];
|
|
@@ -360,7 +353,7 @@ var ResolveIOMainServer = /** @class */ (function () {
|
|
|
360
353
|
this._subscriptionManager = new subscription_manager_1.SubscriptionManager(this, this._wss, this._serverConfig);
|
|
361
354
|
this._methodManager = new method_manager_1.MethodManager(this, this._serverConfig, this._clientDir);
|
|
362
355
|
this._cronManager = new cron_manager_1.CronManager(this);
|
|
363
|
-
this._queueManager = new
|
|
356
|
+
// this._queueManager = new QueueMethodManager(this);
|
|
364
357
|
if (this.LOGGER === 'DEBUG') {
|
|
365
358
|
console.log('End Managers');
|
|
366
359
|
}
|
|
@@ -499,7 +492,7 @@ var ResolveIOMainServer = /** @class */ (function () {
|
|
|
499
492
|
ws.ping(function () { });
|
|
500
493
|
}
|
|
501
494
|
});
|
|
502
|
-
},
|
|
495
|
+
}, 15000);
|
|
503
496
|
setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
504
497
|
var _loop_1, this_1, i;
|
|
505
498
|
var _this = this;
|
|
@@ -689,7 +682,7 @@ var ResolveIOMainServer = /** @class */ (function () {
|
|
|
689
682
|
case 5: return [2 /*return*/];
|
|
690
683
|
}
|
|
691
684
|
});
|
|
692
|
-
}); },
|
|
685
|
+
}); }, 10);
|
|
693
686
|
};
|
|
694
687
|
ResolveIOMainServer.prototype.unsubscribeWS = function (ws) {
|
|
695
688
|
this._subscriptionManager.unsubscribeAll(ws);
|