fixing wamo-line

This commit is contained in:
Martin Karkowski 2021-01-15 16:33:52 +01:00
parent 9e305ebef0
commit f2b0e1ab7b
5 changed files with 131 additions and 128 deletions

View File

@ -2,7 +2,7 @@
* @author Martin Karkowski * @author Martin Karkowski
* @email m.karkowski@zema.de * @email m.karkowski@zema.de
* @create date 2020-03-02 11:37:50 * @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] * @desc [description]
*/ */
@ -330,7 +330,7 @@ export class WaMOBaseModule
// Demo-Mode // Demo-Mode
// Wait 10 Seconds at least spend additional 0-5000 Seconds // 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"); _this._logger.info("waited => release");

View File

@ -2,7 +2,7 @@
* @author Martin Karkowski * @author Martin Karkowski
* @email m.karkowski@zema.de * @email m.karkowski@zema.de
* @create date 2020-03-02 11:37:50 * @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] * @desc [description]
*/ */
@ -401,7 +401,7 @@ export class WaMOSimpleTransportManager
this.config.setContent(options); this.config.setContent(options);
await this.initialized.waitFor((value) => value); await this.initialized.waitFor((value) => value);
await this.flush(); // await this.flush();
} }
/** /**

View File

@ -141,36 +141,74 @@ class OverviewComponent extends React.Component<
></AvailableDispatchers> ></AvailableDispatchers>
</Col> </Col>
</Row> </Row>
<Row> {this.state.instances.length > 0 ? (
<Col> <Row>
<Jumbotron> <Col>
<h1>Instances</h1> <Jumbotron>
<p>The Following instances has been found:</p> <h1>Instances</h1>
<Table striped bordered hover> <p>The Following instances has been found:</p>
<thead> <Table striped bordered hover>
<tr> <thead>
<th>Identifier</th> <tr>
<th>Type</th> <th>Identifier</th>
<th></th> <th>Type</th>
</tr> <th></th>
</thead> </tr>
<tbody> </thead>
{this.state.instances.map((instance) => { <tbody>
return ( {this.state.instances.map((instance) => {
<tr key={idx++}> return (
<td>{instance.identifier}</td> <tr key={idx++}>
<td> <td>{instance.identifier}</td>
<code>{instance.type}</code> <td>
</td> <code>{instance.type}</code>
<td></td> </td>
</tr> <td></td>
); </tr>
})} );
</tbody> })}
</Table> </tbody>
</Jumbotron> </Table>
</Col> </Jumbotron>
</Row> </Col>
</Row>
) : (
""
)}
{this.state.instances.length > 0 ? (
<Row>
<Col>
<Jumbotron>
<h1>Instances</h1>
<p>The Following instances has been found:</p>
<Table striped bordered hover>
<thead>
<tr>
<th>Identifier</th>
<th>Type</th>
<th></th>
</tr>
</thead>
<tbody>
{this.state.instances.map((instance) => {
return (
<tr key={idx++}>
<td>{instance.identifier}</td>
<td>
<code>{instance.type}</code>
</td>
<td></td>
</tr>
);
})}
</tbody>
</Table>
</Jumbotron>
</Col>
</Row>
) : (
""
)}
</Container> </Container>
</> </>
); );

View File

@ -17,7 +17,7 @@ import { INopeObserver } from "../../lib/types/nope/nopeObservable.interface";
/** /**
* Component used to render the Status of the Memory of a Host. * Component used to render the Status of the Memory of a Host.
*/ */
class MemoryStatusComponent extends React.Component< class MemoryStatusOfHostComponent extends React.Component<
{ {
value: number; value: number;
}, },
@ -139,9 +139,9 @@ class HostStatusComponent extends React.Component<
<td> <td>
{" "} {" "}
{/* Rendert the Memory */} {/* Rendert the Memory */}
<MemoryStatusComponent <MemoryStatusOfHostComponent
value={this.props.status.ram} value={this.props.status.ram}
></MemoryStatusComponent> ></MemoryStatusOfHostComponent>
</td> </td>
</tr> </tr>
) : ( ) : (

View File

@ -1,36 +1,39 @@
import "reflect-metadata"; import "reflect-metadata";
import { EventLayer } from "../lib/communication/eventLayer"; import { EventLayer } from "../lib/communication/eventLayer";
import { exportFunctionToDispatcher } from "../lib/decorators/dispatcherDecorators";
import { getLinkedDispatcher } from "../lib/dispatcher/getLinkedDispatcher"; import { getLinkedDispatcher } from "../lib/dispatcher/getLinkedDispatcher";
import { nopeDispatcher } from "../lib/dispatcher/nopeDispatcher"; import { nopeDispatcher } from "../lib/dispatcher/nopeDispatcher";
import { exportFunctionToDispatcher } from "../lib/dispatcher/nopeDispatcherDecorators";
import { NopeObservable } from "../lib/observables/NopeObservable"; import { NopeObservable } from "../lib/observables/NopeObservable";
import { IRemoteInstance } from "../lib/types/remoteInstance.interface";
import { generateBenchmarkFunction } from "../modules/funcs/generateBenchmarkFunction"; import { generateBenchmarkFunction } from "../modules/funcs/generateBenchmarkFunction";
const max = 100000; const max = 100000;
const communicator = new EventLayer( const communicator = new EventLayer();
"generic",
"generic"
);
const local = new nopeDispatcher({ communicator }, () => new NopeObservable()); 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); const _functionRemote = exportFunctionToDispatcher(
}, { async (a: number, b: number, operation: (a: number, b: number) => number) => {
uri: "functionRemote" return await operation(a, b);
}); },
const _benchmark = exportFunctionToDispatcher(generateBenchmarkFunction(max, ""), { {
uri: "benchmark" id: "functionRemote"
}); }
);
const _benchmark = exportFunctionToDispatcher(
generateBenchmarkFunction(max, "remote-dispatcher"),
{
id: "benchmark"
}
);
const remote = getLinkedDispatcher({ communicator }); const remote = getLinkedDispatcher({ communicator });
const remoteObservable = new NopeObservable<number>(); const remoteObservable = new NopeObservable<number>();
remote.registerObservable(remoteObservable,{ remote.registerObservable(remoteObservable, {
mode: "publish", mode: "publish",
topic: "topic" topic: "topic",
schema: {}
}); });
const main = async () => { const main = async () => {
const localObservable = new NopeObservable<number>(); const localObservable = new NopeObservable<number>();
localObservable.subscribe((data) => { localObservable.subscribe((data) => {
console.log(data); console.log(data);
@ -39,14 +42,14 @@ const main = async () => {
remoteObservable.setContent(1337); remoteObservable.setContent(1337);
console.log("No output of the emitter"); console.log("No output of the emitter");
local.registerObservable(localObservable,{ local.registerObservable(localObservable, {
mode: "subscribe", mode: "subscribe",
topic:"topic" topic: "topic",
schema: {}
}); });
remoteObservable.setContent(1338); remoteObservable.setContent(1338);
try { try {
await local.performCall("unkown", []); await local.performCall("unkown", []);
} catch (e) { } catch (e) {
@ -54,81 +57,44 @@ const main = async () => {
console.error(e); console.error(e);
} }
let res = await local.performCall<number>("functionRemote", [1, 2, async (a, b) => { let res = await local.performCall<number>("functionRemote", [
console.log("local callback"); 1,
return a + b; 2,
}]); async (a, b) => {
console.log("local callback");
return a + b;
}
]);
console.log("1", res); console.log("1", res);
res = await local.methodInterface.functionRemote<number>(1, 2, async (a, b) => { res = await local.methodInterface.functionRemote<number>(
console.log("local callback"); 1,
return a * b; 2,
}); async (a, b) => {
console.log("local callback");
remote.registerInternalInstanceGenerator("class", async (dispather, identifier) => { return a * b;
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"
});
let i = 0; let i = 0;
const benchmark = generateBenchmarkFunction(max, ""); const benchmark = generateBenchmarkFunction(max, "");
while (i < max * 10) { while (i < max * 10) {
await local.performCall<number>("functionRemote", [1, 2, async (a, b) => { // await local.performCall<number>(
return 1; // "functionRemote",
}], { // [
deletableCallbacks: [2], // 1,
}); // 2,
// async (a, b) => {
// return 1;
// }
// ],
// {
// deletableCallbacks: [2]
// }
// );
benchmark(); benchmark();
@ -148,13 +114,12 @@ const main = async () => {
i = 0; i = 0;
while (i < max * 10) { while (i < max * 10) {
await benchmark(); await _benchmark();
i++; i++;
} }
await local.dispose();
await remote.dispose();
}; };
main().catch(console.error); main().catch(console.error);
setTimeout(console.log, 10000, "done");