Hi everyone,
I am calling a REST API with the http request node inside nested split nodes. I would like to limit the API calls to an arbitrary rate.
The Delay node in Rate Limit mode does the trick, but as soon as I nest the split nodes, simultaneous calls occur to the REST API. I need to nest as I need to feed the result (JSON array) of the API call into the next split.
I want to limit the http request calls to the REST API to one every three seconds.
The current output is:
Time Calls
0 A, X (simultaneous calls)
3 B, Y (simultaneous calls)
6 C, X (simultaneous calls)
9 Y
12 X
15 Y
My desired output:
Time Calls
0 A
3 X
6 Y
9 B
12 X
15 Y
18 C
21 X
24 Y
I suspect using a function node with a flush to the delay node would help but I cannot figure it out.
On second thoughts I think my problem is related to the how the split works. It parallels everything. I was assuming that it works serially.
Can anyone please provide some here. My goal looks like making the split nodes execute serially in a loop.
Cheers,
Chris
here is a simplified flow that represents my challenge
[
{
"id": "058fb5958f470e48",
"type": "tab",
"label": "Flow 2",
"disabled": false,
"info": "",
"env": []
},
{
"id": "56dd7928a9459d2a",
"type": "inject",
"z": "058fb5958f470e48",
"name": "[\"A\", \"B\", \"C\"]",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "[\"A\", \"B\", \"C\"]",
"payloadType": "json",
"x": 170,
"y": 160,
"wires": [
[
"710df86d6b197cff"
]
]
},
{
"id": "710df86d6b197cff",
"type": "split",
"z": "058fb5958f470e48",
"name": "",
"splt": "\\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "",
"x": 350,
"y": 160,
"wires": [
[
"df33284335bffebb"
]
]
},
{
"id": "b27cdeaac4471314",
"type": "debug",
"z": "058fb5958f470e48",
"name": "Debug ABC",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 710,
"y": 100,
"wires": []
},
{
"id": "0be44aaa65e1f281",
"type": "template",
"z": "058fb5958f470e48",
"name": "[\"X\", \"Y\"]",
"field": "payload",
"fieldType": "msg",
"format": "handlebars",
"syntax": "mustache",
"template": "[\"X\", \"Y\"]",
"output": "json",
"x": 880,
"y": 160,
"wires": [
[
"b1668ae01e9f46d7"
]
]
},
{
"id": "5c55a06787c9d3a2",
"type": "split",
"z": "058fb5958f470e48",
"name": "",
"splt": "\\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "",
"x": 210,
"y": 300,
"wires": [
[
"aed2a5c75af4b18d"
]
]
},
{
"id": "96cb8e104a0d6bd4",
"type": "debug",
"z": "058fb5958f470e48",
"name": "Debug XY",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 600,
"y": 240,
"wires": []
},
{
"id": "539fc7d2d2d7fa6c",
"type": "function",
"z": "058fb5958f470e48",
"name": "Placeholder\\n HTTP Req",
"func": "\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 610,
"y": 300,
"wires": [
[
"05f98fa8bb5b6880"
]
]
},
{
"id": "d35c94d55a345441",
"type": "function",
"z": "058fb5958f470e48",
"name": "Placeholder\\n HTTP Req",
"func": "msg.payloadsplit1 = msg.payload;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 710,
"y": 160,
"wires": [
[
"0be44aaa65e1f281"
]
]
},
{
"id": "c13782c0a9c6f5ef",
"type": "join",
"z": "058fb5958f470e48",
"name": "",
"mode": "auto",
"build": "object",
"property": "payload",
"propertyType": "msg",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"accumulate": "false",
"timeout": "",
"count": "",
"reduceRight": false,
"x": 950,
"y": 300,
"wires": [
[
"2371ebc235e95b3f"
]
]
},
{
"id": "b1668ae01e9f46d7",
"type": "link out",
"z": "058fb5958f470e48",
"name": "link out 14",
"mode": "link",
"links": [
"6d796ef8be569c35"
],
"x": 985,
"y": 160,
"wires": []
},
{
"id": "6d796ef8be569c35",
"type": "link in",
"z": "058fb5958f470e48",
"name": "link in 14",
"links": [
"b1668ae01e9f46d7"
],
"x": 115,
"y": 300,
"wires": [
[
"5c55a06787c9d3a2"
]
]
},
{
"id": "df33284335bffebb",
"type": "delay",
"z": "058fb5958f470e48",
"name": "",
"pauseType": "rate",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "3",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 520,
"y": 160,
"wires": [
[
"d35c94d55a345441",
"b27cdeaac4471314"
]
]
},
{
"id": "aed2a5c75af4b18d",
"type": "delay",
"z": "058fb5958f470e48",
"name": "",
"pauseType": "rate",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "3",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 400,
"y": 300,
"wires": [
[
"539fc7d2d2d7fa6c",
"96cb8e104a0d6bd4"
]
]
},
{
"id": "05f98fa8bb5b6880",
"type": "join",
"z": "058fb5958f470e48",
"name": "",
"mode": "auto",
"build": "object",
"property": "payload",
"propertyType": "msg",
"key": "topic",
"joiner": "\\n",
"joinerType": "str",
"accumulate": "false",
"timeout": "",
"count": "",
"reduceRight": false,
"x": 790,
"y": 300,
"wires": [
[
"c13782c0a9c6f5ef",
"f16f170955f3a4c6"
]
]
},
{
"id": "f16f170955f3a4c6",
"type": "debug",
"z": "058fb5958f470e48",
"name": "debug 89",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 960,
"y": 240,
"wires": []
},
{
"id": "2371ebc235e95b3f",
"type": "debug",
"z": "058fb5958f470e48",
"name": "debug 90",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 1140,
"y": 240,
"wires": []
}
]