@nsshunt/stsappframework 2.19.154 → 2.19.155
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/commonTypes.ts +97 -5
- package/dist/commonTypes.js +38 -1
- package/dist/commonTypes.js.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/masterprocessbase.js +0 -6
- package/dist/masterprocessbase.js.map +1 -1
- package/dist/processbase.js +36 -21
- package/dist/processbase.js.map +1 -1
- package/dist/singleprocessbase.js +1 -2
- package/dist/singleprocessbase.js.map +1 -1
- package/dist/socketioHelper.js +15 -51
- package/dist/socketioHelper.js.map +1 -1
- package/dist/workerprocessbase.js +1 -1
- package/dist/workerprocessbase.js.map +1 -1
- package/index.ts +0 -1
- package/masterprocessbase.ts +0 -7
- package/package.json +2 -1
- package/processbase.ts +50 -23
- package/singleprocessbase.ts +3 -5
- package/socketioHelper.ts +13 -87
- package/tsconfig.json +2 -1
- package/types/commonTypes.d.ts +74 -3
- package/types/commonTypes.d.ts.map +1 -1
- package/types/index.d.ts +0 -1
- package/types/index.d.ts.map +1 -1
- package/types/masterprocessbase.d.ts.map +1 -1
- package/types/processbase.d.ts +3 -4
- package/types/processbase.d.ts.map +1 -1
- package/types/singleprocessbase.d.ts +2 -1
- package/types/singleprocessbase.d.ts.map +1 -1
- package/types/socketioHelper.d.ts +5 -67
- package/types/socketioHelper.d.ts.map +1 -1
- package/types/workerprocessbase.d.ts.map +1 -1
- package/workerprocessbase.ts +2 -2
- package/dist/log.js +0 -43
- package/dist/log.js.map +0 -1
- package/log.ts +0 -45
- package/types/log.d.ts +0 -15
- package/types/log.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"singleprocessbase.d.ts","sourceRoot":"","sources":["../singleprocessbase.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"singleprocessbase.d.ts","sourceRoot":"","sources":["../singleprocessbase.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAA;AAInE,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAE3C,MAAM,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,KAAK,IAAI,CAAA;AAEtD,qBAAa,iBAAkB,SAAQ,WAAY,YAAW,kBAAkB;;IAa5E;;;OAGA;gBACY,OAAO,EAAE,cAAc;IAInC,IAAI,UAAU,QAGb;IAED,0BAA0B;IAQjB,wBAAwB,IAAI,qBAAqB;IAS1D;;;OAGA;IACS,eAAe;IAIxB,cAAc;IAId,IAAI,EAAE,QAEL;IAED,kBAAkB;IAIlB,IAAI,aAAa,qBAEhB;IAED,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IA6B/B,aAAa,sBAoOZ;IAEK,SAAS;CAKlB"}
|
|
@@ -1,75 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export
|
|
4
|
-
export interface ServerSocketEvent {
|
|
5
|
-
serverEventName: string;
|
|
6
|
-
serverEventCb: ServerEventCb;
|
|
7
|
-
}
|
|
8
|
-
export declare enum STSNamespace {
|
|
9
|
-
STSMonitor = "stsmonitor",
|
|
10
|
-
STSControl = "stscontrol"
|
|
11
|
-
}
|
|
12
|
-
export declare enum STSRoom {
|
|
13
|
-
STSInstrumentDataRoom = "stsinstrumentdataroom",
|
|
14
|
-
STSInstrumentDataSubscriptionRoom = "stsinstrumentdatasubscriptionroom",
|
|
15
|
-
STSRunnerRoom = "stsrunnerroom",
|
|
16
|
-
STSNodeRunnerRoom = "stsnoderunnerroom"
|
|
17
|
-
}
|
|
18
|
-
export declare enum STSEvent {
|
|
19
|
-
STSInstrumentData = "stsinstrumentdata",
|
|
20
|
-
STSSubInstrumentData = "stssubinstrumentdata",
|
|
21
|
-
STSResetInstrumentData = "stsresetinstrumentdata",
|
|
22
|
-
STSStartLoggingInstrumentData = "stsStartLoggingInstrumentData",
|
|
23
|
-
STSStopLoggingInstrumentData = "stsStopLoggingInstrumentData",
|
|
24
|
-
STSStart = "stsstart",
|
|
25
|
-
STSStop = "stsstop",
|
|
26
|
-
STSPause = "stspause",
|
|
27
|
-
STSResume = "stsresume",
|
|
28
|
-
STSTerminate = "ststerminate",
|
|
29
|
-
STSUpdateStaticConfig = "stsupdatestaticconfig",
|
|
30
|
-
STSUpdateDynamicConfig = "stsupdatedynamicconfig",
|
|
31
|
-
STSSendToRoom = "sendToRoom",
|
|
32
|
-
connect = "connect"
|
|
33
|
-
}
|
|
34
|
-
export interface STSClientToServerEvents {
|
|
35
|
-
joinRoom: (room: STSRoom) => void;
|
|
36
|
-
register: (message: string) => void;
|
|
37
|
-
disconnecting: (reason: string) => void;
|
|
38
|
-
disconnect: (reason: string) => void;
|
|
39
|
-
sendToRoom: (rooms: STSRoom[], payload: {
|
|
40
|
-
command: string;
|
|
41
|
-
payload: JSONObject;
|
|
42
|
-
}) => void;
|
|
43
|
-
}
|
|
44
|
-
export interface STSServerToClient {
|
|
45
|
-
goodbye: (message: string) => void;
|
|
46
|
-
hello: (message: string) => void;
|
|
47
|
-
registerEcho: (message: {
|
|
48
|
-
socketId: string;
|
|
49
|
-
message: string;
|
|
50
|
-
}) => void;
|
|
51
|
-
disconnect: (reason: string) => void;
|
|
52
|
-
connect: () => void;
|
|
53
|
-
connect_error: () => void;
|
|
54
|
-
start: () => void;
|
|
55
|
-
}
|
|
56
|
-
export interface InterServerEvents {
|
|
57
|
-
ping: () => void;
|
|
58
|
-
}
|
|
59
|
-
export interface STSSocketIONamespace {
|
|
60
|
-
name: string;
|
|
61
|
-
pid: number;
|
|
62
|
-
socketionamespace: Namespace<STSClientToServerEvents, STSServerToClient, InterServerEvents>;
|
|
63
|
-
}
|
|
64
|
-
export type STSServerSocket = Socket<STSClientToServerEvents, STSServerToClient, InterServerEvents>;
|
|
65
|
-
export type STSClientSocket = Socket<STSServerToClient, STSClientToServerEvents, InterServerEvents>;
|
|
66
|
-
export declare class SocketIoHelper {
|
|
1
|
+
import { Server } from "socket.io";
|
|
2
|
+
import { IProcessBase, STSSocketIONamespace, STSRoom, STSServerSocket, ServerSocketEvent, STSNamespace, ISocketIoHelper } from './commonTypes';
|
|
3
|
+
export declare class SocketIoHelper implements ISocketIoHelper {
|
|
67
4
|
#private;
|
|
5
|
+
constructor(stsApp: IProcessBase);
|
|
68
6
|
LogMessage: (namespace: STSSocketIONamespace, message: string) => void;
|
|
69
7
|
LeaveRoom: (namespace: STSSocketIONamespace, room: STSRoom) => void;
|
|
70
8
|
JoinRoom: (namespace: STSSocketIONamespace, socket: STSServerSocket, room: STSRoom) => void;
|
|
71
9
|
SetupNamespace: (io: Server, namespace: STSNamespace, rooms: STSRoom[], autoJoinRooms: boolean, serverSocketEvents: ServerSocketEvent[]) => STSSocketIONamespace;
|
|
72
|
-
GetNamespace(namespace:
|
|
10
|
+
GetNamespace: (namespace: string) => STSSocketIONamespace;
|
|
73
11
|
DisconnectSockets: () => void;
|
|
74
12
|
}
|
|
75
13
|
//# sourceMappingURL=socketioHelper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socketioHelper.d.ts","sourceRoot":"","sources":["../socketioHelper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"socketioHelper.d.ts","sourceRoot":"","sources":["../socketioHelper.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,OAAO,EAAE,eAAe,EACjE,iBAAiB,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAE3E,qBAAa,cAAe,YAAW,eAAe;;gBAItC,MAAM,EAAE,YAAY;IAMhC,UAAU,cAAe,oBAAoB,WAAW,MAAM,KAAG,IAAI,CAInE;IAEF,SAAS,cAAe,oBAAoB,QAAQ,OAAO,KAAG,IAAI,CAKhE;IAEF,QAAQ,cAAe,oBAAoB,UAAU,eAAe,QAAQ,OAAO,KAAG,IAAI,CAOxF;IA2DF,cAAc,OAAQ,MAAM,aAAa,YAAY,SAAS,OAAO,EAAE,iBAAiB,OAAO,sBAAsB,iBAAiB,EAAE,KAAG,oBAAoB,CAgE9J;IAED,YAAY,cAAe,MAAM,KAAG,oBAAoB,CAEvD;IAED,iBAAiB,QAAO,IAAI,CAM3B;CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workerprocessbase.d.ts","sourceRoot":"","sources":["../workerprocessbase.ts"],"names":[],"mappings":"AASA,OAAO,
|
|
1
|
+
{"version":3,"file":"workerprocessbase.d.ts","sourceRoot":"","sources":["../workerprocessbase.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,UAAU,EAAS,MAAM,mBAAmB,CAAA;AAErD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAU5C,OAAO,EAAiE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAGjH;;;;GAIG;AACH,qBAAa,iBAAkB,SAAQ,WAAY,YAAW,kBAAkB;;gBAQhE,OAAO,EAAE,cAAc;IAInC,IAAI,UAAU,QAEb;IAED,aAAa;IAKb,yBAAyB,CAAC,GAAG,EAAE,GAAG;IAIlC,0BAA0B;IAS1B,IAAI,EAAE,QAEL;IAiCD,SAAS,YAAmB,GAAG,KAAG,QAAQ,MAAM,CAAC,CAUhD;IAGD,YAAY,aAAoB,MAAM,WAAW,GAAG,KAAG,QAAQ,UAAU,CAAC,CAWzE;IAED,kBAAkB;IAkDlB,IAAI,aAAa,QAEhB;IAED,WAAW,sBAMV;IAED,aAAa,sBA2NX;CACL"}
|
package/workerprocessbase.ts
CHANGED
|
@@ -7,7 +7,7 @@ import colors from 'colors'
|
|
|
7
7
|
import { createAdapter } from '@socket.io/cluster-adapter'
|
|
8
8
|
|
|
9
9
|
import { Gauge, InstrumentGaugeTelemetry } from '@nsshunt/stsinstrumentation'
|
|
10
|
-
import {
|
|
10
|
+
import { JSONObject, Sleep } from '@nsshunt/stsutils'
|
|
11
11
|
|
|
12
12
|
import { ProcessOptions } from './processoptions'
|
|
13
13
|
import { ProcessBase } from './processbase';
|
|
@@ -56,7 +56,7 @@ export class WorkerProcessBase extends ProcessBase implements IWorkerProcessBase
|
|
|
56
56
|
CollectAdditionalTelemetry() {
|
|
57
57
|
this.httpServer.getConnections((error, count) => {
|
|
58
58
|
//@@this.instruments[Gauge.CONNECTION_COUNT_GAUGE].val = count;
|
|
59
|
-
|
|
59
|
+
this.UpdateInstrument(Gauge.CONNECTION_COUNT_GAUGE, {
|
|
60
60
|
val: count
|
|
61
61
|
} as InstrumentGaugeTelemetry);
|
|
62
62
|
});
|
package/dist/log.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.log = void 0;
|
|
7
|
-
const stsinstrumentation_1 = require("@nsshunt/stsinstrumentation");
|
|
8
|
-
const stsutils_1 = require("@nsshunt/stsutils");
|
|
9
|
-
const cluster_1 = __importDefault(require("cluster"));
|
|
10
|
-
const colors_1 = __importDefault(require("colors"));
|
|
11
|
-
const debug_1 = __importDefault(require("debug"));
|
|
12
|
-
const debug = (0, debug_1.default)(`proc:${process.pid}:log`);
|
|
13
|
-
/**
|
|
14
|
-
* Default styles :-
|
|
15
|
-
* Worker messages - green
|
|
16
|
-
* Master messages - cyan + bold
|
|
17
|
-
* IPC Messages - grey. The message command itself will be bold.
|
|
18
|
-
* Signals - yellow (e.g. SIGINT or SIGTERM etc.)
|
|
19
|
-
* @param {*} appName Application Name
|
|
20
|
-
* @param {*} instruments Instrument collection
|
|
21
|
-
* @returns {function(msg):void} The returned function.
|
|
22
|
-
*/
|
|
23
|
-
function log(appName) {
|
|
24
|
-
return (msg) => {
|
|
25
|
-
let prefix = '';
|
|
26
|
-
let col = null;
|
|
27
|
-
if (cluster_1.default.isPrimary) {
|
|
28
|
-
prefix = 'M';
|
|
29
|
-
col = colors_1.default.bold.cyan;
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
prefix = 'W';
|
|
33
|
-
col = colors_1.default.green;
|
|
34
|
-
}
|
|
35
|
-
const msgEx = col(`${prefix}(${process.pid}) [${appName}]: ${msg}`);
|
|
36
|
-
debug(msgEx);
|
|
37
|
-
stsutils_1.$stsgd.app.UpdateInstrument(stsinstrumentation_1.Gauge.LOGGER, {
|
|
38
|
-
LogMessage: msgEx
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
exports.log = log;
|
|
43
|
-
//# sourceMappingURL=log.js.map
|
package/dist/log.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"log.js","sourceRoot":"","sources":["../log.ts"],"names":[],"mappings":";;;;;;AAAA,oEAA2E;AAC3E,gDAA0C;AAE1C,sDAA6B;AAC7B,oDAA2B;AAE3B,kDAA0B;AAC1B,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,QAAQ,OAAO,CAAC,GAAG,MAAM,CAAC,CAAA;AAM9C;;;;;;;;;GASG;AACH,SAAgB,GAAG,CAAC,OAAO;IACvB,OAAO,CAAC,GAAG,EAAE,EAAE;QAEX,IAAI,MAAM,GAAG,EAAE,CAAC;QAChB,IAAI,GAAG,GAAG,IAAI,CAAC;QAEf,IAAI,iBAAO,CAAC,SAAS,EACrB;YACI,MAAM,GAAG,GAAG,CAAC;YACb,GAAG,GAAG,gBAAM,CAAC,IAAI,CAAC,IAAI,CAAC;SAC1B;aAAM;YACH,MAAM,GAAG,GAAG,CAAC;YACb,GAAG,GAAG,gBAAM,CAAC,KAAK,CAAC;SACtB;QACD,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,MAAM,IAAI,OAAO,CAAC,GAAG,MAAM,OAAO,MAAM,GAAG,EAAE,CAAC,CAAC;QACpE,KAAK,CAAC,KAAK,CAAC,CAAC;QAEb,iBAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,0BAAK,CAAC,MAAM,EAAE;YACtC,UAAU,EAAE,KAAK;SACM,CAAC,CAAC;IACjC,CAAC,CAAC;AACN,CAAC;AArBD,kBAqBC"}
|
package/log.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { Gauge, InstrumentLogTelemetry } from '@nsshunt/stsinstrumentation'
|
|
2
|
-
import { $stsgd } from '@nsshunt/stsutils'
|
|
3
|
-
|
|
4
|
-
import cluster from 'cluster'
|
|
5
|
-
import colors from 'colors'
|
|
6
|
-
|
|
7
|
-
import Debug from "debug";
|
|
8
|
-
const debug = Debug(`proc:${process.pid}:log`)
|
|
9
|
-
|
|
10
|
-
export interface logFunction {
|
|
11
|
-
(msg): void
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Default styles :-
|
|
16
|
-
* Worker messages - green
|
|
17
|
-
* Master messages - cyan + bold
|
|
18
|
-
* IPC Messages - grey. The message command itself will be bold.
|
|
19
|
-
* Signals - yellow (e.g. SIGINT or SIGTERM etc.)
|
|
20
|
-
* @param {*} appName Application Name
|
|
21
|
-
* @param {*} instruments Instrument collection
|
|
22
|
-
* @returns {function(msg):void} The returned function.
|
|
23
|
-
*/
|
|
24
|
-
export function log(appName): logFunction {
|
|
25
|
-
return (msg) =>
|
|
26
|
-
{
|
|
27
|
-
let prefix = '';
|
|
28
|
-
let col = null;
|
|
29
|
-
|
|
30
|
-
if (cluster.isPrimary)
|
|
31
|
-
{
|
|
32
|
-
prefix = 'M';
|
|
33
|
-
col = colors.bold.cyan;
|
|
34
|
-
} else {
|
|
35
|
-
prefix = 'W';
|
|
36
|
-
col = colors.green;
|
|
37
|
-
}
|
|
38
|
-
const msgEx = col(`${prefix}(${process.pid}) [${appName}]: ${msg}`);
|
|
39
|
-
debug(msgEx);
|
|
40
|
-
|
|
41
|
-
$stsgd.app.UpdateInstrument(Gauge.LOGGER, {
|
|
42
|
-
LogMessage: msgEx
|
|
43
|
-
} as InstrumentLogTelemetry);
|
|
44
|
-
};
|
|
45
|
-
}
|
package/types/log.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export interface logFunction {
|
|
2
|
-
(msg: any): void;
|
|
3
|
-
}
|
|
4
|
-
/**
|
|
5
|
-
* Default styles :-
|
|
6
|
-
* Worker messages - green
|
|
7
|
-
* Master messages - cyan + bold
|
|
8
|
-
* IPC Messages - grey. The message command itself will be bold.
|
|
9
|
-
* Signals - yellow (e.g. SIGINT or SIGTERM etc.)
|
|
10
|
-
* @param {*} appName Application Name
|
|
11
|
-
* @param {*} instruments Instrument collection
|
|
12
|
-
* @returns {function(msg):void} The returned function.
|
|
13
|
-
*/
|
|
14
|
-
export declare function log(appName: any): logFunction;
|
|
15
|
-
//# sourceMappingURL=log.d.ts.map
|
package/types/log.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../log.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,WAAW;IAC3B,CAAC,GAAG,KAAA,GAAG,IAAI,CAAA;CACX;AAED;;;;;;;;;GASG;AACH,wBAAgB,GAAG,CAAC,OAAO,KAAA,GAAG,WAAW,CAqBxC"}
|