break recursive loop

Introduce a internal var: up_runtime_task_layer_number. It is used for a force exit or an conditional break. The typical usecase would be a business logic to attempt to maximize the possibility ub a recurisve maner in code execution to probe. For example, web page scraping and a implementation of web spider etc.

Demo

source

Main task yaml file
    tasks:
    - name: task
      task:
      - func: call
        do:
        - layer2
    - name: layer2
      task:
      - func: cmd
        do:
        - name: print
          cmd: 'up_runtime_task_layer_number: {{.up_runtime_task_layer_number}}'
      - func: call
        do:
        - layer3
    - name: layer3
      task:
      - func: cmd
        do:
        - name: exit #or break
        if: '{{eq  .up_runtime_task_layer_number 4}}'
      - func: call
        do:
        - layer2
    
Main log file
    loading [Config]:  ./tests/functests/upconfig.yml
    Main config:
                 Version -> 1.0.0
                  RefDir -> ./tests/functests
                 WorkDir -> cwd
              AbsWorkDir -> /up_project/up
                TaskFile -> f0125
                 Verbose -> vvv
              ModuleName -> self
               ShellType -> /bin/sh
           MaxCallLayers -> 8
                 Timeout -> 3600000
     MaxModuelCallLayers -> 256
               EntryTask -> task
      ModRepoUsernameRef -> 
      ModRepoPasswordRef -> 
    work dir: /up_project/up
    -exec task: task
    loading [Task]:  ./tests/functests/f0125
    module: [self], instance id: [dev], exec profile: []
    profile -  envVars:
    
    (*core.Cache)({
    })
    
    Task1: [task ==> task:  ]
    -Step1:
    self: final context exec vars:
    
    (*core.Cache)({
      "up_runtime_task_layer_number": 0
    })
    
    =Task2: [task ==> layer2:  ]
    --Step1:
    self: final context exec vars:
    
    (*core.Cache)({
      "up_runtime_task_layer_number": 1
    })
    
    ~~SubStep1: [print:  ]
    up_runtime_task_layer_number: 1
    --Step2:
    self: final context exec vars:
    
    (*core.Cache)({
      "up_runtime_task_layer_number": 1
    })
    
    ==Task3: [task/layer2 ==> layer3:  ]
    ---Step1:
    self: final context exec vars:
    
    (*core.Cache)({
      "up_runtime_task_layer_number": 2
    })
    
    condition failed, skip executing step 
    
    ---Step2:
    self: final context exec vars:
    
    (*core.Cache)({
      "up_runtime_task_layer_number": 2
    })
    
    ===Task2: [task/layer2/layer3 ==> layer2:  ]
    ----Step1:
    self: final context exec vars:
    
    (*core.Cache)({
      "up_runtime_task_layer_number": 3
    })
    
    ~~~~SubStep1: [print:  ]
    up_runtime_task_layer_number: 3
    ----Step2:
    self: final context exec vars:
    
    (*core.Cache)({
      "up_runtime_task_layer_number": 3
    })
    
    ====Task3: [task/layer2/layer3/layer2 ==> layer3:  ]
    -----Step1:
    self: final context exec vars:
    
    (*core.Cache)({
      "up_runtime_task_layer_number": 4
    })
    
    ~~~~~SubStep1: [exit:  ]
      Exit: exit [client choose to exit]
    
Logs with different verbose level
Raw logs with different verbose level

Other references: