@5minds/node-red-contrib-processcube 7.7.1-develop-716de1-mkynb1ql → 7.7.1-develop-016853-mkynel2k
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/externaltask-input.js +6 -186
- package/package.json +1 -1
package/externaltask-input.js
CHANGED
|
@@ -144,110 +144,6 @@ module.exports = function (RED) {
|
|
|
144
144
|
|
|
145
145
|
node._subscribed = true;
|
|
146
146
|
node._subscribed_error = null;
|
|
147
|
-
node._trace = '';
|
|
148
|
-
node._step = '';
|
|
149
|
-
node._tracking_nodes = {};
|
|
150
|
-
node._join_inputs = {};
|
|
151
|
-
node._tracking_for_etw = {};
|
|
152
|
-
|
|
153
|
-
node.isHandling = () => {
|
|
154
|
-
return Object.keys(node.started_external_tasks).length > 0;
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
node.ownMessage = (msg) => {
|
|
158
|
-
return msg.etw_input_node_id === node.id;
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
node.clearTracking = (msg) => {
|
|
162
|
-
if (msg.flowNodeInstanceId) {
|
|
163
|
-
node._tracking_for_etw[msg.flowNodeInstanceId].forEach((theNode) => {
|
|
164
|
-
node.decrMsgOnNode(theNode, msg);
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
node.incMsgOnNode = (theNode, msg) => {
|
|
170
|
-
if (node.id === theNode.id) {
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if (!node._tracking_nodes[theNode.id]) {
|
|
175
|
-
node._tracking_nodes[theNode.id] = {
|
|
176
|
-
node: theNode,
|
|
177
|
-
count: 1,
|
|
178
|
-
};
|
|
179
|
-
} else {
|
|
180
|
-
node._tracking_nodes[theNode.id].count++;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
// bei nodes vom type 'join' müssen die eingänge gezählt werden,
|
|
184
|
-
// dass diese dann wieder beim verlassen am ausgang gesamt entfernt werden müssem
|
|
185
|
-
if (theNode.type === 'join') {
|
|
186
|
-
if (!node._join_inputs[theNode.id]) {
|
|
187
|
-
node._join_inputs[theNode.id] = {};
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
if (!node._join_inputs[theNode.id][msg.flowNodeInstanceId]) {
|
|
191
|
-
node._join_inputs[theNode.id][msg.flowNodeInstanceId] = 1;
|
|
192
|
-
} else {
|
|
193
|
-
node._join_inputs[theNode.id][msg.flowNodeInstanceId]++;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
if (!node._tracking_for_etw[msg.flowNodeInstanceId]) {
|
|
198
|
-
node._tracking_for_etw[msg.flowNodeInstanceId] = [];
|
|
199
|
-
node._tracking_for_etw[msg.flowNodeInstanceId].push(theNode);
|
|
200
|
-
} else {
|
|
201
|
-
node._tracking_for_etw[msg.flowNodeInstanceId].push(theNode);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
theNode.status({ fill: 'blue', shape: 'dot', text: `tasks(${node._tracking_nodes[theNode.id].count})` });
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
node.decrMsgOnNode = (theNode, msg) => {
|
|
208
|
-
if (node.id === theNode.id) {
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// bei nodes vom type 'join' müssen die eingänge gezählt werden,
|
|
213
|
-
// dass diese dann wieder beim verlassen am ausgang gesamt entfernt werden müssen
|
|
214
|
-
let dec_count = 1;
|
|
215
|
-
|
|
216
|
-
if (theNode.type === 'join') {
|
|
217
|
-
if (!node._join_inputs[theNode.id]) {
|
|
218
|
-
node._join_inputs[theNode.id] = {};
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
if (node._join_inputs[theNode.id][msg.flowNodeInstanceId]) {
|
|
222
|
-
dec_count = node._join_inputs[theNode.id][msg.flowNodeInstanceId];
|
|
223
|
-
delete node._join_inputs[theNode.id][msg.flowNodeInstanceId];
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
if (!node._tracking_nodes[theNode.id]) {
|
|
228
|
-
node._tracking_nodes[theNode.id] = {
|
|
229
|
-
node: theNode,
|
|
230
|
-
count: 0,
|
|
231
|
-
};
|
|
232
|
-
} else {
|
|
233
|
-
//node._tracking_nodes[theNode.id].count--;
|
|
234
|
-
node._tracking_nodes[theNode.id].count =- dec_count;
|
|
235
|
-
|
|
236
|
-
if (node._tracking_nodes[theNode.id].count <= 0) {
|
|
237
|
-
node._tracking_nodes[theNode.id].count = 0;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
if (node._tracking_for_etw[msg.flowNodeInstanceId]) {
|
|
242
|
-
const count_nodes = node._tracking_for_etw[msg.flowNodeInstanceId].filter(item => item !== theNode)
|
|
243
|
-
|
|
244
|
-
if (count_nodes <= 0) {
|
|
245
|
-
delete node._tracking_for_etw[msg.flowNodeInstanceId];
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
theNode.status({ fill: 'blue', shape: 'dot', text: `tasks(${node._tracking_nodes[theNode.id].count})` });
|
|
250
|
-
};
|
|
251
147
|
|
|
252
148
|
node.traceExecution = (msg) => {
|
|
253
149
|
if ((node._traces || []).includes(msg.event)) {
|
|
@@ -266,70 +162,6 @@ module.exports = function (RED) {
|
|
|
266
162
|
}
|
|
267
163
|
};
|
|
268
164
|
|
|
269
|
-
const onPreDeliver = (sendEvent) => {
|
|
270
|
-
try {
|
|
271
|
-
if (node.isHandling() && node.ownMessage(sendEvent.msg)) {
|
|
272
|
-
|
|
273
|
-
const sourceNode = sendEvent?.source?.node;
|
|
274
|
-
const destinationNode = sendEvent?.destination?.node;
|
|
275
|
-
|
|
276
|
-
node._step = `${destinationNode.name || destinationNode.type}`;
|
|
277
|
-
|
|
278
|
-
node.showStatus();
|
|
279
|
-
|
|
280
|
-
const debugMsg = {
|
|
281
|
-
event: 'enter',
|
|
282
|
-
sourceName: sourceNode.name,
|
|
283
|
-
sourceType: sourceNode.type,
|
|
284
|
-
destinationNodeName: destinationNode.name,
|
|
285
|
-
destinationNodeType: destinationNode.type,
|
|
286
|
-
timestamp: new Date().toISOString(),
|
|
287
|
-
};
|
|
288
|
-
|
|
289
|
-
node.traceExecution(debugMsg);
|
|
290
|
-
|
|
291
|
-
if (process.env.NODE_RED_ETW_STEP_LOGGING == 'true' || process.env.NODERED_ETW_STEP_LOGGING == 'true') {
|
|
292
|
-
node._trace = `'${sourceNode.name || sourceNode.type}'->'${destinationNode.name || destinationNode.type}'`;
|
|
293
|
-
node.log(`preDeliver: ${node._trace}`);
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
} catch (error) {
|
|
297
|
-
node.error(`Error in onPreDeliver: ${error?.message}`, { error: error });
|
|
298
|
-
}
|
|
299
|
-
};
|
|
300
|
-
RED.hooks.add(`preDeliver.etw-input-${node.id}`, onPreDeliver);
|
|
301
|
-
|
|
302
|
-
const onPostDeliver = (sendEvent) => {
|
|
303
|
-
try {
|
|
304
|
-
if (node.isHandling() && node.ownMessage(sendEvent.msg)) {
|
|
305
|
-
const sourceNode = sendEvent?.source?.node;
|
|
306
|
-
const destinationNode = sendEvent?.destination?.node;
|
|
307
|
-
|
|
308
|
-
node.decrMsgOnNode(sourceNode, sendEvent.msg);
|
|
309
|
-
node.incMsgOnNode(destinationNode, sendEvent.msg);
|
|
310
|
-
|
|
311
|
-
const debugMsg = {
|
|
312
|
-
event: 'exit',
|
|
313
|
-
sourceName: sourceNode.name,
|
|
314
|
-
sourceType: sourceNode.type,
|
|
315
|
-
destinationNodeName: destinationNode.name,
|
|
316
|
-
destinationNodeType: destinationNode.type,
|
|
317
|
-
timestamp: new Date().toISOString(),
|
|
318
|
-
};
|
|
319
|
-
|
|
320
|
-
node.traceExecution(debugMsg);
|
|
321
|
-
|
|
322
|
-
if (process.env.NODE_RED_ETW_STEP_LOGGING == 'true' || process.env.NODERED_ETW_STEP_LOGGING == 'true') {
|
|
323
|
-
node._trace = `'${sourceNode.name || sourceNode.type}'->'${destinationNode.name || destinationNode.type}'`;
|
|
324
|
-
node.log(`postDeliver: ${node._trace}`);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
} catch (error) {
|
|
328
|
-
node.error(`Error in onPostDeliver: ${error?.message}`, { error: error });
|
|
329
|
-
}
|
|
330
|
-
};
|
|
331
|
-
RED.hooks.add(`postDeliver.etw-input-${node.id}`, onPostDeliver);
|
|
332
|
-
|
|
333
165
|
node.setSubscribedStatus = () => {
|
|
334
166
|
this._subscribed = true;
|
|
335
167
|
this._subscribed_error = null;
|
|
@@ -367,8 +199,6 @@ module.exports = function (RED) {
|
|
|
367
199
|
node.setFinishHandlingTaskStatus = (externalTask) => {
|
|
368
200
|
if (externalTask.flowNodeInstanceId) {
|
|
369
201
|
delete this.started_external_tasks[externalTask.flowNodeInstanceId];
|
|
370
|
-
node._trace = '';
|
|
371
|
-
node._step = '';
|
|
372
202
|
}
|
|
373
203
|
|
|
374
204
|
this._subscribed = true;
|
|
@@ -383,7 +213,6 @@ module.exports = function (RED) {
|
|
|
383
213
|
|
|
384
214
|
node.traceExecution(debugMsg);
|
|
385
215
|
|
|
386
|
-
this.clearTracking(externalTask); // as msg
|
|
387
216
|
this.showStatus();
|
|
388
217
|
};
|
|
389
218
|
|
|
@@ -423,22 +252,15 @@ module.exports = function (RED) {
|
|
|
423
252
|
|
|
424
253
|
if (this._subscribed === false) {
|
|
425
254
|
this.status({ fill: 'red', shape: 'ring', text: `subscription failed (${msgCounter})` });
|
|
426
|
-
|
|
427
255
|
this.sendStatus('NotOk', `subscription failed (${msgCounter})`);
|
|
428
256
|
} else {
|
|
429
257
|
if (msgCounter >= 1) {
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
this.sendStatus('Ok', `tasks(${msgCounter}) ->'${node._step}'.`);
|
|
433
|
-
} else {
|
|
434
|
-
this.status({ fill: 'blue', shape: 'dot', text: `tasks(${msgCounter})` });
|
|
435
|
-
this.sendStatus('Ok', `tasks(${msgCounter})`);
|
|
436
|
-
}
|
|
437
|
-
this.log(`handling tasks ${msgCounter}.`);
|
|
258
|
+
this.status({ fill: 'blue', shape: 'dot', text: `tasks(${msgCounter})` });
|
|
259
|
+
this.sendStatus('Ok', `tasks(${msgCounter})`);
|
|
438
260
|
} else {
|
|
439
|
-
this.status({ fill: 'green', shape: 'ring', text: `
|
|
440
|
-
this.sendStatus('Ok', `
|
|
441
|
-
}
|
|
261
|
+
this.status({ fill: 'green', shape: 'ring', text: `subscribed` });
|
|
262
|
+
this.sendStatus('Ok', `subscribed`);
|
|
263
|
+
}
|
|
442
264
|
}
|
|
443
265
|
};
|
|
444
266
|
|
|
@@ -560,7 +382,7 @@ module.exports = function (RED) {
|
|
|
560
382
|
client.externalTasks
|
|
561
383
|
.subscribeToExternalTaskTopic(topic, etwCallback, options)
|
|
562
384
|
.then(async (externalTaskWorker) => {
|
|
563
|
-
node.status({ fill: 'blue', shape: 'ring', text: '
|
|
385
|
+
node.status({ fill: 'blue', shape: 'ring', text: 'subscribed' });
|
|
564
386
|
|
|
565
387
|
node.etw = externalTaskWorker;
|
|
566
388
|
|
|
@@ -614,8 +436,6 @@ module.exports = function (RED) {
|
|
|
614
436
|
node.on('close', () => {
|
|
615
437
|
try {
|
|
616
438
|
externalTaskWorker.stop();
|
|
617
|
-
RED.hooks.remove(`preDeliver.etw-input-${node.id}`);
|
|
618
|
-
RED.hooks.remove(`postDeliver.etw-input-${node.id}`);
|
|
619
439
|
node.log('External Task Worker closed.');
|
|
620
440
|
} catch (error) {
|
|
621
441
|
node.error(`Client close failed: ${JSON.stringify(error)}`);
|