全部產品
Search
文件中心

CloudFlow:成功步驟

更新時間:Jul 06, 2024

本文介紹了成功步驟和其相關使用樣本。

介紹

成功(Succeed)步驟用來提前結束一系列串列步驟,類似於程式設計語言中的return。FDL steps定義的步驟是串列的,通常一個步驟執行完成後會繼續執行後續步驟,而成功步驟不會繼續執行下一個步驟。成功步驟通常和選擇步驟結合使用,在選擇步驟條件滿足的情況下跳轉到一個成功步驟,從而不再執行其它步驟。

成功步驟包含以下屬性:

  • (必需)type:succeed表示該步驟是成功步驟。
  • (必需)name:步驟名稱。
  • (可選)inputMappings:輸入映射。
  • (可選)outputMappings:輸出映射。

樣本

下面的流程定義使用成功步驟提前結束執行流程。

  • 如果輸入中的status的值是ready,則會執行第一個條件選項的步驟pass1,然後執行final。由於final是成功步驟,其結束後不會繼續執行handle_failure步驟。
  • 如果輸入中的status的值是failed,則會執行第二個條件選項的跳轉,結束選擇步驟執行handle_failure
  • 如果輸入中不存在status或者status的值不是readyfailed,則會執行預設選項邏輯,即pass2handle_failure
version: v1
type: flow
steps:
  - type: choice
    name: mychoice
    choices:
      - condition: $.status == "ready"
        # choice with steps
        steps:
          - type: pass
            name: pass1
      - condition: $.status == "failed"
        # choice with goto
        goto: handle_failure
    default:
      # choice with both steps and goto
      steps:
        - type: pass
          name: pass2
      goto: handle_failure
  - type: succeed
    name: final
  - type: pass
    name: handle_failure