||The input value passed to this Sub flow (and hence to the shard or sequence of shards in this Sub flow).||
||The output of this Sub flow (which is the same as its input).||
||The shard or sequence of shards to execute in the Sub flow.||
Activates a shard or a sequence of shards independently, without consuming the input. I.e. the input of the Sub flow will also be its output regardless of the shards activated in this Sub flow.
In Shards a shard receives an input, processes it, and produces an output. Usually this output is different from the input that the shard processed.
However, in some cases, we want a shard (or a sequence of shards) to return the same value as its output that it received as an input. For example, when we want a shard to process the same input that its previous shard (or sequence of shards) processed, irrespective of the output created by the previous shard(s).
There is a pass-through parameter available for some shards (like
Match) that can allows these shards to pass-through their own input as their output. For other shards, we can use the
Sub shard (also called the
Sub flow) to acheive the same effect by wrapping the target shard(s) within the
Sub shard recieves an input, it passes that to the first shard contained within it. This shard processes the input and creates its own ouput that is then passed to the next shard in the sequence inside the
Sub flow. This continues till the last shard in the flow is reached. The output of this last shard is not used by the
Sub flow. Instead the
Sub flow outputs the same value that it had received as input.
Sub may seem to not use any of its internal shards' inputs or outputs, every variable assigned inside the
Sub will be available outside as well since the
Sub will always be executed. Hence, the inputs and outputs of the shards within the
Sub flow can be made available outside the
Sub by saving them into
As a result, this method gives a psuedo pass-through capabilty to any shard (if you wrap just that one shard with a
Sub shard) or to any sequence of shards (if you wrap a whole sequence of shards within a
Sub shards you can simulate even more flexible and powerful shard execution paths.
Sub has an alias
| which is more convenient to use.
| also removes the need to use
-> as, unlike
Sub, it doesn't require the parameter shards to be grouped together.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
[info] [shards/General/Sub/1.edn] input to Sub1: 5 [info] [shards/General/Sub/1.edn] Sub1 inner shard o/p | 5 * 2: 10 [info] [shards/General/Sub/1.edn] Sub1 output => input to Sub2: 5 [info] [shards/General/Sub/1.edn] Sub2 inner shard o/p | 5 * 3: 15 [info] [shards/General/Sub/1.edn] input to nested-Sub: 15 [info] [shards/General/Sub/1.edn] nested-Sub inner shard o/p | (5 * 3) * 2: 30 [info] [shards/General/Sub/1.edn] output from nested Sub: 15 [info] [shards/General/Sub/1.edn] Sub2 output => output: 5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
[info] [shards/General/Sub/2.edn] 10 [info] [shards/General/Sub/2.edn] 15 [info] [shards/General/Sub/2.edn] 30 [info] [shards/General/Sub/2.edn] output of the last `Sub` shard: 5 [info] [shards/General/Sub/2.edn] 200 [info] [shards/General/Sub/2.edn] 300 [info] [shards/General/Sub/2.edn] 600 [info] [shards/General/Sub/2.edn] output of the last `|` shard: 100