Git Product home page Git Product logo

Comments (1)

anna-geller avatar anna-geller commented on September 27, 2024

One possibility with BEFORE and AFTER checks:

id: ecommerce-order-processing
namespace: ecommerce
description: E-commerce Order Processing Workflow

inputs:
  - id: orderId
    type: STRING

tasks:
  - id: checkInventory
    type: io.kestra.plugin.fs.http.Request
    description: Check inventory for the order items
    uri: http://inventory-service/check
    contentType: multipart/form-data
    formData:
      orderId: "{{ inputs.orderId }}"

  - id: processPayment
    type: io.kestra.plugin.fs.http.Request
    description: Process payment for the order
    uri: http://payment-service/process
    formData:
      orderId: "{{ inputs.ordered }}"    
    checks: 
      - type: BEFORE
        description: Check stock before accepting payment
        condition: "{{ outputs.checkInventory.body.inventoryAvailable == true }}"
        onConditionFail:
          - type: RUN_SUBFLOW
            flowId: alerting_flow_id
            namespace: myteam
          - type: SET_TASK_RUN_STATE
            state: WARNING # FAILED, WARNING, CANCELLED, KILLED

      - type: AFTER
        description: Validate payment result
        condition: "{{ outputs.processPayment.body.paymentResult == true }}"
        onConditionFail: # optional, by default failed condition leads to failing the taskrun
          - type: SET_TASK_RUN_STATE
            state: CANCELLED # FAILED, WARNING, CANCELLED, KILLED
    
  - id: orderConfirmation
    type: io.kestra.plugin.fs.http.Request
    description: Confirm the order and notify the customer
    uri: http://order-service/confirm
    formData:
      orderId: "{{ inputs.orderId }}"

  - id: arrangeShipping
    type: io.kestra.plugin.fs.http.Request
    description: Arrange shipping for the order
    uri: http://shipping-service/arrange
    formData:
      orderId: "{{ inputs.orderId }}"
    checks:
      - type: BEFORE
        condition: "{{ outputs.orderConfirmation.body.status == 'SUCCESS' }}"
        description: Check stock before accepting payment        
      - type: AFTER
        condition: "{{ outputs.arrangeShipping.body.status == 'SUCCESS' }}"

  - id: updateDeliveryStatus
    type: io.kestra.plugin.fs.http.Request
    description: Update the delivery status of the order
    uri: http://delivery-service/updateStatus
    formData:
      orderId: "{{ inputs.orderId }}"

taskDefaults:
  - type: io.kestra.plugin.fs.http.Request
    values:
      contentType: multipart/form-data
      method: POST 

from kestra.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.