Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Flow Overview

Updated on 2024-11-12 GMT+08:00
NOTE:

Flows are available only in CN East-Shanghai1 and AP-Singapore.

Flows are distributed serverless applications. Visually orchestrate multiple independent serverless functions into an application in sequential, branch, or parallel mode using Low Code technology. In addition, diagnose and debug your applications through a monitoring and management platform.

This section describes flow components, component orchestration rules, expression operators, and configuration examples.

Components

There are multiple types of components. Drag, drop, configure, and connect components to visually orchestrate flows. Before using flows, understand the components described in Table 1.

Table 1 Components

Category

Name

Description

Components

Function

FunctionGraph functions. For details, see Creating a Function.

EG

EventGrid (EG) publishes events to a specified channel. For details about how to create resources, see the EG documentation.

Processors

Callback

Similar to manual review, this node blocks a function flow by conditions until the callback API is called to resume the flow.

Subflow

A flow can be incorporated into another one as its subflow.

Parallel branch

A flow can have multiple parallel branches, which will be executed at the same time. You can determine the next step of each branch.

Start

Start of a flow. A start node only has triggers, and each flow has one start node.

Error handling

Determines the next step in case of an execution failure.

Loop

Cyclically processes each element in an array. All subflows in a loop are executed each time.

Wait

Determines when the next step will be executed after the previous step is finished.

Service

Abstracts complex operations involving multiple functions and combines these functions into an atomic node for easy management.

Conditional branch

Determines whether to execute the next branch based on specified conditions.

Stop

Indicates the end of a flow.

Orchestration Rules

  • A flow must be a directed acyclic graph (DAG). It has a start node followed only by one node (except the error handling and stop nodes) and ends after another node. You can end a flow in the following ways:
    1. Do not connect any conditional, parallel, or start node to the last node of the flow.
    2. Add a stop node as the last node of the flow.
  • Component design rules
    Table 2 Trigger, function, and EG

    Type

    Description

    Mandatory

    Trigger

    • A flow can have a maximum of 10 triggers.
    • Triggers must be included in the start node.
    • Triggers cannot be connected to any other node.

    No

    Function

    • A flow can have a maximum of 99 functions.
    • A function connected to an error handling node can be connected to another node that is not start or error handling.
    • A function that is not connected to an error handling node can be connected to only one non-start node.

    No

    EG

    • A flow can have a maximum of 10 EG nodes.
    • An EG node connected to an error handling node can only be connected to another node that is not start or error handling.
    • An EG node that is not connected to an error handling node can be connected to only one non-start node.

    No

    Table 3 Processors

    Type

    Description

    Mandatory

    Callback

    For details about the constraints of callback nodes, see the function parameter in Table 2. Callback nodes cannot be subnodes of a service node.

    No

    Subflow

    A flow.

    No

    Parallel branch

    • Indicates that the connected branches will be executed concurrently.
    • A parallel branch connects 1 to 20 nodes that are not error handling, start, or stop.

    No

    Start

    • Indicates the start of a flow. Each flow has only one start node.
    • The start node must be followed by a node that is not stop or error handling.

    Yes

    Error handling

    Can be connected to a maximum of 10 nodes that are not start, stop, or error handling.

    No

    Loop

    Cyclically processes each element in an array. All subflows in a loop are executed each time.

    The subflows in a loop must satisfy the following rules:

    1. Start with a function or wait node.
    2. Only include function, wait, and error handling nodes.

    No

    Wait

    Can be connected to zero or one node that is not start or error handling.

    No

    Service

    Consists of multiple functions and can be connected to a stop node or an error handling node.

    No

    Conditional branch

    Connects 2 to 20 nodes that are not start, stop, or error handling.

    No

    Stop

    Not followed by any other node.

    No

Expression Operators

The expression for an error handling or conditional branch node is in the format "[JsonPath] + [logical operator] + [value]". For example, $.age >= 20.

JsonPath Description

Operator

Supported

Description

$

Y

The root element to query. This starts all regular expressions.

@

Y

The current node being processed.

.

Y

Subnode.

[ (, )]

Y

Array indexes.

[start:end]

Y

Array slice operator.

[?()]

Y

Filter expression, which must be evaluated to a Boolean value.

Examples

  • Simple values: JSON data example
    {  
         "fruits": [ "apple", "orange", "pear" ],  
         "vegetables": [{      
         "veggieName": "potato",
         "veggieLike": true    
          },     
          {       
              "veggieName": "broccoli",      
              "veggieLike": false    
          }] 
    }

    The $.fruits expression obtains all values under fruits.

    The result of $.fruits is ["apple","orange","pear"].

  • Simple filtering: JSON data example
    {   
           "fruits": [ "apple", "orange", "pear" ],
           "vegetables": [{ 
           "veggieName": "potato",
           "veggieLike": true
           },     
          { 
              "veggieName": "broccoli",
              "veggieLike": false     
          }] 
    }

    Expression: $.vegetables[?(@.veggieLike == true)].veggieName

    Meaning: Obtains all values of the key vegetables and outputs the value of veggieName whose veggieLike is True.

    Result: [potato]

Logical Operators

The following data is used as input parameters in the examples:

{
  "name" : "apple",
  "weight": 13.4,
  "type": [3,4,6,8],
  "obj": {
        "a" : 1
   }
}

These are the supported operators.

Operator

Description

Example

Return Value

Remarks

==

Equal to

$.name == 'apple'

true

Supported data types: int, float, string, bool, and nil

!=

Not equal to

$.name != 'apple'

false

Supported data types: int, float, string, bool, and nil

<

Less than

$.weight < 12

false

Only numbers supported

>

Greater than

$.weight > 12

true

Only numbers supported

<=

Less than or equal to

$.weight <= 13.4

true

Only numbers supported

>=

Greater than or equal to

$.weight >= 13.4

true

Only numbers supported

'*'

Wildcard

$.weight == '*'

true

Must be used together with ==.

||

Or

$.name == 'apple' || $.weight < 12

true

Used together with () for complex AND/OR logic.

&&

And

$.name == 'apple' && $.weight < 12

false

Used together with () for complex AND/OR logic.

NOTE:
  • A string constant must be enclosed with quotation marks (''). For example, 'apple'.
  • JsonPath expressions cannot contain =, !=, <, >, |, or &.

Configuration Examples

Example 1: Parallel branch

  1. Create three Python 3.9 functions with the following code:
    • Function 1: Returning the value of the event input
      import json
      def handler (event, context):
          input = event.get('input',0)
          return {
              "result": input
              }
    • Function 2: Returning the value of the event input plus 2
      import json
      def handler (event, context):
          input = event.get('input',0)
          return {
              "result": input+2
              }
    • Function 3: Returning the square value of the event input
      import json
      def handler (event, context):
          input = event.get('input',0)
          return {
              "result": input*input
              }
  1. Add components to a flow by drag and drop and configure a parallel branch node according to the following figure.
    Figure 1 Configuring a parallel branch node
  2. Configure three function nodes by referring to Table 2.
    Figure 2 Configuring a function node
  3. Save the flow. Then start execution with the following input:
    {
      "input":3
    }
  4. Click the flow to view the execution result.
    Figure 3 Execution result

Example 2: Service node in serial mode

  1. Orchestrate components by drag and drop, and set the execution mode of the service node to Serial.
    Figure 4 Configuring a service node
  2. Add function 2 and function 3 to the service node and configure them according to the following figures.
    Figure 5 Configuring function node 2
    Figure 6 Configuring function node 3
  3. Save the flow. Then start execution with the following input:
    {
      "input":3
    }
  4. Click the flow to view the execution result.
    Figure 7 Execution result
Example 3: Service node in parallel mode
  1. Create two Python 3.9 functions with the following code:
    import json
    def handler (event, context):
        print(event)
        return {"result":"success"}
  2. Add components to a flow by drag and drop and configure a service node according to the following figure.
    Figure 8 Configuring a service node
  3. Configure function node 1.
    Figure 9 Configuring function node 1
  4. Configure function node 2.
    Figure 10 Configuring function node 2
  5. Save the flow. Then start execution with the following input:
    {
      "test":123
    }
  6. Click the flow to view the execution result. Results of the two functions have been combined.
    Figure 11 Execution result
    NOTE:

    If the result structures of the two functions are the same, only one result will be returned.

Example 4: Error handling

An error handling node determines whether to retry when the function it follows fails. There are two types of function failures: execution error and internal service error with an error code (200: success; 500 and 404: failure).
  1. Add components to a flow by drag and drop and configure the following nodes:
    • Function-Input: Obtains the value of input from event and outputs it for status.
    • ErrorHandling: Retries the function when its status is 500 or 404. This node retries for a maximum of eight times at an interval of 1s.
    • Function-ErrorRecord: Records an error if the status of the previous function is still 500 or 404 after eight retries.
    • Function-NormalOutput: Executed if the status of Function-Input is not 500 or 404.

  2. Configure the Error Handling node with retry condition $.status==500||$.status==404.
    Figure 12 Configuring exception handling
  3. Configure the Function-ErrorRecord node to be executed when all retries fail.

  4. Enter 200. The execution is successful.

  5. Enter 500. The input function retries and an error is recorded.

    Example 5: Conditional branch

    • Use the conditional branch to implement the following logic:

      Input value < 2: result is the input value plus 2.

      Input value > 2: result is 2 times the input value.

      Input value = 2: result is 2.

      The flow design is as follows:

      Input 3 to output the square of 3.

    • Input 2 to output 2.

    Input 1 to output 1 plus 2.

    Example 6: Wait node

    • Use the wait node to delay function invocation. The flow design is shown in the following figure.

    • Set Latency (s) to 60.

    • View the execution result.

    Example 7: Subflow

    Multiple function flows can be combined as a new flow and reused to avoid repeated development.

  • Design a function flow. input < 2: Execute the subflows in serial mode to output the input value plus 2 and then squared; input = 2: Execute the default branch to output the input value; input > 2: Execute the subflows in parallel mode to output the input value, the input value plus 2, and the square of the input value.

  • Input 3 to execute the subflows in parallel mode and output the following result.

  • Input 1 to execute the subflows in serial mode and output the following result.

  • Input 2 to execute the default branch and output the input value, that is, 2.

Example 8: Loop node

Use the loop node to cyclically process each element in an input array. All subflows in a loop are executed each time.

  • Design a function flow with a loop node. The node cyclically adds 2 to each element in an integer array and then squares the sum. The flow is shown in the following figure.

  • Set Array Path to $.inputs and Iteration Variable to $.item.

  • Configure function math_2 to output a result that is the input value plus 2. Ensure that the parameter value in Function Parameters is the same as the iteration variable in the loop node.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback