fixing wamo-line
This commit is contained in:
parent
9e305ebef0
commit
f2b0e1ab7b
@ -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");
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -141,36 +141,74 @@ class OverviewComponent extends React.Component<
|
||||
></AvailableDispatchers>
|
||||
</Col>
|
||||
</Row>
|
||||
<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>
|
||||
{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>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
{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>
|
||||
</>
|
||||
);
|
||||
|
@ -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<
|
||||
<td>
|
||||
{" "}
|
||||
{/* Rendert the Memory */}
|
||||
<MemoryStatusComponent
|
||||
<MemoryStatusOfHostComponent
|
||||
value={this.props.status.ram}
|
||||
></MemoryStatusComponent>
|
||||
></MemoryStatusOfHostComponent>
|
||||
</td>
|
||||
</tr>
|
||||
) : (
|
||||
|
@ -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<number>();
|
||||
remote.registerObservable(remoteObservable,{
|
||||
remote.registerObservable(remoteObservable, {
|
||||
mode: "publish",
|
||||
topic: "topic"
|
||||
topic: "topic",
|
||||
schema: {}
|
||||
});
|
||||
|
||||
const main = async () => {
|
||||
|
||||
const localObservable = new NopeObservable<number>();
|
||||
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<number>("functionRemote", [1, 2, async (a, b) => {
|
||||
console.log("local callback");
|
||||
return a + b;
|
||||
}]);
|
||||
let res = await local.performCall<number>("functionRemote", [
|
||||
1,
|
||||
2,
|
||||
async (a, b) => {
|
||||
console.log("local callback");
|
||||
return a + b;
|
||||
}
|
||||
]);
|
||||
|
||||
console.log("1", res);
|
||||
|
||||
res = await local.methodInterface.functionRemote<number>(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<number>(
|
||||
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<number>("functionRemote", [1, 2, async (a, b) => {
|
||||
return 1;
|
||||
}], {
|
||||
deletableCallbacks: [2],
|
||||
});
|
||||
// await local.performCall<number>(
|
||||
// "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");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user