文档首页 > > 最佳实践> 构建外卖订单业务应用> 构建后台功能程序> 编排功能程序

编排功能程序

分享
更新时间: 2019/04/18 GMT+08:00

编排功能程序步骤如下。

  1. 登录函数工作流服务控制台,进入“工作流>工作流列表”界面,单击“创建工作流”,进入创建工作流界面。
  2. 输入工作流信息

    1. 填写名称,输入“workflow-graph”
    2. 模板类型选择“自定义”

  3. 编排函数

    1. 单击“”,进入代码修改页,如图1所示。
      图1 图标
    2. 输入工作流代码信息,将如下代码输入代码框。
      {
      	"states": {
      		"getOrderInfo": {
      			"type": "OPERATION",
      			"action-mode": "SEQUENTIAL",
      			"start": true,
      			"actions": [
      				{
      					"action-name": "action1",
      					"function": "urn:fss:cn-north-1:7aaef7e2cebf4287a13d1a3ae5a9e789:function:default:func-get-order-info",
      					"invocation-mode": "SYNC"
      				}
      			],
      			"next-state": "parseLoc"
      		},
      		"parseLoc": {
      			"type": "OPERATION",
      			"action-mode": "SEQUENTIAL",
      			"actions": [
      				{
      					"action-name": "action1",
      					"function": "urn:fss:cn-north-1:7aaef7e2cebf4287a13d1a3ae5a9e789:function:default:func-parse-loc",
      					"invocation-mode": "SYNC"
      				}
      			],
      			"next-state": "isInRange"
      		},
      		"isInRange": {
      			"type": "SWITCH",
      			"choices": [
      				{
      					"path": "$.city",
      					"value": "NULL",
      					"next-state": "informFailed"
      				}
      			],
      			"default": "getCityVList"
      		},
      		"getCityVList": {
      			"type": "OPERATION",
      			"action-mode": "SEQUENTIAL",
      			"actions": [
      				{
      					"action-name": "action2",
      					"function": "urn:fss:cn-north-1:7aaef7e2cebf4287a13d1a3ae5a9e789:function:default:func_getCityVList",
      					"invocation-mode": "SYNC"
      				}
      			],
      			"next-state": "hasAvailable"
      		},
      		"hasAvailable": {
      			"type": "SWITCH",
      			"choices": [
      				{
      					"path": "$.vlist_len",
      					"value": "0",
      					"next-state": "informFailed"
      				}
      			],
      			"default": "assginAlgo"
      		},
      		"assginAlgo": {
      			"type": "OPERATION",
      			"action-mode": "SEQUENTIAL",
      			"actions": [
      				{
      					"action-name": "action3",
      					"function": "urn:fss:cn-north-1:7aaef7e2cebf4287a13d1a3ae5a9e789:function:default:func_assginAlgo",
      					"invocation-mode": "SYNC"
      				}
      			],
      			"next-state": "dispatch"
      		},
      		"dispatch": {
      			"type": "OPERATION",
      			"action-mode": "SEQUENTIAL",
      			"actions": [
      				{
      					"action-name": "action4",
      					"function": "urn:fss:cn-north-1:7aaef7e2cebf4287a13d1a3ae5a9e789:function:default:func-dispatch",
      					"invocation-mode": "SYNC"
      				}
      			],
      			"next-state": "inform"
      		},
      		"inform": {
      			"type": "OPERATION",
      			"action-mode": "SEQUENTIAL",
      			"actions": [
      				{
      					"action-name": "action5",
      					"function": "urn:fss:cn-north-1:7aaef7e2cebf4287a13d1a3ae5a9e789:function:default:func_inform",
      					"invocation-mode": "SYNC"
      				}
      			],
      			"next-state": "end"
      		},
      		"informFailed": {
      			"type": "OPERATION",
      			"action-mode": "SEQUENTIAL",
      			"actions": [
      				{
      					"action-name": "action6",
      					"function": "urn:fss:cn-north-1:7aaef7e2cebf4287a13d1a3ae5a9e789:function:default:func_inform_failed",
      					"invocation-mode": "SYNC"
      				}
      			],
      			"next-state": "end"
      		},
      		"end": {
      			"type": "END"
      		}
      	}
      }
    3. 编排函数,方法如下。

      在getOrderInfo节点编排func_getOrderInfo函数,单击函数URN位置,可以从函数列表中选择函数,如图2所示。

      图2 编排函数

      节点与编排函数对应关系如表1所示。

      表1 对应关系

      节点名称

      被编排函数名称

      getOrderInfo

      func-get-order-info

      parseLoc

      func-parse-loc

      getCityVList

      func_getCityVList

      assgin

      func_assginAlgo

      dispatch

      func_dispatch

      inform

      func_inform

      informFailed

      func_inform_failed

    4. 确认工作流信息无误后,单击“创建”,创建工作流。

分享:

    相关文档

    相关产品

文档是否有解决您的问题?

提交成功!

非常感谢您的反馈,我们会继续努力做到更好!

反馈提交失败,请稍后再试!

*必选

请至少选择或填写一项反馈信息

字符长度不能超过200

提交反馈 取消

如您有其它疑问,您也可以通过华为云社区问答频道来与我们联系探讨

跳转到云社区