Correcting version in files. And adapting internal name of cli-parameter
This commit is contained in:
parent
a4ed621237
commit
2f6f71eb8f
@ -260,7 +260,7 @@ Inital commit, which is working with the browser
|
||||
- `loadFunctions` in `lib\loader\loadPackages.ts` to match the interface of `loadPackages` and add the functions to the package-loader.
|
||||
- added the function `addDecoratedElements` in the package-loader and the interface.
|
||||
|
||||
# 1.4.1
|
||||
# 1.4.2
|
||||
- Fixes:
|
||||
- Fixing time based issue in `ConnectivityManager` (using the now synced time for checkups)
|
||||
- `dispatchers.ConnectivityManager.ConnectivityManager`: fixing `_checkDispatcherHealth`
|
||||
@ -273,7 +273,7 @@ Inital commit, which is working with the browser
|
||||
- throws error if `register` method doest not contain a topic.
|
||||
- Adapted the behavior of `_patternbasedPullData`. If no default default value is present -> the function returns an empty array.
|
||||
|
||||
# 1.4.2
|
||||
# 1.4.3
|
||||
- Fixes:
|
||||
- Fixing time based issue in `ConnectivityManager` (using the now synced time for checkups)
|
||||
- `dispatchers.ConnectivityManager.ConnectivityManager`: fixing `_checkDispatcherHealth`
|
||||
|
@ -1 +1 @@
|
||||
1.4.2
|
||||
1.4.3
|
@ -2,5 +2,6 @@ import { runNopeBackend } from "./runNopeBackend";
|
||||
|
||||
runNopeBackend({
|
||||
channel: "io-server",
|
||||
channelParams: JSON.stringify([7000, "info", true]),
|
||||
skipLoadingConfig: true,
|
||||
});
|
||||
|
@ -36,7 +36,7 @@ import { NOPELOGO } from "./renderNope";
|
||||
export interface RunArgs {
|
||||
file: string;
|
||||
channel: validLayerOrMirror;
|
||||
params: string;
|
||||
channelParams: string;
|
||||
// Flag to prevent loading the configuration
|
||||
skipLoadingConfig: boolean;
|
||||
// Level of the logger.
|
||||
@ -71,7 +71,7 @@ export const DEFAULT_SETTINGS: RunArgs = {
|
||||
file: "./config/settings.json",
|
||||
channel: "event",
|
||||
skipLoadingConfig: false,
|
||||
params: "not-provided",
|
||||
channelParams: "not-provided",
|
||||
log: "debug",
|
||||
singleton: true,
|
||||
dispatcherLogLevel: "info",
|
||||
@ -137,13 +137,13 @@ export async function readInArgs(
|
||||
dest: "channel",
|
||||
});
|
||||
|
||||
parser.add_argument("-p", "--params", {
|
||||
parser.add_argument("-p", "--channelParams", {
|
||||
help:
|
||||
"Paramas for the Channel, to connect to. The Following Defaults are used: \n" +
|
||||
JSON.stringify(layerDefaultParameters, undefined, 4),
|
||||
default: "not-provided",
|
||||
type: "str",
|
||||
dest: "params",
|
||||
dest: "channelParams",
|
||||
});
|
||||
|
||||
parser.add_argument("-s", "--skip-loading-config", {
|
||||
@ -248,8 +248,8 @@ export async function readInArgs(
|
||||
|
||||
const args: RunArgs = parser.parse_args();
|
||||
|
||||
if (args.params === "not-provided") {
|
||||
delete args.params;
|
||||
if (args.channelParams === "not-provided") {
|
||||
delete args.channelParams;
|
||||
}
|
||||
|
||||
args.skipLoadingConfig = Array.isArray(args.skipLoadingConfig);
|
||||
@ -385,19 +385,19 @@ export async function runNopeBackend(
|
||||
// Assign the Default Setting for the Channel.
|
||||
opts.params = layerDefaultParameters[args.channel];
|
||||
|
||||
if (args.params != "not-provided") {
|
||||
if (args.channelParams != "not-provided") {
|
||||
try {
|
||||
try {
|
||||
// We try to parse the data.
|
||||
opts.params = JSON.parse(args.params);
|
||||
opts.params = JSON.parse(args.channelParams);
|
||||
} catch (e) {
|
||||
opts.params = JSON.parse('"' + args.params + '"');
|
||||
opts.params = JSON.parse('"' + args.channelParams + '"');
|
||||
}
|
||||
} catch (e) {
|
||||
logger.error(
|
||||
"Unable to parse the Parameters for the channel. Please use valid JSON!"
|
||||
);
|
||||
logger.error(args.params[0]);
|
||||
logger.error(args.channelParams[0]);
|
||||
logger.error(e);
|
||||
throw e;
|
||||
}
|
||||
|
@ -11,8 +11,8 @@ import {
|
||||
defineNopeLogger,
|
||||
ValidLoggerDefinition,
|
||||
} from "../../logger/getLogger";
|
||||
import { DEBUG, INFO } from "../../logger/index.browser";
|
||||
import { Eventnames } from "../../types/nope";
|
||||
import { DEBUG, ILogger, INFO } from "../../logger/index.browser";
|
||||
import { Eventnames, IRpcResponseMsg, IRequestRpcMsg } from "../../types/nope";
|
||||
import { EventCommunicationInterface } from "./EventCommunicationInterface";
|
||||
|
||||
/**
|
||||
@ -23,6 +23,8 @@ import { EventCommunicationInterface } from "./EventCommunicationInterface";
|
||||
*/
|
||||
export class ioSocketServerLayer extends EventCommunicationInterface {
|
||||
protected _sockets: Set<io.Socket>;
|
||||
protected _openRequests: { [index: string]: number } = {};
|
||||
protected _profile: boolean;
|
||||
|
||||
/**
|
||||
* Creates an instance of IoSocketMirrorServer.
|
||||
@ -31,7 +33,11 @@ export class ioSocketServerLayer extends EventCommunicationInterface {
|
||||
* @param {ValidLoggerDefinition} [logger="info"]
|
||||
* @memberof IoSocketMirrorServer
|
||||
*/
|
||||
constructor(public port: number, logger: ValidLoggerDefinition = "info") {
|
||||
constructor(
|
||||
public port: number,
|
||||
logger: ValidLoggerDefinition = "info",
|
||||
profile = false
|
||||
) {
|
||||
super(
|
||||
// As event Emitter, we provide the IO-Client.
|
||||
(io as any)({
|
||||
@ -44,6 +50,9 @@ export class ioSocketServerLayer extends EventCommunicationInterface {
|
||||
);
|
||||
const _this = this;
|
||||
|
||||
// Store, whether we want to profile our data or not.
|
||||
this._profile = profile;
|
||||
|
||||
// Tell the Server to listen.
|
||||
(this._emitter as any).listen(port);
|
||||
|
||||
@ -68,6 +77,14 @@ export class ioSocketServerLayer extends EventCommunicationInterface {
|
||||
// are forwarding the data.
|
||||
for (const event of Eventnames) {
|
||||
client.on(event, (data) => {
|
||||
if (_this._profile) {
|
||||
if (event == "rpcRequest") {
|
||||
_this._profileTask("add", data.taskId);
|
||||
} else if (event == "rpcResponse") {
|
||||
_this._profileTask("remove", data.taskId);
|
||||
}
|
||||
}
|
||||
|
||||
if (event !== "statusChanged" && _this._logger?.enabledFor(DEBUG)) {
|
||||
_this._logger.debug(
|
||||
"forwarding",
|
||||
@ -97,6 +114,29 @@ export class ioSocketServerLayer extends EventCommunicationInterface {
|
||||
this._sockets = new Set();
|
||||
}
|
||||
|
||||
protected _profileTask(
|
||||
mode: "add" | "remove",
|
||||
data: IRequestRpcMsg | IRpcResponseMsg
|
||||
) {
|
||||
try {
|
||||
if (mode == "add") {
|
||||
this._openRequests[data.taskId] = Date.now();
|
||||
} else {
|
||||
if (this._openRequests[data.taskId] !== undefined) {
|
||||
const start = this._openRequests[data.taskId];
|
||||
const end = Date.now();
|
||||
const delta = Math.round((end - start) * 100) / 100;
|
||||
|
||||
this._logger.info(`The execution of the task took ${delta} [ms]!`);
|
||||
|
||||
delete this._openRequests[data.taskId];
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
logger.error(`Failed in 'profileTask' mode=${mode}, data=${data}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper Function, to forward events to the other connected Sockets.
|
||||
*
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "nope",
|
||||
"version": "1.4.2",
|
||||
"version": "1.4.3",
|
||||
"description": "NoPE Runtime for Nodejs. For Browser-Support please use nope-browser",
|
||||
"files": [
|
||||
"dist-nodejs/**/*",
|
||||
|
Loading…
Reference in New Issue
Block a user