@nsshunt/stsappframework 3.0.107 → 3.0.109
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/dist/influxdb/influxDBManager.js +17 -16
- package/dist/influxdb/influxDBManager.js.map +1 -1
- package/dist/influxdb/influxDBManagerAgent.js +13 -9
- package/dist/influxdb/influxDBManagerAgent.js.map +1 -1
- package/dist/influxdb/influxDBManagerBase.js +6 -2
- package/dist/influxdb/influxDBManagerBase.js.map +1 -1
- package/dist/influxdb/influxDBManagerService.js +14 -10
- package/dist/influxdb/influxDBManagerService.js.map +1 -1
- package/dist/kafka/IMKafkaManager.js +6 -2
- package/dist/kafka/IMKafkaManager.js.map +1 -1
- package/dist/kafkatesting/produce.js +5 -1
- package/dist/kafkatesting/produce.js.map +1 -1
- package/dist/tcpclient/app2.js +2 -2
- package/dist/tcpserver/appmaster.js +16 -39
- package/dist/tcpserver/appmaster.js.map +1 -1
- package/dist/testing/appWorkerWSS.js +7 -6
- package/dist/testing/appWorkerWSS.js.map +1 -1
- package/dist/testing/singleservertest.test.js +9 -8
- package/dist/testing/singleservertest.test.js.map +1 -1
- package/package.json +1 -1
- package/src/influxdb/influxDBManager.ts +18 -16
- package/src/influxdb/influxDBManagerAgent.ts +11 -9
- package/src/influxdb/influxDBManagerBase.ts +4 -2
- package/src/influxdb/influxDBManagerService.ts +12 -10
- package/src/kafka/IMKafkaManager.ts +4 -2
- package/src/kafkatesting/produce.ts +3 -1
- package/src/tcpclient/app2.ts +2 -2
- package/src/tcpserver/appmaster.ts +17 -39
- package/src/testing/appWorkerWSS.ts +8 -6
- package/src/testing/singleservertest.test.ts +10 -8
- package/types/influxdb/influxDBManager.d.ts.map +1 -1
- package/types/influxdb/influxDBManagerAgent.d.ts.map +1 -1
- package/types/influxdb/influxDBManagerBase.d.ts.map +1 -1
- package/types/influxdb/influxDBManagerService.d.ts.map +1 -1
- package/types/kafka/IMKafkaManager.d.ts.map +1 -1
- package/types/tcpserver/appmaster.d.ts.map +1 -1
- package/types/testing/appWorkerWSS.d.ts.map +1 -1
|
@@ -117,6 +117,8 @@ import { InfluxDBManagerBase } from './influxDBManagerBase'
|
|
|
117
117
|
import { IInfluxDBManagerOptions, InstrumentPayload } from './../commonTypes'
|
|
118
118
|
import { ISubscriptionPayload, ISubscriptionKey } from '@nsshunt/stssocketio-client'
|
|
119
119
|
|
|
120
|
+
import chalk from 'chalk';
|
|
121
|
+
|
|
120
122
|
const _logPrefix = 'InfluxDBManagerService:'
|
|
121
123
|
|
|
122
124
|
/*
|
|
@@ -179,7 +181,7 @@ data
|
|
|
179
181
|
|
|
180
182
|
return this.queryApi.collectRows(query)
|
|
181
183
|
} catch (error) {
|
|
182
|
-
console.error(`${_logPrefix}#GetSTSCountGeneric: Error: [${error}]
|
|
184
|
+
console.error(chalk.red(`${_logPrefix}#GetSTSCountGeneric: Error: [${error}]`));
|
|
183
185
|
}
|
|
184
186
|
}
|
|
185
187
|
|
|
@@ -195,7 +197,7 @@ data
|
|
|
195
197
|
|> difference()`;
|
|
196
198
|
return this.queryApi.collectRows(query)
|
|
197
199
|
} catch (error) {
|
|
198
|
-
console.error(`${_logPrefix}#GetSTSHistoGeneric: Error: [${error}]
|
|
200
|
+
console.error(chalk.red(`${_logPrefix}#GetSTSHistoGeneric: Error: [${error}]`));
|
|
199
201
|
}
|
|
200
202
|
}
|
|
201
203
|
|
|
@@ -226,7 +228,7 @@ data
|
|
|
226
228
|
|
|
227
229
|
return this.queryApi.collectRows(query)
|
|
228
230
|
} catch (error) {
|
|
229
|
-
console.error(`${_logPrefix}#GetSTSQuantileGeneric: Error: [${error}]
|
|
231
|
+
console.error(chalk.red(`${_logPrefix}#GetSTSQuantileGeneric: Error: [${error}]`));
|
|
230
232
|
}
|
|
231
233
|
}
|
|
232
234
|
|
|
@@ -241,7 +243,7 @@ data
|
|
|
241
243
|
this.#GetSTSHistoGenericService(SERVICE_STATS_GLOBAL, '')],
|
|
242
244
|
[ ])
|
|
243
245
|
} catch (error) {
|
|
244
|
-
console.error(`${_logPrefix}GetInfluxDBResultsRoot: Error: [${error}]
|
|
246
|
+
console.error(chalk.red(`${_logPrefix}GetInfluxDBResultsRoot: Error: [${error}]`));
|
|
245
247
|
}
|
|
246
248
|
return {
|
|
247
249
|
subscriptionKey,
|
|
@@ -259,7 +261,7 @@ data
|
|
|
259
261
|
this.#GetSTSHistoGenericService(SERVICE_STATS_BY_SERVICE, '')],
|
|
260
262
|
['serviceId'])
|
|
261
263
|
} catch (error) {
|
|
262
|
-
console.error(`${_logPrefix}GetInfluxDBResultsService: Error: [${error}]
|
|
264
|
+
console.error(chalk.red(`${_logPrefix}GetInfluxDBResultsService: Error: [${error}]`));
|
|
263
265
|
}
|
|
264
266
|
return {
|
|
265
267
|
subscriptionKey,
|
|
@@ -279,7 +281,7 @@ data
|
|
|
279
281
|
this.#GetSTSHistoGenericService(SERVICE_STATS_BY_SERVICE_INSTANCE, `and r["serviceId"] == "${serviceId}"`)],
|
|
280
282
|
['serviceId', 'serviceInstanceId'])
|
|
281
283
|
} catch (error) {
|
|
282
|
-
console.error(`${_logPrefix}GetInfluxDBResultsServiceInstances: Error: [${error}]
|
|
284
|
+
console.error(chalk.red(`${_logPrefix}GetInfluxDBResultsServiceInstances: Error: [${error}]`));
|
|
283
285
|
}
|
|
284
286
|
return {
|
|
285
287
|
subscriptionKey,
|
|
@@ -298,7 +300,7 @@ data
|
|
|
298
300
|
this.#GetSTSHistoGenericService(SERVICE_STATS_BY_SERVICE_INSTANCE_PROCESS, `and r["serviceInstanceId"] == "${serviceInstanceId}"`)],
|
|
299
301
|
['serviceId', 'serviceInstanceId', 'serviceInstanceProcessId'])
|
|
300
302
|
} catch (error) {
|
|
301
|
-
console.error(`${_logPrefix}GetInfluxDBResultsServiceInstance: Error: [${error}]
|
|
303
|
+
console.error(chalk.red(`${_logPrefix}GetInfluxDBResultsServiceInstance: Error: [${error}]`));
|
|
302
304
|
}
|
|
303
305
|
return {
|
|
304
306
|
subscriptionKey,
|
|
@@ -361,12 +363,12 @@ data
|
|
|
361
363
|
writeApi.writePoint(point);
|
|
362
364
|
return true;
|
|
363
365
|
} catch (error: any) {
|
|
364
|
-
console.error(`${_logPrefix}OutputInfluxDB: Could not write data point: [${error}]
|
|
365
|
-
console.error(`${JSON.stringify(instrumentPayload.context)}
|
|
366
|
+
console.error(chalk.red(`${_logPrefix}OutputInfluxDB: Could not write data point: [${error}]`));
|
|
367
|
+
console.error(chalk.red(`${JSON.stringify(instrumentPayload.context)}`));
|
|
366
368
|
return false;
|
|
367
369
|
}
|
|
368
370
|
} else {
|
|
369
|
-
console.error(`${_logPrefix}OutputInfluxDBService: Could not write data point as writeClient is null
|
|
371
|
+
console.error(chalk.red(`${_logPrefix}OutputInfluxDBService: Could not write data point as writeClient is null`));
|
|
370
372
|
return false;
|
|
371
373
|
}
|
|
372
374
|
}
|
|
@@ -9,6 +9,8 @@ import { KafkaProducer } from './kafkaproducer'
|
|
|
9
9
|
import { JSONObject } from '@nsshunt/stsutils'
|
|
10
10
|
import { v4 as uuidv4 } from 'uuid';
|
|
11
11
|
|
|
12
|
+
import chalk from 'chalk';
|
|
13
|
+
|
|
12
14
|
import { $Options } from '@nsshunt/stsconfig'
|
|
13
15
|
const goptions = $Options()
|
|
14
16
|
|
|
@@ -69,7 +71,7 @@ export class IMKafkaManager {
|
|
|
69
71
|
}
|
|
70
72
|
}
|
|
71
73
|
} catch (error) {
|
|
72
|
-
console.error(`${_logPrefix}#Terminate: Error: [${error}]
|
|
74
|
+
console.error(chalk.red(`${_logPrefix}#Terminate: Error: [${error}]`));
|
|
73
75
|
}
|
|
74
76
|
}
|
|
75
77
|
|
|
@@ -145,7 +147,7 @@ export class IMKafkaManager {
|
|
|
145
147
|
}
|
|
146
148
|
return true;
|
|
147
149
|
} catch (error: any) {
|
|
148
|
-
console.error(`${_logPrefix}OutputLogs: Could not output log data to kafka: [${error}]
|
|
150
|
+
console.error(chalk.red(`${_logPrefix}OutputLogs: Could not output log data to kafka: [${error}]`));
|
|
149
151
|
return false;
|
|
150
152
|
}
|
|
151
153
|
}
|
|
@@ -56,6 +56,8 @@ import { KafkaManager } from './../kafka/kafkamanager'
|
|
|
56
56
|
|
|
57
57
|
import 'colors'
|
|
58
58
|
|
|
59
|
+
import chalk from 'chalk';
|
|
60
|
+
|
|
59
61
|
async function Sleep(milliseconds = 1000) {
|
|
60
62
|
return new Promise(resolve => setTimeout(resolve, milliseconds))
|
|
61
63
|
}
|
|
@@ -92,7 +94,7 @@ const runme = async () => {
|
|
|
92
94
|
for (let i=0; i < count; i++) {
|
|
93
95
|
if (i % 100 === 0) console.log(i);
|
|
94
96
|
const retVal = await producer.SendMessages(TOPIC, [
|
|
95
|
-
{ key: 'key1', value: `hello world - ${i}
|
|
97
|
+
{ key: 'key1', value: chalk.green(`hello world - ${i}`) },
|
|
96
98
|
{ key: 'key2', value: 'hey hey! -2' },
|
|
97
99
|
{ key: 'key3', value: 'hey hey! -3' },
|
|
98
100
|
{ key: 'key4', value: 'hey hey! -4' },
|
package/src/tcpclient/app2.ts
CHANGED
|
@@ -48,9 +48,9 @@ socket2.on('secureConnect', () => {
|
|
|
48
48
|
dosomework(socket2);
|
|
49
49
|
});
|
|
50
50
|
socket2.on('close', function(data: any) {
|
|
51
|
-
console.log(`CLOSED: ${socket2.remoteAddress} ${socket2.remotePort}
|
|
51
|
+
console.log(chalk.green(`CLOSED: ${socket2.remoteAddress} ${socket2.remotePort}`));
|
|
52
52
|
});
|
|
53
53
|
socket2.on('data', function(data: any) {
|
|
54
|
-
console.log(`DATA ${socket2.remoteAddress} ${socket2.remotePort} ${data}
|
|
54
|
+
console.log(chalk.green(`DATA ${socket2.remoteAddress} ${socket2.remotePort} ${data}`));
|
|
55
55
|
});
|
|
56
56
|
*/
|
|
@@ -9,6 +9,8 @@ import { JSONObject } from '@nsshunt/stsutils';
|
|
|
9
9
|
import { MasterProcessBase } from './../masterprocessbase'
|
|
10
10
|
import { ProcessOptions } from './../processoptions'
|
|
11
11
|
|
|
12
|
+
import chalk from 'chalk';
|
|
13
|
+
|
|
12
14
|
// Colour codes
|
|
13
15
|
// ---------------------------------
|
|
14
16
|
// Red - Error
|
|
@@ -122,7 +124,7 @@ export class AppMaster extends MasterProcessBase
|
|
|
122
124
|
// Update my currentTerm
|
|
123
125
|
this.#currentTerm = term;
|
|
124
126
|
// Return my yes vote
|
|
125
|
-
console.log(`${message} - Vote Yes
|
|
127
|
+
console.log(chalk.green(`${message} - Vote Yes`));
|
|
126
128
|
callback(null, true); // YES vote
|
|
127
129
|
}
|
|
128
130
|
|
|
@@ -130,7 +132,7 @@ export class AppMaster extends MasterProcessBase
|
|
|
130
132
|
// Log the fact that I have now voted for this currentTerm
|
|
131
133
|
this.#votedLog[term] = true;
|
|
132
134
|
// Return my yes vote
|
|
133
|
-
console.log(`${message} - Vote No
|
|
135
|
+
console.log(chalk.yellow(`${message} - Vote No`));
|
|
134
136
|
callback(null, false); // NO vote
|
|
135
137
|
}
|
|
136
138
|
|
|
@@ -229,19 +231,19 @@ export class AppMaster extends MasterProcessBase
|
|
|
229
231
|
const retVal = this.#CheckMoreRecentTerm(term, lastLogItemTerm, lastLogItemIndex);
|
|
230
232
|
if (retVal.retVal === true) {
|
|
231
233
|
console.log(`${retVal.msg}`);
|
|
232
|
-
console.log(`${this.#GetLogPrefix()}: New leader detected, Host: [${host}], Port: [${port}], while in CANDIDATE mode, reverting to FOLLOWER
|
|
234
|
+
console.log(chalk.magenta(`${this.#GetLogPrefix()}: New leader detected, Host: [${host}], Port: [${port}], while in CANDIDATE mode, reverting to FOLLOWER.`));
|
|
233
235
|
// This sending node is the leader so revert to follower
|
|
234
236
|
this.#currentTerm = term;
|
|
235
237
|
this.#ChangeState(AppMasterRAFTState.FOLLOWER);
|
|
236
238
|
} else {
|
|
237
239
|
console.log(`${retVal.msg}`);
|
|
238
|
-
console.log(`${this.#GetLogPrefix()}: appendEntry called but log is older than my current state, Host: [${host}], Port: [${port}]
|
|
240
|
+
console.log(chalk.magenta(`${this.#GetLogPrefix()}: appendEntry called but log is older than my current state, Host: [${host}], Port: [${port}].`));
|
|
239
241
|
// Reject this RPC and continue in the CANDIDATE state
|
|
240
242
|
callback(null, false);
|
|
241
243
|
return;
|
|
242
244
|
}
|
|
243
245
|
} else if (this.#RAFTState.localeCompare(AppMasterRAFTState.LEADER) === 0) {
|
|
244
|
-
console.log(`${this.#GetLogPrefix()}: appendEntry called while I am the current leader, rejecting RPC call
|
|
246
|
+
console.log(chalk.red(`${this.#GetLogPrefix()}: appendEntry called while I am the current leader, rejecting RPC call.`));
|
|
245
247
|
// Reject this RPC and continue in the LEADER state
|
|
246
248
|
callback(null, false);
|
|
247
249
|
return;
|
|
@@ -258,7 +260,7 @@ export class AppMaster extends MasterProcessBase
|
|
|
258
260
|
}
|
|
259
261
|
} else {
|
|
260
262
|
console.log(`${retVal.msg}`);
|
|
261
|
-
console.log(`${this.#GetLogPrefix()}: appendEntry called but log is older than my current state, Host: [${host}], Port: [${port}]
|
|
263
|
+
console.log(chalk.magenta(`${this.#GetLogPrefix()}: appendEntry called but log is older than my current state, Host: [${host}], Port: [${port}].`));
|
|
262
264
|
// Reject this RPC and continue in the CANDIDATE state
|
|
263
265
|
callback(null, false);
|
|
264
266
|
return;
|
|
@@ -270,13 +272,13 @@ export class AppMaster extends MasterProcessBase
|
|
|
270
272
|
if (sentLeaderService) {
|
|
271
273
|
if (sentLeaderService.host.localeCompare(this.#leaderNode.host) !== 0 || sentLeaderService.port !== this.#leaderNode.port) {
|
|
272
274
|
this.#leaderNode = sentLeaderService;
|
|
273
|
-
console.log(`${this.#GetLogPrefix()}: Leader Service: Host:[${this.#leaderNode.host}] Port: [${this.#leaderNode.port}]
|
|
275
|
+
console.log(chalk.white(`${this.#GetLogPrefix()}: Leader Service: Host:[${this.#leaderNode.host}] Port: [${this.#leaderNode.port}]`));
|
|
274
276
|
}
|
|
275
277
|
}
|
|
276
278
|
} else {
|
|
277
279
|
this.#leaderNode = this.#FindService(host, port);
|
|
278
280
|
if (this.#leaderNode) {
|
|
279
|
-
console.log(`${this.#GetLogPrefix()}: Leader Service: Host:[${this.#leaderNode.host}] Port: [${this.#leaderNode.port}]
|
|
281
|
+
console.log(chalk.white(`${this.#GetLogPrefix()}: Leader Service: Host:[${this.#leaderNode.host}] Port: [${this.#leaderNode.port}]`));
|
|
280
282
|
}
|
|
281
283
|
}
|
|
282
284
|
|
|
@@ -309,18 +311,6 @@ export class AppMaster extends MasterProcessBase
|
|
|
309
311
|
};
|
|
310
312
|
|
|
311
313
|
const client = jayson.client.tls(options);
|
|
312
|
-
/*
|
|
313
|
-
client.on('tcp socket', (socket: tls.TLSSocket) => {
|
|
314
|
-
socket.setTimeout(200); //@@ config
|
|
315
|
-
socket.on('timeout', () => {
|
|
316
|
-
console.log('socket timeout');
|
|
317
|
-
socket.end();
|
|
318
|
-
});
|
|
319
|
-
});
|
|
320
|
-
client.on('tcp error', (error: any) => {
|
|
321
|
-
console.log(`ERROR: [${error}]`.red);
|
|
322
|
-
});
|
|
323
|
-
*/
|
|
324
314
|
|
|
325
315
|
let lastLogItem: ILogItem;
|
|
326
316
|
if (this.#log.length > 0) {
|
|
@@ -335,7 +325,7 @@ export class AppMaster extends MasterProcessBase
|
|
|
335
325
|
|
|
336
326
|
client.request('vote', [ this.#currentTerm, lastLogItem.term, lastLogItem.index ], (error: any, response: any) => {
|
|
337
327
|
if (error) {
|
|
338
|
-
//console.log(`vote attempt fail: [${JSON.stringify(options)}: ${error}]
|
|
328
|
+
//console.log(chalk.red(`vote attempt fail: [${JSON.stringify(options)}: ${error}]`));
|
|
339
329
|
} else {
|
|
340
330
|
// Log the result
|
|
341
331
|
if (response.result === true) {
|
|
@@ -353,18 +343,6 @@ export class AppMaster extends MasterProcessBase
|
|
|
353
343
|
};
|
|
354
344
|
|
|
355
345
|
const client = jayson.client.tls(options);
|
|
356
|
-
/*
|
|
357
|
-
client.on('tcp socket', (socket: tls.TLSSocket) => {
|
|
358
|
-
socket.setTimeout(200); //@@ config
|
|
359
|
-
socket.on('timeout', () => {
|
|
360
|
-
console.log('socket timeout');
|
|
361
|
-
socket.end();
|
|
362
|
-
});
|
|
363
|
-
});
|
|
364
|
-
client.on('tcp error', (error: any) => {
|
|
365
|
-
console.log(`ERROR: [${error}]`.red);
|
|
366
|
-
});
|
|
367
|
-
*/
|
|
368
346
|
|
|
369
347
|
let lastLogItem: ILogItem;
|
|
370
348
|
if (this.#log.length > 0) {
|
|
@@ -379,7 +357,7 @@ export class AppMaster extends MasterProcessBase
|
|
|
379
357
|
|
|
380
358
|
client.request('appendEntry', [ this.#thisService.host, this.#thisService.port, this.#currentTerm, lastLogItem.term, lastLogItem.index ], (error: any, response: any) => {
|
|
381
359
|
if (error) {
|
|
382
|
-
//console.log(`appendEntry attempt fail: [${JSON.stringify(options)}: ${error}]
|
|
360
|
+
//console.log(chalk.red(`appendEntry attempt fail: [${JSON.stringify(options)}: ${error}]`));
|
|
383
361
|
} else {
|
|
384
362
|
this.#appendedEntries[this.#GetServiceKey(service)] = 1;
|
|
385
363
|
// Log the result
|
|
@@ -431,14 +409,14 @@ export class AppMaster extends MasterProcessBase
|
|
|
431
409
|
if (majority) {
|
|
432
410
|
this.#StartAppendEntries();
|
|
433
411
|
} else {
|
|
434
|
-
console.log(`${this.#GetLogPrefix()}: Not enough response for valid cluster state
|
|
412
|
+
console.log(chalk.red(`${this.#GetLogPrefix()}: Not enough response for valid cluster state.`));
|
|
435
413
|
}
|
|
436
414
|
}, this.#heartBeatTimeout);
|
|
437
415
|
}
|
|
438
416
|
|
|
439
417
|
#Promote = () => {
|
|
440
418
|
this.#ChangeState(AppMasterRAFTState.LEADER);
|
|
441
|
-
console.log(`${this.#GetLogPrefix()}: New LEADER is elected: [${this.#GetSelfServiceKey()}]
|
|
419
|
+
console.log(chalk.green(`${this.#GetLogPrefix()}: New LEADER is elected: [${this.#GetSelfServiceKey()}]`));
|
|
442
420
|
// As leader, now start the regular pings
|
|
443
421
|
this.#StartAppendEntries();
|
|
444
422
|
}
|
|
@@ -492,7 +470,7 @@ export class AppMaster extends MasterProcessBase
|
|
|
492
470
|
// Log the result - Vote for myself
|
|
493
471
|
this.#votes[this.#GetSelfServiceKey()] = 1;
|
|
494
472
|
// Return my yes vote
|
|
495
|
-
console.log(`${this.#GetLogPrefix()}: SELF VOTE: canidate currentTerm: [${this.#currentTerm}], vote YES
|
|
473
|
+
console.log(chalk.green(`${this.#GetLogPrefix()}: SELF VOTE: canidate currentTerm: [${this.#currentTerm}], vote YES`));
|
|
496
474
|
this.#CheckMajority();
|
|
497
475
|
} else {
|
|
498
476
|
// Send vote request
|
|
@@ -526,13 +504,13 @@ export class AppMaster extends MasterProcessBase
|
|
|
526
504
|
}
|
|
527
505
|
|
|
528
506
|
#StartRAFTService = async () => {
|
|
529
|
-
this.LogEx(`---[ RAFT Protocol Starting ]
|
|
507
|
+
this.LogEx(chalk.green(`---[ RAFT Protocol Starting ]---`));
|
|
530
508
|
this.#server = await this.#SetupJSONRPCServer();
|
|
531
509
|
this.#StartElectionTimeout();
|
|
532
510
|
}
|
|
533
511
|
|
|
534
512
|
#ChangeState(newState: AppMasterRAFTState) {
|
|
535
|
-
this.LogEx(`${this.#GetLogPrefix()}: State Change, From: [${this.#RAFTState.toString()}] --> To: [${newState.toString()}]
|
|
513
|
+
this.LogEx(chalk.magenta(`${this.#GetLogPrefix()}: State Change, From: [${this.#RAFTState.toString()}] --> To: [${newState.toString()}]`));
|
|
536
514
|
this.#RAFTState = newState;
|
|
537
515
|
}
|
|
538
516
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/* eslint @typescript-eslint/no-explicit-any: 0 */ // --> OFF
|
|
2
2
|
import cluster from 'node:cluster';
|
|
3
3
|
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
|
|
4
6
|
import { WorkerProcessBase, STSNamespace, STSRoom, SocketIoServerHelper, STSSocketIONamespace } from './../index'
|
|
5
7
|
|
|
6
8
|
//import { Socket, Namespace } from "socket.io";
|
|
@@ -61,7 +63,7 @@ export class WorkerProcess extends WorkerProcessBase
|
|
|
61
63
|
|
|
62
64
|
if (cluster.worker && cluster.worker.id !== workerId) {
|
|
63
65
|
// Invalid data - this workerId must match
|
|
64
|
-
console.log(`WorkerProcess.ReceivedMessageFromMaster: Invalid workerId: [${workerId}]. Should have been: [${cluster.worker.id}]
|
|
66
|
+
console.log(chalk.red(`WorkerProcess.ReceivedMessageFromMaster: Invalid workerId: [${workerId}]. Should have been: [${cluster.worker.id}].`));
|
|
65
67
|
} else {
|
|
66
68
|
const workerProcess: WorkerProcess = this as WorkerProcess;
|
|
67
69
|
if (workerProcess.stsMonitorNamespace !== null) {
|
|
@@ -69,16 +71,16 @@ export class WorkerProcess extends WorkerProcessBase
|
|
|
69
71
|
const sockets = await stsMonitorNamespace.fetchSockets();
|
|
70
72
|
for (const socket of sockets) {
|
|
71
73
|
if (socket.id.localeCompare(socketId) === 0) {
|
|
72
|
-
console.log(`WorkerProcess.ReceivedMessageFromMaster: Sending payload to subscribed client
|
|
74
|
+
console.log(chalk.green(`WorkerProcess.ReceivedMessageFromMaster: Sending payload to subscribed client.`));
|
|
73
75
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
74
76
|
//socket.emit(STSEvent.STSSubInstrumentData as any, model);
|
|
75
77
|
return;
|
|
76
78
|
}
|
|
77
79
|
}
|
|
78
|
-
console.log(`WorkerProcess.ReceivedMessageFromMaster: Invalid socketId. Expecting socket to existing in socket namespace collection
|
|
80
|
+
console.log(chalk.red(`WorkerProcess.ReceivedMessageFromMaster: Invalid socketId. Expecting socket to existing in socket namespace collection.`));
|
|
79
81
|
// Invalid - could not find matching socketid to send to
|
|
80
82
|
} else {
|
|
81
|
-
console.log(`WorkerProcess.ReceivedMessageFromMaster: Invalid workerProcess.stsMonitorNamespace is null. Expecting non-null value
|
|
83
|
+
console.log(chalk.red(`WorkerProcess.ReceivedMessageFromMaster: Invalid workerProcess.stsMonitorNamespace is null. Expecting non-null value.`));
|
|
82
84
|
}
|
|
83
85
|
}
|
|
84
86
|
}
|
|
@@ -98,12 +100,12 @@ export class WorkerProcess extends WorkerProcessBase
|
|
|
98
100
|
console.log(`WorkerProcess.#SendIPCMessageToMaster`.grey);
|
|
99
101
|
(process as any).send( { command: eventName, payload }, null, { swallowErrors: true }, (error: any) => {
|
|
100
102
|
if (error) {
|
|
101
|
-
console.error(`Error with WorkerProcess:SendIPCMessageToMaster(1): [${error}]
|
|
103
|
+
console.error(chalk.red(`Error with WorkerProcess:SendIPCMessageToMaster(1): [${error}]`));
|
|
102
104
|
}
|
|
103
105
|
});
|
|
104
106
|
}
|
|
105
107
|
} catch (error) {
|
|
106
|
-
console.error(`Error with WorkerProcess:SendIPCMessageToMaster(2): [${error}]
|
|
108
|
+
console.error(chalk.red(`Error with WorkerProcess:SendIPCMessageToMaster(2): [${error}]`));
|
|
107
109
|
}
|
|
108
110
|
}
|
|
109
111
|
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import debugModule from 'debug'
|
|
3
3
|
const debug = debugModule(`proc:${process.pid}:singleservertest.test`);
|
|
4
4
|
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
|
|
5
7
|
import axios, { AxiosError, AxiosResponse } from 'axios';
|
|
6
8
|
|
|
7
9
|
import { Sleep } from '@nsshunt/stsutils'
|
|
@@ -64,26 +66,26 @@ describe("Single Server Test", () =>
|
|
|
64
66
|
`${endpoint}:${goptions.rest01port}/${STSNamespace.STSMonitor}/`;
|
|
65
67
|
|
|
66
68
|
const HandleError = (error: any) => {
|
|
67
|
-
debug(`Error: [${error}]
|
|
69
|
+
debug(chalk.red(`Error: [${error}]`));
|
|
68
70
|
if (axios.isAxiosError(error)) {
|
|
69
71
|
const axiosError: AxiosError = error;
|
|
70
72
|
if (axiosError.response) {
|
|
71
|
-
debug(`AXIOS Error Response.Status = [${axiosError.response.status}]
|
|
73
|
+
debug(chalk.red(`AXIOS Error Response.Status = [${axiosError.response.status}]`));
|
|
72
74
|
if (axiosError.response.headers) {
|
|
73
|
-
console.log(` headers: [${JSON.stringify(axiosError.response.headers)}]
|
|
75
|
+
console.log(chalk.red(` headers: [${JSON.stringify(axiosError.response.headers)}]`));
|
|
74
76
|
}
|
|
75
77
|
if (axiosError.response.data) {
|
|
76
|
-
console.log(` data: [${JSON.stringify(axiosError.response.data)}]
|
|
78
|
+
console.log(chalk.red(` data: [${JSON.stringify(axiosError.response.data)}]`));
|
|
77
79
|
}
|
|
78
80
|
try {
|
|
79
81
|
if (axiosError.response.config) {
|
|
80
|
-
console.log(` config: [${JSON.stringify(axiosError.response.config)}]
|
|
82
|
+
console.log(chalk.red(` config: [${JSON.stringify(axiosError.response.config)}]`));
|
|
81
83
|
}
|
|
82
84
|
} catch (innererror: any) {
|
|
83
|
-
console.log(` could not get response config, error: [${innererror}]
|
|
85
|
+
console.log(chalk.red(` could not get response config, error: [${innererror}]`));
|
|
84
86
|
}
|
|
85
87
|
} else {
|
|
86
|
-
debug(`AXIOS Error = [${axiosError}]
|
|
88
|
+
debug(chalk.red(`HandleError(): AXIOS Error = [${axiosError}]`));
|
|
87
89
|
}
|
|
88
90
|
}
|
|
89
91
|
}
|
|
@@ -268,7 +270,7 @@ describe("Single Server Test", () =>
|
|
|
268
270
|
instrumentManagerAddress,
|
|
269
271
|
// Connected call back
|
|
270
272
|
(socket: Socket<ServerToClientEvents, ClientToServerEvents>) => {
|
|
271
|
-
debug(`connected - 1
|
|
273
|
+
debug(chalk.green(`connected - 1`));
|
|
272
274
|
expect(1).toEqual(1);
|
|
273
275
|
},
|
|
274
276
|
// Custom Events
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"influxDBManager.d.ts","sourceRoot":"","sources":["../../src/influxdb/influxDBManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,QAAQ,EAAgD,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"influxDBManager.d.ts","sourceRoot":"","sources":["../../src/influxdb/influxDBManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,QAAQ,EAAgD,MAAM,6BAA6B,CAAA;AAQ9G,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAI9C,OAAO,EAAE,sBAAsB,EAAC,MAAM,0BAA0B,CAAA;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAA2B,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AA0L7E,qBAAa,eAAe;;;IAyFxB,2BAA2B,CAAC,SAAS,EAAE,MAAM;IAa7C,IAAI,cAAc,IAAI,sBAAsB,CAE3C;IAED,IAAI,YAAY,IAAI,oBAAoB,CAEvC;IAED,KAAK,sBAEJ;IAED,SAAS,sBA2BR;IAQD,sBAAsB,aAAc,GAAG,EAAE,SAUxC;IAGD,kBAAkB,CAAC,eAAe,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,UAAU;IAW9E,IAAI,WAAW,IAAI,QAAQ,CAsG1B;IAIK,cAAc,CAAC,iBAAiB,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC;CAe/E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"influxDBManagerAgent.d.ts","sourceRoot":"","sources":["../../src/influxdb/influxDBManagerAgent.ts"],"names":[],"mappings":";AAkGA,OAAO,EAAS,QAAQ,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAIvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAE3D,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAC7E,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"influxDBManagerAgent.d.ts","sourceRoot":"","sources":["../../src/influxdb/influxDBManagerAgent.ts"],"names":[],"mappings":";AAkGA,OAAO,EAAS,QAAQ,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAIvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAE3D,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAC7E,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAWpF,qBAAa,oBAAqB,SAAQ,mBAAmB;;gBAE7C,OAAO,EAAE,uBAAuB,EAAE,QAAQ,EAAE,QAAQ;IAIhE,IAAa,SAAS,IAAI,MAAM,CAE/B;IAqEK,2BAA2B,CAAC,eAAe,EAAE,gBAAgB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAkB7F,uBAAuB,CAAC,eAAe,EAAE,gBAAgB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAkBzF,8BAA8B,CAAC,eAAe,EAAE,gBAAgB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAmBhG,6BAA6B,CAAC,eAAe,EAAE,gBAAgB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAsB/F,cAAc,CAAC,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC;CA6CnG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"influxDBManagerBase.d.ts","sourceRoot":"","sources":["../../src/influxdb/influxDBManagerBase.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAEhE,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAE7E,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"influxDBManagerBase.d.ts","sourceRoot":"","sources":["../../src/influxdb/influxDBManagerBase.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAEhE,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAE7E,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAM9C,qBAAa,mBAAmB;;gBAMhB,OAAO,EAAE,uBAAuB,EAAE,QAAQ,EAAE,QAAQ;IAKhE,IAAI,OAAO,4BAEV;IACD,IAAI,QAAQ,aAEX;IAED,IAAI,YAAY,IAGM,OAAO,CAD5B;IACD,IAAI,YAAY,CAAC,GAAG,EAAE,OAAO,EAE5B;IAED,IAAI,SAAS,IAAI,MAAM,CAEtB;IAGK,sBAAsB,CAAC,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE;IAuCxE,sBAAsB,aAAc,GAAG,EAAE,SAUxC;IAED,kBAAkB,CAAC,eAAe,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,UAAU;IAaxE,cAAc,CAAC,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC;CAGnG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"influxDBManagerService.d.ts","sourceRoot":"","sources":["../../src/influxdb/influxDBManagerService.ts"],"names":[],"mappings":";AA8GA,OAAO,EAAS,QAAQ,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAIvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAE3D,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAC7E,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"influxDBManagerService.d.ts","sourceRoot":"","sources":["../../src/influxdb/influxDBManagerService.ts"],"names":[],"mappings":";AA8GA,OAAO,EAAS,QAAQ,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAIvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAE3D,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAC7E,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAkBpF,qBAAa,sBAAuB,SAAQ,mBAAmB;;gBAE/C,OAAO,EAAE,uBAAuB,EAAE,QAAQ,EAAE,QAAQ;IAIhE,IAAa,SAAS,IAAI,MAAM,CAE/B;IA6FK,6BAA6B,CAAC,eAAe,EAAE,gBAAgB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAkB/F,yBAAyB,CAAC,eAAe,EAAE,gBAAgB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAmB3F,kCAAkC,CAAC,eAAe,EAAE,gBAAgB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAmBpG,iCAAiC,CAAC,eAAe,EAAE,gBAAgB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAqBnG,cAAc,CAAC,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC;CA6DnG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IMKafkaManager.d.ts","sourceRoot":"","sources":["../../src/kafka/IMKafkaManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAIpD,OAAO,EAAE,YAAY,EAAuB,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"IMKafkaManager.d.ts","sourceRoot":"","sources":["../../src/kafka/IMKafkaManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAIpD,OAAO,EAAE,YAAY,EAAuB,MAAM,gBAAgB,CAAA;AAclE,qBAAa,cAAc;;;IAiCvB,IAAI,EAAE,IAAI,YAAY,CAErB;IAED,KAAK,QAAa,QAAQ,IAAI,CAAC,CAG9B;IAED,SAAS,QAAa,QAAQ,IAAI,CAAC,CAclC;IAyBK,UAAU,CAAC,iBAAiB,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC;CAqD3E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appmaster.d.ts","sourceRoot":"","sources":["../../src/tcpserver/appmaster.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"appmaster.d.ts","sourceRoot":"","sources":["../../src/tcpserver/appmaster.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAapD,oBAAY,kBAAkB;IAC1B,IAAI,SAAS;IACb,QAAQ,aAAa;IACrB,SAAS,cAAc;IACvB,MAAM,WAAW;CACpB;AAED,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,QAAQ;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,UAAU,GAAG,IAAI,CAAA;CAC1B;AAED,qBAAa,SAAU,SAAQ,iBAAiB;;gBA0BhC,aAAa,EAAE,cAAc;IAkczC,aAAa,IAAI,IAAI;CAKxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appWorkerWSS.d.ts","sourceRoot":"","sources":["../../src/testing/appWorkerWSS.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"appWorkerWSS.d.ts","sourceRoot":"","sources":["../../src/testing/appWorkerWSS.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAA+C,oBAAoB,EAAE,MAAM,YAAY,CAAA;AASjH,oBAAY,0BAA0B;IACrC,OAAO,YAAY,CAAE,oCAAoC;IAEzD,SAAS,mCAAmC;IAC5C,WAAW,qCAAqC;IAChD,oBAAoB,6CAA6C;CACjE;AAED,MAAM,WAAW,iBAAiB;IACjC,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAEhB,IAAI,EAAE,GAAG,CAAA;CACT;AAED,oBAAY,2BAA2B;IACtC,mBAAmB,6CAA6C;CAChE;AAED,oBAAY,WAAW;IACtB,uBAAuB,4BAA4B;CACnD;AAED,qBAAa,aAAc,SAAQ,iBAAiB;;gBAIpC,OAAO,EAAE,GAAG;IAcxB,yBAAyB,gBAAuB,GAAG,mBAgClD;IAwBD,aAAa,IAAI,GAAG;IAkDpB,IAAI,mBAAmB,IAAI,oBAAoB,GAAG,IAAI,CAKrD;CACJ"}
|