jensrossbach / node-red-contrib-chronos

Time-based Node-RED scheduling, repeating, queueing, routing, filtering and manipulating nodes
https://jensrossbach.github.io/node-red-contrib-chronos
MIT License
28 stars 1 forks source link

Optimize scheduler resource usage #166

Closed jensrossbach closed 3 months ago

jensrossbach commented 3 months ago

This pull request optimizes the resource usage of the scheduler node by reducing the number of scheduled timers. Instead of one timer per enabled event, only a single timer for the next upcoming enabled event is started. Additionally the usage of the Node-RED event flows:started for delaying next event messages after node start until flows have been set up has been replaced by a fixed delay that is customizable and by default 0.1 seconds. Reason is that this event is an undocumented internal Node-RED event that shouldn't be used by nodes as it can be removed/changed at any time and also has some restrictions related to maximum number of allowed events. The fixed delay is optional and is used for any message being sent directly after start of the node.