@siglesiasg/node-red-event-manager
Advanced tools
Comparing version 0.0.8 to 0.0.9
@@ -16,2 +16,3 @@ import { NodeStatusFill } from "node-red"; | ||
stopConsumingEvents(): void; | ||
isConsumingEvents(): boolean; | ||
checkEvent(): void; | ||
@@ -18,0 +19,0 @@ setConsumeEvents(callback: (element: T) => void): void; |
@@ -34,2 +34,5 @@ "use strict"; | ||
} | ||
isConsumingEvents() { | ||
return this.isConsuming; | ||
} | ||
checkEvent() { | ||
@@ -36,0 +39,0 @@ if (this.currentlyUncheckedEvents === 0) { |
@@ -5,4 +5,5 @@ import { NodeDef } from 'node-red'; | ||
maxConcurrency: number; | ||
consumeEventsOnStart: string; | ||
debugStatus: string; | ||
} | ||
//# sourceMappingURL=event-manager-dispatcher.def.d.ts.map |
@@ -10,5 +10,10 @@ "use strict"; | ||
const eventsQueue = new events_queue_1.EventsQueue(config.maxConcurrency); | ||
eventsQueue.startConsumingEvents(); | ||
if ('true' === config.consumeEventsOnStart) { | ||
eventsQueue.startConsumingEvents(); | ||
this.status({ fill: 'green', shape: 'dot', text: 'Consuming events' }); | ||
} | ||
else { | ||
this.status({ fill: 'yellow', shape: 'dot', text: 'Not consuming events' }); | ||
} | ||
(0, node_red_utils_1.addSharedData)(this, 'eventsQueue', eventsQueue); | ||
this.status({ fill: 'green', shape: 'dot', text: 'Ready' }); | ||
eventsQueue.setConsumeEvents((msg) => { | ||
@@ -28,2 +33,5 @@ if ('true' === config.debugStatus) { | ||
} | ||
if (!eventsQueue.isConsumingEvents()) { | ||
this.status({ fill: 'yellow', shape: 'dot', text: `Not consuming events. In queue: ${eventsQueue.size()}` }); | ||
} | ||
eventsQueue.enqueue(msg); | ||
@@ -52,2 +60,12 @@ if ('true' === config.debugStatus) { | ||
} | ||
if (payload.consumeEvents || payload.consumeEvents === false) { | ||
if (payload.consumeEvents) { | ||
node.status({ fill: 'green', shape: 'dot', text: 'Consuming events' }); | ||
eventsQueue.startConsumingEvents(); | ||
} | ||
else { | ||
node.status({ fill: 'yellow', shape: 'dot', text: `Not consuming events. In queue: ${eventsQueue.size()}` }); | ||
eventsQueue.stopConsumingEvents(); | ||
} | ||
} | ||
if ('true' === config.debugStatus) { | ||
@@ -54,0 +72,0 @@ node.status({ fill: eventsQueue.isPrintStatusWarning(), shape: 'dot', text: `${eventsQueue.printStatus()}` }); |
@@ -147,4 +147,5 @@ [ | ||
"maxConcurrency": "30", | ||
"consumeEventsOnStart": "false", | ||
"debugStatus": "false", | ||
"x": 300, | ||
"x": 430, | ||
"y": 140, | ||
@@ -170,3 +171,3 @@ "wires": [ | ||
"statusType": "msg", | ||
"x": 800, | ||
"x": 880, | ||
"y": 40, | ||
@@ -217,3 +218,3 @@ "wires": [] | ||
"statusType": "auto", | ||
"x": 780, | ||
"x": 900, | ||
"y": 140, | ||
@@ -239,3 +240,3 @@ "wires": [] | ||
"outputs": 1, | ||
"x": 540, | ||
"x": 680, | ||
"y": 140, | ||
@@ -255,3 +256,3 @@ "wires": [ | ||
"debugStatus": "false", | ||
"x": 770, | ||
"x": 910, | ||
"y": 200, | ||
@@ -282,3 +283,3 @@ "wires": [] | ||
"x": 180, | ||
"y": 220, | ||
"y": 140, | ||
"wires": [ | ||
@@ -295,3 +296,3 @@ [ | ||
"name": "", | ||
"x": 400, | ||
"x": 460, | ||
"y": 60, | ||
@@ -306,3 +307,61 @@ "wires": [ | ||
] | ||
}, | ||
{ | ||
"id": "2f91eae919466c99", | ||
"type": "inject", | ||
"z": "c6cc7badd6dabaa4", | ||
"name": "Enable consuming", | ||
"props": [ | ||
{ | ||
"p": "payload" | ||
}, | ||
{ | ||
"p": "topic", | ||
"vt": "str" | ||
} | ||
], | ||
"repeat": "", | ||
"crontab": "", | ||
"once": false, | ||
"onceDelay": 0.1, | ||
"topic": "", | ||
"payload": "{\"isEventManagerConfig\": \"true\", \"consumeEvents\": true}", | ||
"payloadType": "json", | ||
"x": 150, | ||
"y": 180, | ||
"wires": [ | ||
[ | ||
"0bfa8732a2ca82d6" | ||
] | ||
] | ||
}, | ||
{ | ||
"id": "2c9a85f0fe5fef4e", | ||
"type": "inject", | ||
"z": "c6cc7badd6dabaa4", | ||
"name": "Disable consuming", | ||
"props": [ | ||
{ | ||
"p": "payload" | ||
}, | ||
{ | ||
"p": "topic", | ||
"vt": "str" | ||
} | ||
], | ||
"repeat": "", | ||
"crontab": "", | ||
"once": false, | ||
"onceDelay": 0.1, | ||
"topic": "", | ||
"payload": "{\"isEventManagerConfig\": \"true\", \"consumeEvents\": false}", | ||
"payloadType": "json", | ||
"x": 150, | ||
"y": 220, | ||
"wires": [ | ||
[ | ||
"0bfa8732a2ca82d6" | ||
] | ||
] | ||
} | ||
] |
{ | ||
"name": "@siglesiasg/node-red-event-manager", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "Event Manager for Node Red", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -13,6 +13,6 @@ # Event Manager Dispatcher | ||
- **Event Manager Dispatcher:** Emits messages based on slot availability, storing them in memory until a free slot becomes available. Configuration options include dynamic updates for maximum concurrency. | ||
- **Event Manager Checkpoint:** Allows marking the completion of message execution and enables the emission of new messages from the `event-manager-dispatcher` node. | ||
- **Event Manager Dispatcher:** Emits messages based on slot availability, storing them in memory until a free slot becomes available. Configuration options include dynamic updates for maximum concurrency. | ||
### Key Features | ||
@@ -19,0 +19,0 @@ |
@@ -50,2 +50,6 @@ import { NodeStatusFill } from "node-red"; | ||
isConsumingEvents(): boolean { | ||
return this.isConsuming; | ||
} | ||
checkEvent() { | ||
@@ -52,0 +56,0 @@ if (this.currentlyUncheckedEvents === 0) { |
@@ -6,3 +6,4 @@ import { NodeDef } from 'node-red'; | ||
maxConcurrency: number; | ||
consumeEventsOnStart: string; | ||
debugStatus: string; | ||
} |
@@ -18,3 +18,8 @@ import { Node, NodeAPI, NodeMessageInFlow } from 'node-red'; | ||
const eventsQueue = new EventsQueue<NodeMessageInFlow>(config.maxConcurrency); | ||
eventsQueue.startConsumingEvents(); | ||
if ('true' === config.consumeEventsOnStart) { | ||
eventsQueue.startConsumingEvents(); | ||
this.status({ fill: 'green', shape: 'dot', text: 'Consuming events' }); | ||
} else { | ||
this.status({ fill: 'yellow', shape: 'dot', text: 'Not consuming events' }); | ||
} | ||
@@ -24,7 +29,5 @@ // Save link | ||
this.status({ fill: 'green', shape: 'dot', text: 'Ready' }); | ||
eventsQueue.setConsumeEvents((msg) => { | ||
// Update node status | ||
// Debug node status | ||
if ('true' === config.debugStatus) { | ||
@@ -43,11 +46,17 @@ this.status({ fill: eventsQueue.isPrintStatusWarning(), shape: 'dot', text: `${eventsQueue.printStatus()}` }); | ||
/** On Input */ | ||
/** On Input -> Check if it's a config message or enqueue all messages */ | ||
this.on('input', async (msg: NodeMessageInFlow, send, done) => { | ||
try { | ||
// Message of loading config | ||
if (dinamicConfig(this, msg)) { | ||
done(); | ||
return; | ||
return; // Do not enqueue this message | ||
} | ||
if (!eventsQueue.isConsumingEvents()) { | ||
this.status({ fill: 'yellow', shape: 'dot', text: `Not consuming events. In queue: ${eventsQueue.size()}` }); | ||
} | ||
// Enqueue message to be sent | ||
eventsQueue.enqueue(msg); | ||
@@ -81,2 +90,4 @@ | ||
if (payload && (payload.isEventManagerConfig === true || payload.isEventManagerConfig === 'true')) { | ||
// Set the concurrency | ||
if (payload.maxConcurrency && !isNaN(+payload.maxConcurrency)) { | ||
@@ -86,2 +97,12 @@ eventsQueue.setMaxConcurrency(Number(payload.maxConcurrency)); | ||
if (payload.consumeEvents || payload.consumeEvents === false) { | ||
if (payload.consumeEvents) { | ||
node.status({ fill: 'green', shape: 'dot', text: 'Consuming events' }); | ||
eventsQueue.startConsumingEvents(); | ||
} else { | ||
node.status({ fill: 'yellow', shape: 'dot', text: `Not consuming events. In queue: ${eventsQueue.size()}` }); | ||
eventsQueue.stopConsumingEvents(); | ||
} | ||
} | ||
// Print debug | ||
if ('true' === config.debugStatus) { | ||
@@ -88,0 +109,0 @@ node.status({ fill: eventsQueue.isPrintStatusWarning(), shape: 'dot', text: `${eventsQueue.printStatus()}` }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
315267
1479