Correcting version in files. And adapting internal name of cli-parameter

This commit is contained in:
Martin Karkowski 2022-10-27 20:13:20 +02:00
parent a4ed621237
commit 2f6f71eb8f
6 changed files with 58 additions and 17 deletions

View File

@ -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. - `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. - added the function `addDecoratedElements` in the package-loader and the interface.
# 1.4.1 # 1.4.2
- Fixes: - Fixes:
- Fixing time based issue in `ConnectivityManager` (using the now synced time for checkups) - Fixing time based issue in `ConnectivityManager` (using the now synced time for checkups)
- `dispatchers.ConnectivityManager.ConnectivityManager`: fixing `_checkDispatcherHealth` - `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. - 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. - 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: - Fixes:
- Fixing time based issue in `ConnectivityManager` (using the now synced time for checkups) - Fixing time based issue in `ConnectivityManager` (using the now synced time for checkups)
- `dispatchers.ConnectivityManager.ConnectivityManager`: fixing `_checkDispatcherHealth` - `dispatchers.ConnectivityManager.ConnectivityManager`: fixing `_checkDispatcherHealth`

View File

@ -1 +1 @@
1.4.2 1.4.3

View File

@ -2,5 +2,6 @@ import { runNopeBackend } from "./runNopeBackend";
runNopeBackend({ runNopeBackend({
channel: "io-server", channel: "io-server",
channelParams: JSON.stringify([7000, "info", true]),
skipLoadingConfig: true, skipLoadingConfig: true,
}); });

View File

@ -36,7 +36,7 @@ import { NOPELOGO } from "./renderNope";
export interface RunArgs { export interface RunArgs {
file: string; file: string;
channel: validLayerOrMirror; channel: validLayerOrMirror;
params: string; channelParams: string;
// Flag to prevent loading the configuration // Flag to prevent loading the configuration
skipLoadingConfig: boolean; skipLoadingConfig: boolean;
// Level of the logger. // Level of the logger.
@ -71,7 +71,7 @@ export const DEFAULT_SETTINGS: RunArgs = {
file: "./config/settings.json", file: "./config/settings.json",
channel: "event", channel: "event",
skipLoadingConfig: false, skipLoadingConfig: false,
params: "not-provided", channelParams: "not-provided",
log: "debug", log: "debug",
singleton: true, singleton: true,
dispatcherLogLevel: "info", dispatcherLogLevel: "info",
@ -137,13 +137,13 @@ export async function readInArgs(
dest: "channel", dest: "channel",
}); });
parser.add_argument("-p", "--params", { parser.add_argument("-p", "--channelParams", {
help: help:
"Paramas for the Channel, to connect to. The Following Defaults are used: \n" + "Paramas for the Channel, to connect to. The Following Defaults are used: \n" +
JSON.stringify(layerDefaultParameters, undefined, 4), JSON.stringify(layerDefaultParameters, undefined, 4),
default: "not-provided", default: "not-provided",
type: "str", type: "str",
dest: "params", dest: "channelParams",
}); });
parser.add_argument("-s", "--skip-loading-config", { parser.add_argument("-s", "--skip-loading-config", {
@ -248,8 +248,8 @@ export async function readInArgs(
const args: RunArgs = parser.parse_args(); const args: RunArgs = parser.parse_args();
if (args.params === "not-provided") { if (args.channelParams === "not-provided") {
delete args.params; delete args.channelParams;
} }
args.skipLoadingConfig = Array.isArray(args.skipLoadingConfig); args.skipLoadingConfig = Array.isArray(args.skipLoadingConfig);
@ -385,19 +385,19 @@ export async function runNopeBackend(
// Assign the Default Setting for the Channel. // Assign the Default Setting for the Channel.
opts.params = layerDefaultParameters[args.channel]; opts.params = layerDefaultParameters[args.channel];
if (args.params != "not-provided") { if (args.channelParams != "not-provided") {
try { try {
try { try {
// We try to parse the data. // We try to parse the data.
opts.params = JSON.parse(args.params); opts.params = JSON.parse(args.channelParams);
} catch (e) { } catch (e) {
opts.params = JSON.parse('"' + args.params + '"'); opts.params = JSON.parse('"' + args.channelParams + '"');
} }
} catch (e) { } catch (e) {
logger.error( logger.error(
"Unable to parse the Parameters for the channel. Please use valid JSON!" "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); logger.error(e);
throw e; throw e;
} }

View File

@ -11,8 +11,8 @@ import {
defineNopeLogger, defineNopeLogger,
ValidLoggerDefinition, ValidLoggerDefinition,
} from "../../logger/getLogger"; } from "../../logger/getLogger";
import { DEBUG, INFO } from "../../logger/index.browser"; import { DEBUG, ILogger, INFO } from "../../logger/index.browser";
import { Eventnames } from "../../types/nope"; import { Eventnames, IRpcResponseMsg, IRequestRpcMsg } from "../../types/nope";
import { EventCommunicationInterface } from "./EventCommunicationInterface"; import { EventCommunicationInterface } from "./EventCommunicationInterface";
/** /**
@ -23,6 +23,8 @@ import { EventCommunicationInterface } from "./EventCommunicationInterface";
*/ */
export class ioSocketServerLayer extends EventCommunicationInterface { export class ioSocketServerLayer extends EventCommunicationInterface {
protected _sockets: Set<io.Socket>; protected _sockets: Set<io.Socket>;
protected _openRequests: { [index: string]: number } = {};
protected _profile: boolean;
/** /**
* Creates an instance of IoSocketMirrorServer. * Creates an instance of IoSocketMirrorServer.
@ -31,7 +33,11 @@ export class ioSocketServerLayer extends EventCommunicationInterface {
* @param {ValidLoggerDefinition} [logger="info"] * @param {ValidLoggerDefinition} [logger="info"]
* @memberof IoSocketMirrorServer * @memberof IoSocketMirrorServer
*/ */
constructor(public port: number, logger: ValidLoggerDefinition = "info") { constructor(
public port: number,
logger: ValidLoggerDefinition = "info",
profile = false
) {
super( super(
// As event Emitter, we provide the IO-Client. // As event Emitter, we provide the IO-Client.
(io as any)({ (io as any)({
@ -44,6 +50,9 @@ export class ioSocketServerLayer extends EventCommunicationInterface {
); );
const _this = this; const _this = this;
// Store, whether we want to profile our data or not.
this._profile = profile;
// Tell the Server to listen. // Tell the Server to listen.
(this._emitter as any).listen(port); (this._emitter as any).listen(port);
@ -68,6 +77,14 @@ export class ioSocketServerLayer extends EventCommunicationInterface {
// are forwarding the data. // are forwarding the data.
for (const event of Eventnames) { for (const event of Eventnames) {
client.on(event, (data) => { 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)) { if (event !== "statusChanged" && _this._logger?.enabledFor(DEBUG)) {
_this._logger.debug( _this._logger.debug(
"forwarding", "forwarding",
@ -97,6 +114,29 @@ export class ioSocketServerLayer extends EventCommunicationInterface {
this._sockets = new Set(); 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. * Helper Function, to forward events to the other connected Sockets.
* *

View File

@ -1,6 +1,6 @@
{ {
"name": "nope", "name": "nope",
"version": "1.4.2", "version": "1.4.3",
"description": "NoPE Runtime for Nodejs. For Browser-Support please use nope-browser", "description": "NoPE Runtime for Nodejs. For Browser-Support please use nope-browser",
"files": [ "files": [
"dist-nodejs/**/*", "dist-nodejs/**/*",