Adding Environment
This commit is contained in:
parent
7c4e00d6fa
commit
2c3a6ddb36
@ -249,8 +249,8 @@ export class nopeDispatcher implements INopeDispatcher {
|
|||||||
if (this._logger?.enabledFor(Logger.DEBUG)) {
|
if (this._logger?.enabledFor(Logger.DEBUG)) {
|
||||||
this._logger.debug(
|
this._logger.debug(
|
||||||
"Adding instance generator for \"" +
|
"Adding instance generator for \"" +
|
||||||
identifier +
|
identifier +
|
||||||
"\" to external Generators. Other Elements can now create instances of this type."
|
"\" to external Generators. Other Elements can now create instances of this type."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -350,8 +350,8 @@ export class nopeDispatcher implements INopeDispatcher {
|
|||||||
if (this._logger?.enabledFor(Logger.DEBUG)) {
|
if (this._logger?.enabledFor(Logger.DEBUG)) {
|
||||||
this._logger.debug(
|
this._logger.debug(
|
||||||
"Removing instance generator for \"" +
|
"Removing instance generator for \"" +
|
||||||
identifier +
|
identifier +
|
||||||
"\" from external Generators. Other Elements cant create instances of this type anymore."
|
"\" from external Generators. Other Elements cant create instances of this type anymore."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -370,8 +370,8 @@ export class nopeDispatcher implements INopeDispatcher {
|
|||||||
if (this._logger?.enabledFor(Logger.DEBUG)) {
|
if (this._logger?.enabledFor(Logger.DEBUG)) {
|
||||||
this._logger.debug(
|
this._logger.debug(
|
||||||
"Adding instance generator for \"" +
|
"Adding instance generator for \"" +
|
||||||
identifier +
|
identifier +
|
||||||
"\" as internal Generator. This Generator wont be used externally."
|
"\" as internal Generator. This Generator wont be used externally."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -382,8 +382,8 @@ export class nopeDispatcher implements INopeDispatcher {
|
|||||||
if (this._logger?.enabledFor(Logger.DEBUG)) {
|
if (this._logger?.enabledFor(Logger.DEBUG)) {
|
||||||
this._logger.debug(
|
this._logger.debug(
|
||||||
"Rmoving instance generator for \"" +
|
"Rmoving instance generator for \"" +
|
||||||
identifier +
|
identifier +
|
||||||
"\" from internal Generator. The sytem cant create elements of this type any more."
|
"\" from internal Generator. The sytem cant create elements of this type any more."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -436,10 +436,10 @@ export class nopeDispatcher implements INopeDispatcher {
|
|||||||
if (this._logger?.enabledFor(Logger.DEBUG)) {
|
if (this._logger?.enabledFor(Logger.DEBUG)) {
|
||||||
this._logger.debug(
|
this._logger.debug(
|
||||||
"Requesting an Instance of type: \"" +
|
"Requesting an Instance of type: \"" +
|
||||||
_defDescription.type +
|
_defDescription.type +
|
||||||
"\" with the identifier: \"" +
|
"\" with the identifier: \"" +
|
||||||
_defDescription.identifier +
|
_defDescription.identifier +
|
||||||
"\""
|
"\""
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,8 +447,8 @@ export class nopeDispatcher implements INopeDispatcher {
|
|||||||
if (this._logger?.enabledFor(Logger.DEBUG)) {
|
if (this._logger?.enabledFor(Logger.DEBUG)) {
|
||||||
this._logger.debug(
|
this._logger.debug(
|
||||||
"Already created instance with the identifiert: \"" +
|
"Already created instance with the identifiert: \"" +
|
||||||
_defDescription.identifier +
|
_defDescription.identifier +
|
||||||
"\" => returning this instance"
|
"\" => returning this instance"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -480,8 +480,8 @@ export class nopeDispatcher implements INopeDispatcher {
|
|||||||
if (this._logger?.enabledFor(Logger.DEBUG)) {
|
if (this._logger?.enabledFor(Logger.DEBUG)) {
|
||||||
this._logger.debug(
|
this._logger.debug(
|
||||||
"No instance with the identifiert: \"" +
|
"No instance with the identifiert: \"" +
|
||||||
_defDescription.identifier +
|
_defDescription.identifier +
|
||||||
"\" found, but an internal generator is available. Using the internal one for creating the instance and requesting the \"real\" instance externally"
|
"\" found, but an internal generator is available. Using the internal one for creating the instance and requesting the \"real\" instance externally"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -614,12 +614,12 @@ export class nopeDispatcher implements INopeDispatcher {
|
|||||||
// If there is a Logger:
|
// If there is a Logger:
|
||||||
this._logger.debug(
|
this._logger.debug(
|
||||||
"Dispatcher \"" +
|
"Dispatcher \"" +
|
||||||
this.id +
|
this.id +
|
||||||
"\" received request: \"" +
|
"\" received request: \"" +
|
||||||
data.functionId +
|
data.functionId +
|
||||||
"\" -> task: \"" +
|
"\" -> task: \"" +
|
||||||
data.taskId +
|
data.taskId +
|
||||||
"\""
|
"\""
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -649,29 +649,29 @@ export class nopeDispatcher implements INopeDispatcher {
|
|||||||
// trigger the remote.
|
// trigger the remote.
|
||||||
data.callbacks.map(
|
data.callbacks.map(
|
||||||
(options) =>
|
(options) =>
|
||||||
(args[options.idx] = async (..._args) => {
|
(args[options.idx] = async (..._args) => {
|
||||||
// And Create the Task and its Promise.
|
// And Create the Task and its Promise.
|
||||||
const servicePromise = _this.performCall<any>(
|
const servicePromise = _this.performCall<any>(
|
||||||
options.functionId,
|
options.functionId,
|
||||||
_args,
|
_args,
|
||||||
options
|
options
|
||||||
);
|
);
|
||||||
|
|
||||||
const cancelCallback = (reason) => {
|
const cancelCallback = (reason) => {
|
||||||
// The Main Task has been canceled =>
|
// The Main Task has been canceled =>
|
||||||
// We are allowed to canel the Subtask as well.
|
// We are allowed to canel the Subtask as well.
|
||||||
servicePromise.cancel(reason);
|
servicePromise.cancel(reason);
|
||||||
};
|
};
|
||||||
cbs.push(cancelCallback);
|
cbs.push(cancelCallback);
|
||||||
|
|
||||||
// Await the Result. If an Task is canceled => The Error is Thrown.
|
// Await the Result. If an Task is canceled => The Error is Thrown.
|
||||||
const result = await servicePromise;
|
const result = await servicePromise;
|
||||||
|
|
||||||
// Remove the Index
|
// Remove the Index
|
||||||
cbs.splice(cbs.indexOf(cancelCallback), 1);
|
cbs.splice(cbs.indexOf(cancelCallback), 1);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
// Perform the Task it self.
|
// Perform the Task it self.
|
||||||
@ -704,10 +704,10 @@ export class nopeDispatcher implements INopeDispatcher {
|
|||||||
// If there is a Logger:
|
// If there is a Logger:
|
||||||
this._logger.error(
|
this._logger.error(
|
||||||
"Dispatcher \"" +
|
"Dispatcher \"" +
|
||||||
this.id +
|
this.id +
|
||||||
"\" failed with request: \"" +
|
"\" failed with request: \"" +
|
||||||
data.taskId +
|
data.taskId +
|
||||||
"\""
|
"\""
|
||||||
);
|
);
|
||||||
this._logger.error(error);
|
this._logger.error(error);
|
||||||
}
|
}
|
||||||
@ -773,7 +773,7 @@ export class nopeDispatcher implements INopeDispatcher {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (e) { }
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -848,7 +848,7 @@ export class nopeDispatcher implements INopeDispatcher {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (e) { }
|
||||||
});
|
});
|
||||||
|
|
||||||
// Subscribe to new available Topics.
|
// Subscribe to new available Topics.
|
||||||
@ -869,7 +869,7 @@ export class nopeDispatcher implements INopeDispatcher {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (e) { }
|
||||||
});
|
});
|
||||||
|
|
||||||
await this.communicator.onNewInstanceGeneratorsAvailable((data) => {
|
await this.communicator.onNewInstanceGeneratorsAvailable((data) => {
|
||||||
@ -887,7 +887,7 @@ export class nopeDispatcher implements INopeDispatcher {
|
|||||||
data.dispatcher
|
data.dispatcher
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (e) { }
|
||||||
});
|
});
|
||||||
|
|
||||||
await this.communicator.onStatusUpdate((info) => {
|
await this.communicator.onStatusUpdate((info) => {
|
||||||
@ -937,8 +937,8 @@ export class nopeDispatcher implements INopeDispatcher {
|
|||||||
// If there is a Logger:
|
// If there is a Logger:
|
||||||
_this._logger.debug(
|
_this._logger.debug(
|
||||||
"Remote Dispatcher \"" +
|
"Remote Dispatcher \"" +
|
||||||
message.dispatcher +
|
message.dispatcher +
|
||||||
"\" updated its available instances"
|
"\" updated its available instances"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1096,6 +1096,8 @@ export class nopeDispatcher implements INopeDispatcher {
|
|||||||
const os = require("os");
|
const os = require("os");
|
||||||
return {
|
return {
|
||||||
id: this.id,
|
id: this.id,
|
||||||
|
env: "javascript",
|
||||||
|
version: "0.9.5",
|
||||||
host: {
|
host: {
|
||||||
cores: os.cpus().length,
|
cores: os.cpus().length,
|
||||||
cpu: `${os.cpus()[0].model}`,
|
cpu: `${os.cpus()[0].model}`,
|
||||||
@ -1109,6 +1111,8 @@ export class nopeDispatcher implements INopeDispatcher {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
env: "javascript",
|
||||||
|
version: "0.9.5",
|
||||||
host: {
|
host: {
|
||||||
cores: -1,
|
cores: -1,
|
||||||
cpu: "unkown",
|
cpu: "unkown",
|
||||||
@ -1382,8 +1386,8 @@ export class nopeDispatcher implements INopeDispatcher {
|
|||||||
// That should lead to a fatal error ?
|
// That should lead to a fatal error ?
|
||||||
_this._logger.warn(
|
_this._logger.warn(
|
||||||
"An Instance with the name \"" +
|
"An Instance with the name \"" +
|
||||||
instance.identifier +
|
instance.identifier +
|
||||||
"\" has already been declared",
|
"\" has already been declared",
|
||||||
_this._externalInstances.get(instance.identifier)?.type,
|
_this._externalInstances.get(instance.identifier)?.type,
|
||||||
"!=",
|
"!=",
|
||||||
instance.type
|
instance.type
|
||||||
@ -1536,7 +1540,7 @@ export class nopeDispatcher implements INopeDispatcher {
|
|||||||
protected _subscribeToEvent(event: string) {
|
protected _subscribeToEvent(event: string) {
|
||||||
const item = this._externallySubscribeObservables.get(event) || {
|
const item = this._externallySubscribeObservables.get(event) || {
|
||||||
observable: this._generateObservable<IExternalEventMsg>(),
|
observable: this._generateObservable<IExternalEventMsg>(),
|
||||||
cb: () => {}
|
cb: () => { }
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!item.observable.hasSubscriptions) {
|
if (!item.observable.hasSubscriptions) {
|
||||||
@ -2266,12 +2270,12 @@ export class nopeDispatcher implements INopeDispatcher {
|
|||||||
if (_this._logger?.enabledFor(Logger.DEBUG)) {
|
if (_this._logger?.enabledFor(Logger.DEBUG)) {
|
||||||
_this._logger.debug(
|
_this._logger.debug(
|
||||||
"Dispatcher \"" +
|
"Dispatcher \"" +
|
||||||
this.id +
|
this.id +
|
||||||
"\" requesting externally Function \"" +
|
"\" requesting externally Function \"" +
|
||||||
serviceName +
|
serviceName +
|
||||||
"\" with task: \"" +
|
"\" with task: \"" +
|
||||||
_taskId +
|
_taskId +
|
||||||
"\""
|
"\""
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2375,12 +2379,12 @@ export class nopeDispatcher implements INopeDispatcher {
|
|||||||
if (_this._logger?.enabledFor(Logger.DEBUG)) {
|
if (_this._logger?.enabledFor(Logger.DEBUG)) {
|
||||||
_this._logger.debug(
|
_this._logger.debug(
|
||||||
"Dispatcher \"" +
|
"Dispatcher \"" +
|
||||||
this.id +
|
this.id +
|
||||||
"\" putting task \"" +
|
"\" putting task \"" +
|
||||||
_taskId +
|
_taskId +
|
||||||
"\" on: \"" +
|
"\" on: \"" +
|
||||||
_this._getServiceName(taskRequest.functionId, "request") +
|
_this._getServiceName(taskRequest.functionId, "request") +
|
||||||
"\""
|
"\""
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2391,8 +2395,8 @@ export class nopeDispatcher implements INopeDispatcher {
|
|||||||
_taskId,
|
_taskId,
|
||||||
new Error(
|
new Error(
|
||||||
"TIMEOUT. The Service allowed execution time of " +
|
"TIMEOUT. The Service allowed execution time of " +
|
||||||
options.timeout.toString() +
|
options.timeout.toString() +
|
||||||
"[ms] has been excided"
|
"[ms] has been excided"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}, options.timeout);
|
}, options.timeout);
|
||||||
|
@ -42,7 +42,9 @@ export type IValidPromise<T> = Promise<T> | INopePromise<T>;
|
|||||||
export interface IDispatcherInfo {
|
export interface IDispatcherInfo {
|
||||||
id: string;
|
id: string;
|
||||||
timestamp: number;
|
timestamp: number;
|
||||||
status: ENopeDispatcherStatus;
|
status: ENopeDispatcherStatus;
|
||||||
|
env: string,
|
||||||
|
version: string,
|
||||||
host: {
|
host: {
|
||||||
cores: number;
|
cores: number;
|
||||||
cpu: string;
|
cpu: string;
|
||||||
|
Loading…
Reference in New Issue
Block a user