# Gate node using Blockly

**URL:** <https://discourse.nodered.org/t/gate-node-using-blockly/2830>\
**Category:** Share Your Nodes\
**Created:** [4 September 2018 11:47 UTC](https://discourse.nodered.org/t/gate-node-using-blockly/2830 "2018-09-04T11:47:41Z")\
**Posts on this page:** 10\
**Page:** 2

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [6 September 2018 23:19 UTC](https://discourse.nodered.org/t/gate-node-using-blockly/2830/21 "2018-09-06T23:19:19Z")

</div>

> [@cymplecy](#):
>
> I was thinking that if messages are chosen to be queued rather than dropped, then if the gate is opened - they'd just all be sent thru at once - that's all the functionality I was thinking should be in it

I assumed it would work that way, but it's also useful, and no more difficult, to allow a "trigger" message to release messages one at a time. The improved version is shaping up as having three states, `closed`, `open`, and `queueing`, with pretty much the obvious behavior in each.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [6 September 2018 23:23 UTC](https://discourse.nodered.org/t/gate-node-using-blockly/2830/22 "2018-09-06T23:23:20Z")

</div>

> [@drmibell](#):
>
> but it's also useful, and no more difficult, to allow a "trigger" message to release messages one at a time

"and no more difficult" ????

I think it would need a delay loop inside the node, and parameter for rate and .... 🙂

---

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [6 September 2018 23:41 UTC](https://discourse.nodered.org/t/gate-node-using-blockly/2830/23 "2018-09-06T23:41:02Z")

</div>

> [@cymplecy](#):
>
> I think it would need a delay loop inside the node, and parameter for rate and .... 🙂

I wasn't thinking about rate-limiting inside the node, just one (external) trigger, one message released. (This is how `node-red-contrib-simple-queue` works, and anything more complicated would make my head hurt.)

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [7 September 2018 05:58 UTC](https://discourse.nodered.org/t/gate-node-using-blockly/2830/24 "2018-09-07T05:58:52Z")

</div>

Don't forget, that the delay node already has a rate limit mode that can drip feed messages through. There is also a to do item on the whiteboard to add a flush mode to release all the stored messages. This may well cover some of your simple use cases.

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [7 September 2018 08:16 UTC](https://discourse.nodered.org/t/gate-node-using-blockly/2830/25 "2018-09-07T08:16:41Z")

</div>

BTW If you could make it like this so we can toggle its state by pressing a button without having extra inject nodes around it (like I've done with my version of inject in my NodeTARTAN fork) that would be great 🙂

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/5/5cbfe1c12ceb9d18801918b452c75bda170b6526.png)

_Runs away very quickly before @dceejay gets here!_

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [7 September 2018 08:19 UTC](https://discourse.nodered.org/t/gate-node-using-blockly/2830/26 "2018-09-07T08:19:40Z")

</div>

Nope. If the node has an input, it should not have a button.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [7 September 2018 08:29 UTC](https://discourse.nodered.org/t/gate-node-using-blockly/2830/27 "2018-09-07T08:29:32Z")

</div>

It's still September... (ignoring all suggestions until Oct)

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [9 September 2018 19:32 UTC](https://discourse.nodered.org/t/gate-node-using-blockly/2830/28 "2018-09-09T19:32:27Z")

</div>

via trwitter \_ I saw this has just been published

> **[node-red-contrib-message-gate](https://flows.nodered.org/node/node-red-contrib-message-gate)**
>
> A gate for message

Interesting idea to have a separate control node I thought

Given me a great idea

But it will have to wait another 3 weeks before I dare mention it 🙂

---

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [3 October 2018 17:11 UTC](https://discourse.nodered.org/t/gate-node-using-blockly/2830/29 "2018-10-03T17:11:19Z")

</div>

I apologize to anyone who might have hoped for some follow-up to this discussion. Travel has kept me busy for a few weeks. Here is my update.

> [@drmibell](#):
>
> I will raise an issue against `node-red-contrib-simple-queue` to see whether it can be modified to meet @tilleul's needs.

Done (sort of). The author added a mechanism (as I understand it) that allows the user to define a message property that causes the message to be passed through instead of being queued. Only @tilleul can say whether that solves his problem.

> [@drmibell](#):
>
> I would like to publish `node-red-contrib-gate` on npm in its present form.

Done. To avoid confusion, I have re-named this as `node-red-contrib-simple-gate` and published it to the npm repository. I will post a description shortly.

> [@drmibell](#):
>
> I'll look into modifying my `gate` node to (optionally) queue messages that arrive while it is closed.

Done. The result is on GitHub at [node-red-contrib-queue-gate](https://github.com/drmibell/node-red-contrib-queue-gate). I think the node is usable, but it needs some tweaks before I publish to npm. In particular, the html file is a great display of my ignorance of html/css. Comments and suggestions are welcome.

---

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [13 October 2018 01:44 UTC](https://discourse.nodered.org/t/gate-node-using-blockly/2830/30 "2018-10-13T01:44:57Z")

</div>

Absent any comments about [node-red-contrib-queue-gate](https://github.com/drmibell/node-red-contrib-queue-gate)on GitHub, I will shortly publish the node to npm. It turns out that there were a few unexpected design issues related to transitions out of the `queueing` state, whether to limit the queue size, and (if so) what to do when the queue is full. The choices I made can be seen in the documentation. I hope you find the queueing feature useful. Comments are welcome.

[Previous page](https://discourse.nodered.org/t/gate-node-using-blockly/2830.md?page=1)
