From f2b0e1ab7bf3aac3eb1ee2ef672c1206709d7eea Mon Sep 17 00:00:00 2001 From: Martin Karkowski Date: Fri, 15 Jan 2021 16:33:52 +0100 Subject: [PATCH] fixing wamo-line --- modules/wamo/src/wamo.basemodule.module.ts | 4 +- .../wamo.transportManager.simple.module.ts | 4 +- pages/kernel/overview.tsx | 98 ++++++++---- resources/admin-shell/dispatchers.tsx | 6 +- test/testDispatcher.ts | 147 +++++++----------- 5 files changed, 131 insertions(+), 128 deletions(-) diff --git a/modules/wamo/src/wamo.basemodule.module.ts b/modules/wamo/src/wamo.basemodule.module.ts index be55d2b..629aac9 100644 --- a/modules/wamo/src/wamo.basemodule.module.ts +++ b/modules/wamo/src/wamo.basemodule.module.ts @@ -2,7 +2,7 @@ * @author Martin Karkowski * @email m.karkowski@zema.de * @create date 2020-03-02 11:37:50 - * @modify date 2021-01-06 15:48:34 + * @modify date 2021-01-14 12:12:15 * @desc [description] */ @@ -330,7 +330,7 @@ export class WaMOBaseModule // Demo-Mode // Wait 10 Seconds at least spend additional 0-5000 Seconds - await sleep(Math.random() * 5000 + 10000); + await sleep(Math.random() * 5000 + 1000); _this._logger.info("waited => release"); diff --git a/modules/wamo/src/wamo.transportManager.simple.module.ts b/modules/wamo/src/wamo.transportManager.simple.module.ts index 33ce0c0..790d827 100644 --- a/modules/wamo/src/wamo.transportManager.simple.module.ts +++ b/modules/wamo/src/wamo.transportManager.simple.module.ts @@ -2,7 +2,7 @@ * @author Martin Karkowski * @email m.karkowski@zema.de * @create date 2020-03-02 11:37:50 - * @modify date 2021-01-06 16:59:20 + * @modify date 2021-01-14 12:08:07 * @desc [description] */ @@ -401,7 +401,7 @@ export class WaMOSimpleTransportManager this.config.setContent(options); await this.initialized.waitFor((value) => value); - await this.flush(); + // await this.flush(); } /** diff --git a/pages/kernel/overview.tsx b/pages/kernel/overview.tsx index bdb3d01..d64a142 100644 --- a/pages/kernel/overview.tsx +++ b/pages/kernel/overview.tsx @@ -141,36 +141,74 @@ class OverviewComponent extends React.Component< > - - - -

Instances

-

The Following instances has been found:

- - - - - - - - - - {this.state.instances.map((instance) => { - return ( - - - - - - ); - })} - -
IdentifierType
{instance.identifier} - {instance.type} -
-
- -
+ {this.state.instances.length > 0 ? ( + + + +

Instances

+

The Following instances has been found:

+ + + + + + + + + + {this.state.instances.map((instance) => { + return ( + + + + + + ); + })} + +
IdentifierType
{instance.identifier} + {instance.type} +
+
+ +
+ ) : ( + "" + )} + {this.state.instances.length > 0 ? ( + + + +

Instances

+

The Following instances has been found:

+ + + + + + + + + + {this.state.instances.map((instance) => { + return ( + + + + + + ); + })} + +
IdentifierType
{instance.identifier} + {instance.type} +
+
+ +
+ ) : ( + "" + )} ); diff --git a/resources/admin-shell/dispatchers.tsx b/resources/admin-shell/dispatchers.tsx index 1ac2c8d..4646aa1 100644 --- a/resources/admin-shell/dispatchers.tsx +++ b/resources/admin-shell/dispatchers.tsx @@ -17,7 +17,7 @@ import { INopeObserver } from "../../lib/types/nope/nopeObservable.interface"; /** * Component used to render the Status of the Memory of a Host. */ -class MemoryStatusComponent extends React.Component< +class MemoryStatusOfHostComponent extends React.Component< { value: number; }, @@ -139,9 +139,9 @@ class HostStatusComponent extends React.Component< {" "} {/* Rendert the Memory */} - + > ) : ( diff --git a/test/testDispatcher.ts b/test/testDispatcher.ts index feb36d5..28c298d 100644 --- a/test/testDispatcher.ts +++ b/test/testDispatcher.ts @@ -1,36 +1,39 @@ import "reflect-metadata"; import { EventLayer } from "../lib/communication/eventLayer"; +import { exportFunctionToDispatcher } from "../lib/decorators/dispatcherDecorators"; import { getLinkedDispatcher } from "../lib/dispatcher/getLinkedDispatcher"; import { nopeDispatcher } from "../lib/dispatcher/nopeDispatcher"; -import { exportFunctionToDispatcher } from "../lib/dispatcher/nopeDispatcherDecorators"; import { NopeObservable } from "../lib/observables/NopeObservable"; -import { IRemoteInstance } from "../lib/types/remoteInstance.interface"; import { generateBenchmarkFunction } from "../modules/funcs/generateBenchmarkFunction"; - const max = 100000; -const communicator = new EventLayer( - "generic", - "generic" -); +const communicator = new EventLayer(); const local = new nopeDispatcher({ communicator }, () => new NopeObservable()); -const _functionRemote = exportFunctionToDispatcher(async (a: number, b: number, operation: (a: number, b: number) => number) => { - return await operation(a, b); -}, { - uri: "functionRemote" -}); -const _benchmark = exportFunctionToDispatcher(generateBenchmarkFunction(max, ""), { - uri: "benchmark" -}); + +const _functionRemote = exportFunctionToDispatcher( + async (a: number, b: number, operation: (a: number, b: number) => number) => { + return await operation(a, b); + }, + { + id: "functionRemote" + } +); +const _benchmark = exportFunctionToDispatcher( + generateBenchmarkFunction(max, "remote-dispatcher"), + { + id: "benchmark" + } +); + const remote = getLinkedDispatcher({ communicator }); const remoteObservable = new NopeObservable(); -remote.registerObservable(remoteObservable,{ +remote.registerObservable(remoteObservable, { mode: "publish", - topic: "topic" + topic: "topic", + schema: {} }); const main = async () => { - const localObservable = new NopeObservable(); localObservable.subscribe((data) => { console.log(data); @@ -39,14 +42,14 @@ const main = async () => { remoteObservable.setContent(1337); console.log("No output of the emitter"); - local.registerObservable(localObservable,{ + local.registerObservable(localObservable, { mode: "subscribe", - topic:"topic" + topic: "topic", + schema: {} }); remoteObservable.setContent(1338); - try { await local.performCall("unkown", []); } catch (e) { @@ -54,81 +57,44 @@ const main = async () => { console.error(e); } - let res = await local.performCall("functionRemote", [1, 2, async (a, b) => { - console.log("local callback"); - return a + b; - }]); + let res = await local.performCall("functionRemote", [ + 1, + 2, + async (a, b) => { + console.log("local callback"); + return a + b; + } + ]); console.log("1", res); - res = await local.methodInterface.functionRemote(1, 2, async (a, b) => { - console.log("local callback"); - return a * b; - }); - - remote.registerInternalInstanceGenerator("class", async (dispather, identifier) => { - const ret: IRemoteInstance = { - dispose: async () => { - console.log("dispise"); - }, - description: { - - }, - init: async (... args) => { - console.log("INIT with", args); - }, - type: "class" - }; - - console.log("CREATED INSTANCE of type \"class\" with args",dispather.id, identifier); - - return ret; - }, { - mode: "external" - }); - - local.registerInstanceGenerator("class", async (dispather, identifier) => { - const ret: IRemoteInstance = { - dispose: async () => { - console.log("dispise"); - }, - identifier: "null", - init: async (... args) => { - console.log("INIT with", args); - }, - type: "class" - }; - - console.log("CREATED Wrapper for", identifier); - - return ret; - }, { - mode: "internal" - }); - - const instance_01= await local.generateInstance({ - identifier: "obj1", - params: ["hello","world"], - type: "class" - }); - - const instance_02 = await local.generateInstance({ - identifier: "obj1", - params: ["hello","world"], - type: "class" - }); - + res = await local.methodInterface.functionRemote( + 1, + 2, + async (a, b) => { + console.log("local callback"); + return a * b; + } + ); let i = 0; const benchmark = generateBenchmarkFunction(max, ""); while (i < max * 10) { - await local.performCall("functionRemote", [1, 2, async (a, b) => { - return 1; - }], { - deletableCallbacks: [2], - }); + // await local.performCall( + // "functionRemote", + // [ + // 1, + // 2, + // async (a, b) => { + // return 1; + // } + // ], + // { + // deletableCallbacks: [2] + // } + // ); benchmark(); @@ -148,13 +114,12 @@ const main = async () => { i = 0; while (i < max * 10) { - await benchmark(); + await _benchmark(); i++; } + await local.dispose(); + await remote.dispose(); }; main().catch(console.error); - -setTimeout(console.log, 10000, "done"); -