10-08-2019 01:31 PM
I am curious about using recursive pipelines. I know the documentation says that we should not use pipelines in a recursive manner but for some solutions, I think it makes sense. I have created two pipelines: Recursion Parent and Recursion Child.The Recursion Parent passes in a simple js variable, $test which is set to 2 in this case. The Recursion Parent then calls the Recursion Child pipeline which then increments $test by 1 while subsequently decrementing the pipeline parameter param by 1. Once param == 0 then the Child pipeline stops and returns the value of $test and a status, in this case “completed”.
Recursive Parent Input
Recursive Parent Output
Recursive Child Input
Recursive Child Pipeline Execute
My question/point to this is: Why is recursion not supported? It obviously works with a minor work around.
10-10-2019 09:26 AM
Recursion is not supported because it’s too easy to lose control of the execution and have it start spawning child executions and overloading the Snaplex.
Can I ask what you’re trying to achieve?
10-11-2019 05:28 AM
My team wants to be able to get a list of pipelines that call other pipelines. For example:
Pipeline A calls Pipeline B. Pipeline B calls Pipeline C.
Using recursion is the most elegant, and in my opinion, the most correct way to traverse this type of list. Furthermore, we know that there is a limit to how many children can be called, for us it is about 50. For traversing pipelines, we will never have more than 4 or 5 nested children at a time.
10-11-2019 08:59 AM
Isn’t recursion where something calls itself?
You should be able to have A that calls B, and then B that calls C.
Sounds like maybe you’re just trying to implement looping (until param == 0)?
10-11-2019 09:05 AM
Not sure if it’s “legit” from SnapLogic’s perspective, but you can implement looping between parent/child pipelines. Have the child pipeline exposed via triggered task, then have parent pipeline use REST GET snap to call the child pipeline triggered task, and use the REST GET’s pagination features (Has Next & Next URL) to evaluate some criteria and re-GET the child pipeline until criteria is false.