The service orchestration feature of DataService Studio allows you to configure workflows by dragging nodes to directed acyclic graphs (DAGs). You can arrange APIs and functions in a serial, parallel, or branch structure based on the business logic.
Prerequisites
- DataWorks Enterprise Edition or a more advanced edition is activated so that you can use the service orchestration feature. For more information, see DataWorks advanced editions.
- A DataWorks workspace is created in the China (Shanghai) region.
Background information
When you run a workflow to call APIs, DataWorks runs the nodes in the workflow in sequence, passes parameters among the nodes, and automatically changes the status of each node. The service orchestration feature simplifies the process of calling multiple APIs or functions and reduces the cost of development and maintenance. This allows you to focus on business development.
- Reduced cost of developing APIs
After you drag nodes to a DAG, you can arrange APIs and functions in a serial, parallel, or branch structure without the need to write code. This reduces the cost of developing APIs.
- Higher performance in calling APIs and functions
A workflow allows you to call multiple APIs and functions in a container. Compared with writing code to call APIs and functions, the service orchestration feature reduces the latency of calling APIs and functions and greatly improves the calling performance.
- Serverless architecture
The service orchestration feature adopts a serverless architecture. A serverless architecture supports automatic resource scaling based on business needs. You can focus on the business logic, without the need to worry about the underlying runtime environment.
Values of request and response parameters
DataService Studio uses JSONPath to obtain parameter values. JSONPath is a query language that allows you to extract data from JSON files. For more information, see JSONPath.
- Response parameter of Node A: {"namea":"valuea"}
Expression for obtaining the value of the response parameter of Node A: ${A.namea}
- Response parameter of Node B: {"nameb":"valueb"}
Expression for obtaining the value of the response parameter of Node B: $.nameb or ${B.nameb}
Parameters
- Request parameters of a workflow
On the configuration tab of a workflow, click the Request Parameters tab in the right-side navigation pane. Then, you can configure request parameters in manual adding or automatic parsing mode.
- Manual adding: Click Add Parameters and manually add a request parameter for the workflow.
- Automatic parsing: If the first node of the workflow is an API node, click Automatically parse request parameters to automatically map the request parameters of this API node to the request parameters of the workflow.
- Request parameters of an API node
Click an API node. In the panel that appears, click Input Request Parameters and specify values for request parameters.
- If you do not specify a value for a request parameter, DataService Studio obtains
the value of the same parameter in the first layer of the JSON string that is returned
by the parent node, and assigns the value to the request parameter.
Note If the current node is the first node of a workflow, the values of the request parameters of this node are assigned to the same parameters of the workflow.
- If you specify a value for a request parameter, DataService Studio uses the value
that you specify.
Note To reference the value of a specified parameter that is returned by a specified ancestor node, you must use a JSONPath expression.
- If you do not specify a value for a request parameter, DataService Studio obtains
the value of the same parameter in the first layer of the JSON string that is returned
by the parent node, and assigns the value to the request parameter.
- Response parameters of an API node
Click an API node. In the panel that appears, select set output results and customize the output of the node by using JSON expressions similar to the following example:
{ "return1":"$.data.rows.user_id", "return2":"$.data.rows.user_name" }
- Request parameters of a Python node
Click a Python node. Specify request parameters in the Request Parameters section.
- Response parameters of a Python node
Click a Python node. In the panel that appears, select set output results and customize the output of the node by using JSON expressions similar to the following example:
{ "return1":"$.data.rows.user_id", "return2":"$.data.rows.user_name" }
JSONPath expression | Role in request parameters | Role in response parameters |
---|---|---|
$. | Obtains the root object of the output of the parent node. | Obtains the root object of the output of the current node. |
$.param | Obtains the value of the param parameter in the output of the parent node. | Obtains the value of the param parameter in the output of the current node. |
${START} | Obtains the output of the start node. | |
${NodeID} | Obtains the output of the node with the specified ID. | |
${NodeID.param} | Obtains the value of the param parameter in the output of the node with the specified ID. |
Example
You must first create a connection. For more information, see Configure a connection. In this example, a MySQL connection is used.