@5minds/node-red-contrib-processcube 0.0.8 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.node-red/data/.config.nodes.json +1 -1
- package/.node-red/data/.config.nodes.json.backup +12 -1
- package/.node-red/data/flows.json +4 -3
- package/externaltask-error.js +4 -3
- package/externaltask-input.html +7 -2
- package/externaltask-input.js +22 -7
- package/externaltask-output.js +4 -3
- package/package.json +1 -1
- package/EventAggregator.js +0 -25
@@ -499,7 +499,7 @@
|
|
499
499
|
},
|
500
500
|
"@5minds/node-red-contrib-processcube": {
|
501
501
|
"name": "@5minds/node-red-contrib-processcube",
|
502
|
-
"version": "0.0.
|
502
|
+
"version": "0.0.8",
|
503
503
|
"local": true,
|
504
504
|
"user": false,
|
505
505
|
"nodes": {
|
@@ -525,6 +525,17 @@
|
|
525
525
|
"module": "@5minds/node-red-contrib-processcube",
|
526
526
|
"file": "/data/node_modules/node-red-contrib-processcube/externaltask-output.js"
|
527
527
|
},
|
528
|
+
"externaltaskError": {
|
529
|
+
"name": "externaltaskError",
|
530
|
+
"types": [
|
531
|
+
"externaltask-error"
|
532
|
+
],
|
533
|
+
"enabled": true,
|
534
|
+
"local": true,
|
535
|
+
"user": false,
|
536
|
+
"module": "@5minds/node-red-contrib-processcube",
|
537
|
+
"file": "/data/node_modules/node-red-contrib-processcube/externaltask-error.js"
|
538
|
+
},
|
528
539
|
"processStart": {
|
529
540
|
"name": "processStart",
|
530
541
|
"types": [
|
@@ -132,6 +132,7 @@
|
|
132
132
|
"type": "externaltask-input",
|
133
133
|
"z": "a23d2e782beb66f4",
|
134
134
|
"name": "processmodels",
|
135
|
+
"engine": "",
|
135
136
|
"topic": "processmodels",
|
136
137
|
"x": 100,
|
137
138
|
"y": 460,
|
@@ -560,7 +561,7 @@
|
|
560
561
|
"z": "a23d2e782beb66f4",
|
561
562
|
"name": "",
|
562
563
|
"pauseType": "delay",
|
563
|
-
"timeout": "
|
564
|
+
"timeout": "1",
|
564
565
|
"timeoutUnits": "seconds",
|
565
566
|
"rate": "1",
|
566
567
|
"nbRateUnits": "1",
|
@@ -609,7 +610,7 @@
|
|
609
610
|
"z": "a23d2e782beb66f4",
|
610
611
|
"name": "",
|
611
612
|
"pauseType": "delay",
|
612
|
-
"timeout": "
|
613
|
+
"timeout": "1",
|
613
614
|
"timeoutUnits": "seconds",
|
614
615
|
"rate": "1",
|
615
616
|
"nbRateUnits": "1",
|
@@ -725,7 +726,7 @@
|
|
725
726
|
"statusVal": "",
|
726
727
|
"statusType": "auto",
|
727
728
|
"x": 380,
|
728
|
-
"y":
|
729
|
+
"y": 180,
|
729
730
|
"wires": []
|
730
731
|
},
|
731
732
|
{
|
package/externaltask-error.js
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
-
const EventAggregator = require('./EventAggregator');
|
2
|
-
|
3
1
|
module.exports = function(RED) {
|
4
2
|
function ExternalTaskError(config) {
|
5
3
|
RED.nodes.createNode(this,config);
|
6
4
|
var node = this;
|
7
5
|
|
6
|
+
var flowContext = node.context().flow;
|
7
|
+
var eventEmitter = flowContext.get('emitter');
|
8
|
+
|
8
9
|
node.on('input', function(msg) {
|
9
10
|
|
10
11
|
const externalTaskId = msg.externalTaskId;
|
@@ -17,7 +18,7 @@ module.exports = function(RED) {
|
|
17
18
|
}
|
18
19
|
};
|
19
20
|
|
20
|
-
|
21
|
+
eventEmitter.emit(`error-${externalTaskId}`, msg.payload);
|
21
22
|
});
|
22
23
|
}
|
23
24
|
RED.nodes.registerType("externaltask-error", ExternalTaskError);
|
package/externaltask-input.html
CHANGED
@@ -3,8 +3,9 @@
|
|
3
3
|
category: 'ProcessCube',
|
4
4
|
color: '#00aed7',
|
5
5
|
defaults: {
|
6
|
-
name: {value:""},
|
7
|
-
|
6
|
+
name: {value: ""},
|
7
|
+
engine: {value: "http://engine:8000"},
|
8
|
+
topic: {value: ""}
|
8
9
|
},
|
9
10
|
inputs: 0,
|
10
11
|
outputs: 1,
|
@@ -20,6 +21,10 @@
|
|
20
21
|
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
21
22
|
<input type="text" id="node-input-name" placeholder="Name">
|
22
23
|
</div>
|
24
|
+
<div class="form-row">
|
25
|
+
<label for="node-input-engine"><i class="fa fa-tag"></i> Engine-URL</label>
|
26
|
+
<input type="text" id="node-input-engine" placeholder="http://engine:8000">
|
27
|
+
</div>
|
23
28
|
<div class="form-row">
|
24
29
|
<label for="node-input-topic"><i class="fa fa-tag"></i> Topic</label>
|
25
30
|
<input type="text" id="node-input-topic" placeholder="Topic of ExternalTask">
|
package/externaltask-input.js
CHANGED
@@ -1,11 +1,7 @@
|
|
1
1
|
const process = require('process');
|
2
|
+
const EventEmitter = require('node:events');
|
2
3
|
|
3
4
|
const engine_client = require('@5minds/processcube_engine_client');
|
4
|
-
const EventAggregator = require('./EventAggregator');
|
5
|
-
|
6
|
-
const engineUrl = process.env.ENGINE_URL || 'http://engine:8000';
|
7
|
-
|
8
|
-
const client = new engine_client.EngineClient(engineUrl);
|
9
5
|
|
10
6
|
function showStatus(node, msgCounter) {
|
11
7
|
if (msgCounter >= 1) {
|
@@ -20,6 +16,24 @@ module.exports = function(RED) {
|
|
20
16
|
RED.nodes.createNode(this,config);
|
21
17
|
var node = this;
|
22
18
|
var msgCounter = 0;
|
19
|
+
var flowContext = node.context().flow;
|
20
|
+
var nodeContext = node.context();
|
21
|
+
|
22
|
+
const engineUrl = config.engine || process.env.ENGINE_URL || 'http://engine:8000';
|
23
|
+
|
24
|
+
var client = nodeContext.get('client');
|
25
|
+
|
26
|
+
if (!client) {
|
27
|
+
nodeContext.set('client', new engine_client.EngineClient(engineUrl));
|
28
|
+
client = nodeContext.get('client');
|
29
|
+
}
|
30
|
+
|
31
|
+
var eventEmitter = flowContext.get('emitter');
|
32
|
+
|
33
|
+
if (!eventEmitter) {
|
34
|
+
flowContext.set('emitter', new EventEmitter());
|
35
|
+
eventEmitter = flowContext.get('emitter');
|
36
|
+
}
|
23
37
|
|
24
38
|
client.externalTasks.subscribeToExternalTaskTopic(
|
25
39
|
config.topic,
|
@@ -28,13 +42,14 @@ module.exports = function(RED) {
|
|
28
42
|
|
29
43
|
return await new Promise((resolve, reject) => {
|
30
44
|
|
31
|
-
|
45
|
+
// TODO: once ist 2x gebunden
|
46
|
+
eventEmitter.once(`finish-${externalTask.flowNodeInstanceId}`, (result) => {
|
32
47
|
msgCounter--;
|
33
48
|
showStatus(node, msgCounter);
|
34
49
|
resolve(result);
|
35
50
|
});
|
36
51
|
|
37
|
-
|
52
|
+
eventEmitter.once(`error-${externalTask.flowNodeInstanceId}`, (msg) => {
|
38
53
|
msgCounter--;
|
39
54
|
showStatus(node, msgCounter);
|
40
55
|
|
package/externaltask-output.js
CHANGED
@@ -1,15 +1,16 @@
|
|
1
|
-
const EventAggregator = require('./EventAggregator');
|
2
|
-
|
3
1
|
module.exports = function(RED) {
|
4
2
|
function ExternalTaskOutput(config) {
|
5
3
|
RED.nodes.createNode(this,config);
|
6
4
|
var node = this;
|
7
5
|
|
6
|
+
var flowContext = node.context().flow;
|
7
|
+
var eventEmitter = flowContext.get('emitter');
|
8
|
+
|
8
9
|
node.on('input', function(msg) {
|
9
10
|
|
10
11
|
const externalTaskId = msg.externalTaskId;
|
11
12
|
|
12
|
-
|
13
|
+
eventEmitter.emit(`finish-${externalTaskId}`, msg.payload);
|
13
14
|
});
|
14
15
|
}
|
15
16
|
RED.nodes.registerType("externaltask-output", ExternalTaskOutput);
|
package/package.json
CHANGED
package/EventAggregator.js
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
const EventEmitter = require('node:events');
|
2
|
-
|
3
|
-
const eventEmitter = new EventEmitter();
|
4
|
-
|
5
|
-
const eventSubscriptionDictionary = {};
|
6
|
-
|
7
|
-
function subscribeOnce(eventName, callback) {
|
8
|
-
eventSubscriptionDictionary[eventName] = callback;
|
9
|
-
}
|
10
|
-
|
11
|
-
async function publish(eventName, payload) {
|
12
|
-
const callback = eventSubscriptionDictionary[eventName];
|
13
|
-
|
14
|
-
if (callback) {
|
15
|
-
await callback(payload);
|
16
|
-
delete eventSubscriptionDictionary[eventName]
|
17
|
-
}
|
18
|
-
}
|
19
|
-
|
20
|
-
module.exports = {
|
21
|
-
eventEmitter: eventEmitter,
|
22
|
-
subscribeOnce: subscribeOnce,
|
23
|
-
publish: publish,
|
24
|
-
countSubscriptions: () => Object.keys(eventSubscriptionDictionary).length
|
25
|
-
}
|