Method and apparatus for processing workflow
By preprocessing the source workflow as the target workflow and leveraging the execution timing mechanism of the parent coroutine and child coroutine, the problem of insufficient response speed and stability in high concurrency scenarios is solved, and flexible timeouts are achieved Control and efficient task scheduling.
Patent Information
- Application Number
- CN202310827758.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-06
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2043-07-06
AI Technical Summary
Traditional workflow engines are difficult to ensure response speed and stability in online high concurrency scenarios, especially in complex business processes, timeout control and task scheduling performance are insufficient.
By taking the source workflow and preprocessing it as a target workflow, the target workflow includes the target node that configures the timeout. During the execution of the target node, the parent coroutine determines the execution timing and the target task is performed through the child coroutine. Control the execution of the target workflow based on the comparison of execution timing and the actual timeout time.
It realizes flexible timeout control for workflows, supports in- and inter-node timeout control, sub-workflow timeout control, and dynamic timeout control, improving the processing efficiency and stability of the workflow engine in high concurrency scenarios.
Smart Images

Figure CN118606010B_ABST
Abstract
Description
Technical Field
[0001] Example embodiments of the present disclosure generally relate to the field of computers, and in particular, to methods, devices, apparatuses, computer-readable storage media, and computer program products for autonomous driving. Background Art
[0002] A workflow engine is a software system used to manage, orchestrate, and execute workflows. It can combine multiple independent tasks or sub-workflows into a complete business process, and provides functions such as visual monitoring, automatic scheduling, and fault-tolerant recovery. The role of the workflow engine is particularly important in online high-concurrency scenarios. High-concurrency scenarios refer to a large number of users or requests accessing or using a service or system at the same time. In this case, the workflow engine can help the system effectively manage and schedule these concurrent requests to ensure that each request is processed correctly and in a timely manner. However, as online high-concurrency processing processes become increasingly complex, traditional workflow engines are unable to guarantee the response speed and stability of their services. Summary of the invention
[0003] In a first aspect of the present disclosure, a method for processing a workflow is provided. The method includes: obtaining a source workflow for a business process and preprocessing the source workflow to obtain a target workflow, the target workflow including a set of nodes, the set of nodes including a target node configured with a configured timeout; during the execution of the target node, determining the execution timing of the target node using a parent coroutine, and executing a target task corresponding to the target node using a child coroutine of the parent coroutine; and controlling the execution of the target workflow according to a comparison between the execution timing and an actual timeout of the target node, the actual timeout being determined based on the configured timeout.
[0004] In a second aspect of the present disclosure, a device for processing a workflow is provided. The device includes: a source workflow acquisition module configured to acquire a source workflow for a business process; a preprocessing module configured to preprocess the source workflow to obtain a target workflow, the target workflow includes a group of nodes, and the group of nodes includes a target node configured with a configured timeout; an execution timing acquisition module configured to determine the execution timing of the target node using a parent coroutine during the execution of the target node; a target task execution module configured to execute a target task corresponding to the target node using a child coroutine of the parent coroutine during the execution of the target node; and an execution control module configured to control the execution of the target workflow according to a comparison between the execution timing and the actual timeout of the target node, and the actual timeout is determined based on the configured timeout.
[0005] In a third aspect of the present disclosure, an electronic device is provided. The device includes at least one processing unit; and at least one memory, the at least one memory is coupled to the at least one processing unit and stores instructions for execution by the at least one processing unit. When the instructions are executed by the at least one processing unit, the device executes the method of the first aspect.
[0006] In a fourth aspect of the present disclosure, a computer-readable storage medium is provided, wherein a computer program is stored on the computer-readable storage medium, and the computer program can be executed by a processor to implement the method of the first aspect.
[0007] In a fifth aspect of the present disclosure, a computer program product is provided, which includes computer executable instructions, and when the computer executable instructions are executed by a processor, the method of the first aspect is implemented.
[0008] It should be understood that the contents described in the summary of the present invention are not intended to limit the key features or important features of the embodiments of the present disclosure, nor are they intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. In the accompanying drawings, the same or similar reference numerals represent the same or similar elements, wherein:
[0010] Figure 1 A schematic diagram showing an example environment in which embodiments of the present disclosure can be implemented;
[0011] Figure 2 An exemplary architecture diagram of a workflow engine according to an embodiment of the present disclosure is shown;
[0012] Figure 3 A schematic diagram showing an example data structure of a workflow according to some embodiments of the present disclosure;
[0013] Figure 4 A schematic diagram showing an example of a multi-layer nested workflow according to some embodiments of the present disclosure;
[0014] Figure 5 A schematic diagram showing an example of converting a multi-layer nested workflow into a single workflow according to some embodiments of the present disclosure;
[0015] Figure 6 A schematic diagram showing an example of converting a multi-layer nested workflow controlled by timeout into a single workflow according to some embodiments of the present disclosure;
[0016] Figure 7A schematic diagram of the execution process of a timeout controller according to some embodiments of the present disclosure is shown;
[0017] Figure 8 A flowchart of a method for processing a workflow according to some embodiments of the present disclosure is shown;
[0018] Fig. 9 A block diagram showing an apparatus for processing a workflow according to some embodiments of the present disclosure; and
[0019] Fig.10 A block diagram of a device capable of implementing various embodiments of the present disclosure is shown. DETAILED DESCRIPTION
[0020] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments set forth herein. On the contrary, these embodiments are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0021] It should be noted that the titles of any sections / subsections provided herein are not restrictive. Various embodiments are described throughout this article, and any type of embodiment may be included under any section / subsection. In addition, the embodiments described in any section / subsection may be combined in any manner with any other embodiments described in the same section / subsection and / or different sections / subsections.
[0022] In the description of the embodiments of the present disclosure, the term "including" and similar terms should be understood as open inclusion, that is, "including but not limited to". The term "based on" should be understood as "based at least in part on". The term "one embodiment" or "the embodiment" should be understood as "at least one embodiment". The term "some embodiments" should be understood as "at least some embodiments". Other explicit and implicit definitions may be included below. The terms "first", "second", etc. may refer to different or the same objects. Other explicit and implicit definitions may be included below.
[0023] The embodiments of the present disclosure may involve user data, data acquisition and / or use, etc. These aspects are subject to the corresponding laws, regulations and relevant provisions. In the embodiments of the present disclosure, all data collection, acquisition, processing, processing, forwarding, use, etc. are carried out on the premise that the user knows and confirms. Accordingly, when implementing each embodiment of the present disclosure, the type, scope of use, usage scenario, etc. of the data or information that may be involved should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with the relevant laws and regulations. The specific notification and / or authorization method can vary according to the actual situation and application scenario, and the scope of the present disclosure is not limited in this respect.
[0024] The solutions described in this specification and in the examples, if they involve the processing of personal information, will be processed on the premise of having a legal basis (such as obtaining the consent of the subject of personal information, or being necessary for the performance of a contract, etc.), and will only be processed within the scope of regulations or agreements. If a user refuses to process personal information other than the necessary information for basic functions, it will not affect the user's use of basic functions.
[0025] As used herein, the term "model" can learn the association between the corresponding input and output from the training data, so that after the training is completed, the corresponding output can be generated for a given input. The generation of the model can be based on machine learning technology. Deep learning is a machine learning algorithm that processes inputs and provides corresponding outputs by using multiple layers of processing units. In this article, "model" may also be referred to as "machine learning model", "machine learning network" or "network", and these terms are used interchangeably in this article.
[0026] The term workflow in the embodiments of the present disclosure refers to the automation of part or all of a business process in a computer application environment, and is an abstract and general description of the business rules between the workflow and its various operation steps. Usually, in order to complete a business, a set of related tasks need to be completed according to a certain process. Each task corresponds to a node in the workflow. According to the position of the node in the workflow, the workflow includes the following types of nodes:
[0027] Head node: It can also be described as the starting node. It generally refers to the first node executed in the workflow. The head node does not have a predecessor node.
[0028] Tail node: It can also be described as the end node. It generally refers to the last node executed in the workflow. After the tail node is executed, it indicates the end of the workflow execution. The tail node does not have a successor node.
[0029] Predecessor node and successor node: Among two adjacent nodes that are executed in a sequential order, the node that is executed first is the predecessor node of the node that is executed later. Correspondingly, the node that is executed later is the successor node of the node that is executed first. It is understandable that a node may be a predecessor node of another node and also a successor node of other nodes. For example, node A is the predecessor node of node B adjacent to it, and correspondingly, node B is the successor node of node A. At the same time, node A can also be the successor node of node C adjacent to it. In addition, a node may have multiple predecessor nodes, for example, node A has multiple predecessor nodes in a parallel relationship. A node may also have multiple successor nodes, for example, node A has multiple successor nodes in a parallel relationship.
[0030] Conditional node: It can also be called a decision node or a judgment node. A conditional node predefines a set of conditions. When the workflow reaches this node, it will make a judgment based on the conditions, and the path that meets the conditions will be executed.
[0031] As briefly mentioned above, as online high-concurrency processing processes become increasingly complex, the use of traditional workflow engines will lead to problems such as low processing efficiency and long response time.
[0032] Secondly, traditional workflow engines cannot directly adapt to large-scale or real-time computing scenarios due to the lack of automatic adjustment and optimization mechanisms. When faced with high load pressures such as massive requests and big data analysis, bottlenecks or crashes are likely to occur.
[0033] Furthermore, in the online high-concurrency scenario of traditional workflow engines, timeout control is an important issue. Timeout control means that if the expected result or response is not obtained within a certain period of time, the system will automatically interrupt the request or perform other processing methods. This is to prevent the system from causing overall performance degradation or blocking due to waiting for a long time without response. Traditional workflow engines are mainly used in low-concurrency scenarios. The scheduled tasks generally take minutes, hours or even days. The time consumption of tasks is not the primary consideration. The main challenge lies in the allocation and scheduling capabilities between machine resources and executed tasks in a distributed environment. Online workflow engines are mainly used in high-concurrency scenarios. The task scheduling in the workflow is executed in a single machine. The time consumption of a single node in the workflow is generally in milliseconds. The main challenge lies in the scheduling and execution performance of multi-threads (coroutines) in an environment with multiple central processing units (CPUs). Due to the above differences, it is very difficult to reuse traditional workflow engines directly in online high-concurrency scenarios. Functions that are relatively easy to implement in traditional workflow engines, such as timeout control in sub-workflow nodes, are weakly supported in online workflow engines.
[0034] Therefore, as online high-concurrency processing processes become increasingly complex and diverse, a workflow engine suitable for online high-concurrency scenarios is needed to solve these problems and achieve more efficient, flexible and reliable task processing methods.
[0035] Embodiments of the present disclosure propose a scheme for processing workflows. According to various embodiments of the present disclosure, the scheme includes obtaining a source workflow for a business process, preprocessing the source workflow to obtain a target workflow, the target workflow includes a group of nodes, and a group of nodes includes a target node configured with a configured timeout. During the execution of the target node, the execution timing of the target node is determined using a parent coroutine, and the target task corresponding to the target node is executed using a child coroutine of the parent coroutine. And based on the comparison of the execution timing with the actual timeout time of the target node, the execution of the target workflow is controlled, and the actual timeout time is determined based on the configured timeout time.
[0036] In the embodiment of the present disclosure, a flexible timeout controller is designed to control the execution of the target workflow based on the comparison between the execution timing and the actual timeout time of the target node. In this way, support for intra-node timeout control, inter-node timeout control, sub-workflow timeout control, node dynamic timeout control, node synchronization and asynchronous callback is achieved.
[0037] In the following, we will first refer to Figure 1 An example environment is described in which embodiments according to the present disclosure can be implemented.
[0038] Example Environment
[0039] Figure 1 A block diagram of an example environment 100 is shown in which embodiments of the present disclosure can be implemented. The example environment 100 includes a workflow management system 110 , a configuration distribution layer 120 , and a workflow engine 130 .
[0040] The workflow management system 110 is used by users to configure workflows, such as creating, deleting, modifying, viewing, importing, and exporting workflows. Users can also review and publish workflows through the workflow management system 110. The configuration information of the workflow can be stored in the database 140. As an example, Figure 1 The database 140 in the workflow management system 110 is independent of the workflow management system 110. In other examples, the database 140 can also be used as a submodule of the workflow management system 100 and integrated in the workflow management system 100. The embodiment of the present disclosure does not limit the implementation form of the database 140. In addition, the workflow management system 110 is also used to distribute the configuration information of the workflow to the configuration distribution layer 120.
[0041] The configuration distribution layer 120 is used to obtain the configuration information of the workflow from the workflow management system 110 and distribute it through different channels, such as publishing it to different storage media such as redis cluster, zookeeper cluster and other distributed caches, global configuration center or local disk, etc. It can also be directly exported to a file in a specific format, such as a json file, and then the developer copies the exported json file to the relevant project directory and runs it in a local loading mode. As an example, Figure 1 The two types of distribution channels, storage media and files, are given as examples. The present disclosure does not limit the types, quantity, etc. of channels for distributing workflows.
[0042] The workflow engine 130 is generally embedded in the service provided by the application system in the form of a component (or SDK). It provides a method to load workflow configuration information from the configuration distribution layer to build a workflow engine instance (or described as a workflow engine object). After the instance or object is built, the service can be provided with the ability to schedule and execute workflows. As an example, Figure 1 Three different services (service 1, service 2, service 3) and the corresponding workflow engines are given as examples.
[0043] The workflow management system 110 and the workflow engine 130 can be implemented as different devices or device clusters. The device or device cluster can be a terminal device or a terminal device cluster, or a server or a server cluster. For example, the workflow management system is a server. The workflow engine 130 is a server cluster composed of multiple servers.
[0044] The workflow management system 110 , the configuration distribution layer 120 , and the workflow engine 130 may be integrated into one platform, such as a workflow platform.
[0045] It should be understood that the functions of various systems or modules in the environment 100 are described for exemplary purposes only and do not imply any limitation on the scope of the present disclosure.
[0046] Figure 2 An example architecture diagram for processing a workflow engine according to some embodiments of the present disclosure is shown. The architecture can be implemented in Figure 1 In the workflow engine 130. Figure 2 In the example of , the architecture 200 includes three parts: a pre-processing module 210 , a core processing module 220 , and an operator library 230 .
[0047] It is understandable that the architecture 200 may also include more or fewer modules. The above two or more modules may be integrated into one module, or one of the above modules may be divided into more sub-modules. The functions of a module described below may be implemented in the module or in other modules. The embodiments of the present disclosure do not limit the division method and function implementation of the modules in the architecture.
[0048] The functions of each module are described below by way of example.
[0049] The preprocessing module 210 is used to preprocess the workflow to be scheduled for execution, including loading the workflow, setting the head and tail nodes, setting the predecessor node, linking the parent-child workflow, etc., in order to help the subsequent core processing module simplify the processing logic and improve performance. The core processing module 220 is used to be called when providing services to the outside after the workflow engine is initialized. The module is further divided into two modules: the initialization module 221 and the scheduling execution module 222. The initialization module 221 is responsible for completing the initialization of the context information. The scheduling execution module 222 includes three submodules: a workflow scheduling submodule D, a node execution submodule E, and a node removal submodule P (which can also be described as a node pruning submodule in the disclosed embodiment).
[0050] In some embodiments, the pre-processing module 210 is called when the workflow engine is initialized.
[0051] In some embodiments, the pre-processing module 210 first obtains or loads one or more workflows to be scheduled for execution.
[0052] Optionally, the preprocessing module 210 reads the configuration information of all workflows (also described as workflow sets) currently to be executed from a data source used to store workflows (for example, the distributed cache, global configuration center, or local disk involved in the configuration distribution layer 120 mentioned above) into memory and generates a workflow set of a specific data structure.
[0053] Figure 3 A schematic diagram showing an example data structure of a workflow according to some embodiments of the present disclosure. Figure 3 , exemplarily showing an example of a workflow with a map structure. The data format of the map structure is a key-value pair format. In this example, the configuration information of the workflow is deserialized into a workflow 300 with a map structure, wherein the key 310 is the identifier of the workflow (WorkflowId), and the value 320 is the workflow object (Workflow).
[0054] Optionally, a workflow object includes only one workflow chart, for example, an object WorkflowChart of the WorkflowChart type.
[0055] Optionally, for each WorkflowChart object of type WorkflowChart, process it according to the following rules:
[0056] First, you can set the head and tail nodes.
[0057] The head node is a node that does not have a predecessor node. Therefore, the head node can be determined in the following way: for the node set Actions in the WorkflowChart, if there is a node Action that is not a successor node of any node, then set the node Action as the head node of the WorkflowChart.
[0058] The tail node is a node that has no successor node. Therefore, for the node set Actions in WorkflowChart, if there is a node Action and its successor node list is empty, then the node Action is set to the tail node of WorkflowChart.
[0059] Furthermore, a predecessor node may be set.
[0060] In some embodiments, there is a corresponding relationship between the predecessor node and the successor node. For example, for the first node, if the second node is the successor node of the first node, the corresponding first node must be the predecessor node of the second node. Then, through the successor node list of a certain node, the node can be marked as the predecessor node of all nodes in the successor node list. There is no need to traverse all nodes to obtain all predecessor nodes of the node. In this way, the speed of node search can be improved. In other words, the present disclosure marks the first node as the predecessor node of the second node in response to the successor node of the first node being the second node.
[0061] Therefore, for the workflow of the map structure mentioned above, the node set Actions in each object WorkflowChart of the WorkflowChart type is traversed, and each node Action in the node set Actions is processed according to the following rules: find the successor node list (NextActionIds) of the node Action, and for the node (NextAction) corresponding to each identifier (Id) in the successor node list (NextActionIds), add the identifier (ActionId) of the node (Action) to the predecessor node list (PrevActionIds) of each node (NextAction).
[0062] Through the above two processes, the head node, tail node, and predecessor node of each node are marked in advance, which facilitates the rapid access to nodes during the subsequent workflow scheduling and execution.
[0063] In some embodiments, a multi-layer nested workflow is provided. For example, a workflow may be used in multiple similar business scenarios. In order to improve the reusability of the workflow, the workflow is set independently and can be nested as a sub-workflow in multiple other workflows to form a workflow with a nested relationship. For another example, for a complex workflow, in order to simplify the workflow, a part of the complex workflow is used as a sub-workflow and the parent-child workflow is nested.
[0064] For ease of description, in the embodiments of the present disclosure, workflows in a nested relationship are described as parent workflows and child workflows, respectively. Among them, the parent workflow contains a node for linking the child workflow. In the embodiments of the present disclosure, the node is described as a child workflow node. Therefore, the parent workflow is a workflow containing a child workflow node; the child workflow is a workflow linked to the child workflow node. That is, the workflow nested in the parent workflow is described as a child workflow. In addition, there can be multiple child workflow nodes contained in the parent workflow. The child workflow corresponding to a child workflow node can further nest the child workflow, that is, form a multi-layer nested parent workflow.
[0065] refer to Figure 4 , an example of a parent-child workflow with one level of nesting is given. Figure 4 In the example shown, workflow 400 includes 9 nodes, namely, node a1 to node a9. Among them, node a4 is a child workflow node. The child workflow corresponding to or linked to child workflow node a4 is workflow 410. Therefore, workflow 400 is the parent workflow of workflow 410, and correspondingly, workflow 410 is the child workflow of workflow 400. Workflow 410 includes nodes a41 to node a45.
[0066] It should be understood that Figure 4 This is just an exemplary description. Figure 4 In the example shown, the workflow 410 includes nodes a41 to a45. The workflow 410 does not include a sub-workflow node. It is understandable that if the workflow 410 includes a sub-workflow node, that is, there are sub-workflow nodes in nodes a41 to a45, then the workflow 410 can further nest sub-workflows. The present disclosure does not limit the number and number of layers of nested sub-workflows.
[0067] Currently, in high-concurrency scenarios, due to performance limitations, most workflow engines have limited support for the above-mentioned multi-layer nested parent workflows.
[0068] In some embodiments, in order to enhance the workflow engine's support for the above-mentioned parent workflow containing multiple layers of nesting, after obtaining the source workflow of the workflow used for the business process, if the source workflow is a workflow containing multiple layers of nesting, the workflow (which may also be described as a parent workflow in the embodiments of the present disclosure) is preprocessed.
[0069] In some embodiments, the parent workflow includes a child workflow node, and the child workflow node corresponds to the child workflow. The preprocessing module 210 preprocesses the parent workflow containing multiple layers of nesting to link the parent and child workflows, and converts the parent workflow containing multiple layers of nesting into a single workflow. The specific process includes:
[0070] The sub-workflow nodes in the parent workflow are replaced with the first group of nodes in the sub-workflow to obtain a target workflow for executing the business process subsequently.
[0071] refer to Figure 4 and Figure 5 , the parent workflow 400 includes a child workflow node a4, and the child workflow node a4 corresponds to the child workflow 410. The child workflow 410 includes nodes a41 to a45. If node a4 has no timeout control requirement (timeout equals 0), the group of nodes a41 to a45 included in the child workflow 410 replaces node a4 to obtain a workflow 500.
[0072] Further, refer to Figure 4 and Figure 6 , the parent workflow 400 includes a child workflow node a4, and the child workflow node a4 corresponds to the child workflow 410. The child workflow 410 includes nodes a41 to a45. If node a4 has a timeout control requirement (the timeout period is greater than 0), the group of nodes a41 to a45 included in the child workflow 410 are embedded in the parent workflow 400, and the child workflow node a4 is retained to obtain a workflow 600. The node type of the child workflow node a4 will be changed to a "timeout node" (the timeout node will be described in detail below). At this point, the conversion of the parent workflow 400 with nested child workflows into a single workflow 600 without nested child workflows is completed, which is the target workflow for subsequent business execution.
[0073] It should be understood that, for the convenience of display, in the embodiments of the present disclosure, Figure 4 , Figure 5 , Figure 6 In the figure, only the one-way connection line between the predecessor node and the successor node is shown, that is, the one-way connection arrow in the figure. In actual applications, the connection lines in the preprocessed workflow diagram are bidirectional.
[0074] In some embodiments, for different types of replaced sub-workflow nodes, it is also necessary to set the association relationship of nodes associated with the replaced sub-workflow node (such as the predecessor node of the replaced sub-workflow node in the parent workflow and the head node of the sub-workflow, the successor node of the replaced sub-workflow node in the parent workflow and the tail node of the sub-workflow) as follows:
[0075] In some embodiments, if the child workflow node is the head node in the parent workflow, it means that the head node in the parent workflow is replaced, and the head node needs to be reset. That is, the head node in the child workflow is replaced with the head node of the parent-child workflow, that is, used as the head node of the workflow obtained after linking the parent-child workflow.
[0076] In some embodiments, if the child workflow node is not the head node of the parent workflow, since the child workflow node is replaced, it is necessary to set the relationship between the predecessor node of the replaced child workflow node and the head node of the child workflow. Therefore, a group of predecessor nodes of the child workflow node in the parent workflow is determined; the head node in the child workflow is set as the successor node of the group of predecessor nodes; and the predecessor node of the head node in the child workflow is set as the above group of predecessor nodes.
[0077] For example, reference Figure 4 and Figure 5 After the sub-workflow 410 replaces the sub-workflow node a4 in the parent workflow 400 to obtain the workflow 500, since the sub-workflow node a4 is replaced, it is necessary to set the association relationship between the predecessor node a1 of the sub-workflow node a4 and the head node a41 of the sub-workflow 400. In this example, the sub-workflow node a4 in the successor node list of the predecessor node a1 of the sub-workflow node a4 is replaced with the head node a41 of the sub-workflow 400. Accordingly, the predecessor node of the head node a41 of the sub-workflow in the workflow 500 is set to node a1.
[0078] In some embodiments, if the child workflow node is the tail node in the parent workflow, it means that the tail node in the parent workflow is replaced, and the tail node needs to be reset. Therefore, the tail node in the child workflow needs to be replaced with the tail node of the parent workflow, that is, it is set to the tail node of the workflow obtained after linking the parent and child workflows.
[0079] In some embodiments, if the child workflow node is not the tail node of the parent workflow, since the child workflow node that is not the tail node is replaced, it is necessary to set the relationship between the successor node of the replaced child workflow node in the parent workflow and the tail node of the child workflow. Therefore, a group of successor nodes of the child workflow node in the parent workflow is determined; the tail node in the child workflow is set as the predecessor node of this group of successor nodes. And the successor node of the tail node in the child workflow is set as this group of successor nodes.
[0080] For example, reference Figure 4 and Figure 5 After replacing the sub-workflow node a4 in the workflow 400 with the sub-workflow 410 to obtain the workflow 500, since the sub-workflow node a4 is not the tail node in the workflow 400, it is necessary to set the association relationship between the successor node a5 of the sub-workflow node a4 and the tail node a45 of the sub-workflow 400. In this example, the predecessor node of the successor node a5 of the sub-workflow node a4 in the workflow 500 is set as the tail node a45 of the sub-workflow 400. Correspondingly, the successor node of the tail node a45 of the sub-workflow 410 in the workflow 500 is set as the node a5.
[0081] Combined with the following Figure 3 The data structure shown describes an example process of converting a parent workflow containing nesting into a single sub-workflow without nesting by linking sub-workflows.
[0082] exist Figure 3 In the example shown, n (n≥1) workflows are stored in a map data structure 310. For any workflow, for example, workflow i, its data structure 320 includes the following elements:
[0083] The identifier i (ID) indicates the unique identifier of workflow i; the scene identifier (SceneId) i is the identifier of the business scene corresponding to workflow i; the workflow chart indicates the object WorkflowChart of the WorkflowChart type corresponding to the workflow i; the value of IsDefault is used to indicate that when the workflow engine 130 does not find a matching workflow, the workflow is executed by default. The update time (UpdateTime) is used to indicate the update time of the workflow configuration information.
[0084] Optionally, an experiment group name (GroupName) may also be included. When the workflow engine 130 performs a specific experiment, a workflow may be configured for each group (the experiment group name is not shown in the figure).
[0085] Furthermore, for a workflow chart (WorkflowChart), its data structure 330 includes the following elements:
[0086] The identifier of the head node (FirstActionId) indicates the ID of the first node executed in the workflow diagram; the identifier of the tail node (LastActionId) indicates the ID of the last node executed in the workflow diagram; the node set (Actions) composed of all nodes contained in the workflow diagram is represented by a Key-Value structure. The content of the Key is the identifier of the node object; the content of the Value is the content description of each node. Figure 5 Node identifiers and node contents of p (p≥2) nodes (node a1, node a2, ... node p) are exemplarily shown.
[0087] Furthermore, for each node in the node set, taking node k as an example, its corresponding data structure 340 includes the following elements:
[0088] Node type (ActionType), including task node, condition node, sub-workflow node (which can also be described as a sub-workflow node in the embodiment of the present disclosure); node identifier (ActionId), which indicates the unique identifier of the node; parameters (Params) contained in the node; list of successor node execution conditions (NextConditions); list of predecessor node identifiers (PrevActionIds); node name (ActionName); list of successor node identifiers (NextActionIds); the identifier of the referenced sub-workflow (RefWorkflowId) indicates the identifier of the sub-workflow referenced by the workflow (which can also be described as a link or nested in the embodiment of the present disclosure). If the default value is 0, it means that no sub-workflow is referenced; timeout (Timeout), if the default value is 0, it means that there is no timeout limit; whether there is an asynchronous timeout callback (TimeoutAsync), if the default value is False, it is used to determine the execution of an asynchronous timeout callback. Whether there is a dynamic timeout (TimeoutDynamic), if the default value is False, it is used to determine the dynamic timeout; and node description information (Description).
[0089] In some embodiments, the parent-child workflow linking module in the pre-processing module 210 processes each Workflow type object Workflow by following the steps below:
[0090] First, initialize an empty set S. Traverse the node set Actions in the workflow diagram WorkflowChart of Workflow, find all node Actions of the "sub-workflow" type, and add them to S. If the number of elements in the set S is 0, return. Alternatively or additionally, if the number of elements in the set S is not 0, for each element FA in the set S, find the sub-workflow refWorkflow referenced by FA, take out all the node refActions in refWorkflow, and copy them to the node set Actions of the flowchart WorkflowChart of Workflow.
[0091] In some embodiments, if FA is the head node of WorkflowChart, the head node of the workflow diagram of refWorkflow is set to the head node of the workflow diagram WorkflowChart of Workflow.
[0092] Alternatively or additionally, if FA is not the head node of WorkflowChart, perform the following operations on each predecessor node PA of FA: if the timeout of FA is greater than 0, add the head node of the workflow diagram of refWorkflow to the successor node list of PA. Or, if the timeout of FA is less than or equal to 0, replace the FA node in the successor node list of PA with the head node of the workflow diagram of refWorkflow. Accordingly, set the predecessor node list of the head node of the newly added sub-workflow diagram in WorkflowChart to the predecessor node list of FA.
[0093] Alternatively or additionally, if FA is the tail node of WorkflowChart, the tail node of the workflow graph of refWorkflow is set to the tail node of the workflow graph WorkflowChart of Workflow.
[0094] Alternatively or additionally, if FA is not the tail node of WorkflowChart, perform the following operations: Perform the following operations on each successor node NA of FA: If the timeout of FA is greater than 0, add the tail node of the workflow diagram of refWorkflow to the predecessor node list of NA. Or, if the timeout of FA is less than or equal to 0, replace the FA node in the predecessor node list of NA with the tail node of the workflow diagram of refWorkflow. Accordingly, set the successor node list of the tail node of the newly added sub-workflow diagram in WorkflowChart to the successor node list of FA.
[0095] Alternatively or additionally, if the timeout period of the FA is greater than 0, the node type of the FA is changed to a timeout node type.
[0096] Alternatively or additionally, if the timeout period of FA is less than or equal to 0, the FA node is deleted from the node set Actions of WorkflowChart.
[0097] The above steps are repeated until all Workflow objects of the Workflow type are processed.
[0098] Through the above process, the parent workflow containing multiple layers of nesting is converted into a single workflow, thereby supporting the scheduling and execution of the parent workflow containing multiple layers of nesting. In addition, since the above work is performed in the preprocessing stage, the speed of workflow scheduling and execution is also improved.
[0099] After the above preprocessing, the subsequent online service can select the corresponding workflow for scheduling and execution according to the current request after receiving the request.
[0100] Still combined Figure 2 Based on the architecture shown, the following describes the process of scheduling workflow execution services.
[0101] In some embodiments, the core processing module 220 is used to be called when providing services to the outside after the workflow engine is initialized. For example, the core processing module 220 is used to receive a scheduling request for a service, and select a workflow for a business process corresponding to the request in response to the scheduling request for the service, and control the execution of the business process based on the obtained workflow.
[0102] The following description is made by taking the workflow obtained as a workflow containing a conditional node (which may also be described as a source workflow in the embodiment of the present disclosure) as an example. Optionally, the conditional node may be the conditional node containing dynamic parameters as mentioned above.
[0103] Before the business process is executed, the core processing module 220 obtains the workflow for the business process. For example, there may be multiple business scenarios in an application system, and multiple different workflows may be configured in each scenario. When the application system provides services to the outside world, it is necessary to select a workflow according to the actual business scenario.
[0104] Optionally, the core processing module 220 obtains the workflow preprocessed by the preprocessing module 210. In some embodiments, the obtained workflow (source workflow) is preprocessed to obtain a target workflow, which includes a group of nodes, including a target node configured with a first timeout period.
[0105] After the core processing module 220 obtains the target workflow, during the execution of the target condition node, according to the target value of the target condition node, the successor node to be executed in the target workflow is determined to be the first successor node, and then the branch to be executed is determined. After that, the target workflow is updated to at least remove the connection between the target condition node and the second successor node. That is, the unexecuted branches in the updated target workflow are "pruned". Then, based on the updated target workflow, the execution of the business process is controlled.
[0106] Combined with the following Figure 2 The structure of the core processing module 220 in FIG. 2 describes the above process in detail.
[0107] See also Figure 2 As an example, the core processing module 220 includes two sub-modules: an initialization module 221 and a scheduling execution module 222 .
[0108] The initialization module 221 is responsible for completing the initialization of the context information.
[0109] Before each scheduling and execution of the workflow graph, an initialization method InitContext needs to be executed to pass some context information into the workflow scheduling and execution function in the form of parameters. The specific initialization work includes:
[0110] In some embodiments, the initialization work includes business context (Ctx) initialization: business information required during workflow execution is stored in Ctx. Optionally, intermediate results during subsequent workflow scheduling execution can also be stored in Ctx.
[0111] Additionally or alternatively, the initialization work also includes initializing the coroutine synchronizer (CA) corresponding to the node: traversing the workflow graph, creating a coroutine synchronizer for each node containing multiple predecessor nodes. Exemplarily, the initial value of the internal counter of the coroutine synchronizer is set to the total number of predecessor nodes of the current node, and the created coroutine synchronizer will be stored in the CA.
[0112] Additionally or alternatively, the initialization work also includes timeout controller (CT) initialization: traverse the workflow graph, create a timeout controller for each node with a timeout requirement (timeout is greater than 0), and store the created timeout controller in the CT.
[0113] Ginseng Figure 7 In some embodiments, in order to achieve timeout control capability, we implement a component called "timeout controller 720" for use by the scheduling execution module. Its working principle is as follows: Figure 7The timeout controller 720 mainly includes four modules: initialization module, timeout transmission module, timing module, and end timing module. The following describes the functions of each module in conjunction with the detailed process of timeout control:
[0114] Additionally or alternatively, during the initialization phase, the timeout controller creates a timeout controller instance or object for each node configured with a timeout by calling the "initialization module" and assigning values to the core data structure. Note that at this time, the "remaining time" of each timeout controller is assigned a value of 0.
[0115] Additionally or alternatively, when the timeout controller encounters a node with timeout control requirements during the scheduling execution phase, it first creates a child coroutine 730 in the current coroutine 710 (hereinafter referred to as the parent coroutine), and then the child coroutine 730 starts to execute the operator in the operator library corresponding to the node. After the task is executed, the "end timing module" of the timeout controller of the node will be called to write an end mark to the end pipeline.
[0116] In some embodiments, after the parent coroutine 710 creates the child coroutine 730, it will immediately call the "timing module" of the timeout controller to start the timeout timing. When a timeout occurs, a timeout mark is written to the timeout pipe. It should be understood that the basis for determining whether a timeout has occurred is: the timing time is greater than the sum of the timeout time and the remaining time in the timeout controller.
[0117] When the timeout controller calls the "timing module" and starts the timeout timing, it will listen to the timeout pipe and the end pipe at the same time. If the task execution times out, it will obtain the timeout mark from the timeout pipe; if the task is completed normally, it will obtain the end mark from the end pipe, and then return the obtained mark to the parent coroutine 710.
[0118] If the parent coroutine 710 receives a timeout mark, it reads the callback type. If the callback type is synchronous, it directly calls the timeout callback function OnTimeout; if the callback type is asynchronous callback, it starts a new coroutine to asynchronously call the timeout callback function OnTimeout. If the parent coroutine 710 obtains the end mark from the end pipeline, it means that the task is completed normally, and there is no need to execute the timeout callback function. The parent coroutine 710 can continue to execute the subsequent logic.
[0119] In some embodiments, in order to better demonstrate the timeout control capability, we have made timeout skipping requirements for some recall nodes in the workflow, as shown in Table 1 below, and made an overall timeout control for the entire recall link between action-5-1 to action-5-10 (corresponding to the timeout node action-5-9), and set the inter-node timeout to 80 milliseconds. The detailed attribute configuration of each node is shown in Table 1 below. It can be understood that the "execution time" in Table 1 below is an artificial control of the execution time of each node to demonstrate the timeout function, and it cannot be manually determined in advance during actual execution.
[0120] Table 1
[0121] Node ID Timeout (ms) Execution time (ms) Asynchronous callbacks Whether to dynamically time out action-5-1 none 10 none none action-5-2 none none none action-5-3 50 40 yes no action-5-4 50 30 yes no action-5-5 50 60 yes no action-5-6 50 30 yes yes action-5-7 30 40 yes no action-5-8 30 20 yes no action-5-9 80 0 yes no action-5-10 none 15 none none action-5-11 none 10 none none action-5-12 none 5 none none
[0122] According to the configuration of Table 1 and the above workflow diagram, the detailed execution process is as shown in Table 2:
[0123] Table 2
[0124]
[0125]
[0126] From the execution process shown in Table 2 above, we can see that: the timeout time set for node action-5-5 is 50ms, and the actual execution time is 60ms, so the execution is skipped at the 50th ms, and the timeout callback is triggered; the timeout time set for node action-5-6 is 50ms, and the actual execution is completed after 30ms. Due to the dynamic timeout setting, the remaining 20ms is passed to the successor node action-5-7. The timeout time set for node action-5-7 is 30ms, and the actual execution time is 40ms. Due to the 20ms "surplus" time passed from the predecessor node action-5-6, the timeout time becomes 50ms, so there is no timeout during the execution of node action-5-7. The timeout of node action-5-8 is set to 30ms, and the actual execution time is 20ms. Although it does not cause internal timeout of the node, the time consumption of nodes action-5-6 and action-5-7 has reached 30ms+40ms=70ms. For the timeout of the entire branch of 80ms, there is only 10ms left. Therefore, node action-5-8 times out after 10ms, and then action-5-10 starts to execute.
[0127] Additionally or alternatively, the initialization work also includes initializing a workflow state synchronizer (CF): creating a coroutine synchronizer for synchronizing the workflow execution state. The initial value of the internal counter of the coroutine synchronizer is set to 1.
[0128] The coroutine synchronizer in the above initialization work is a tool for synchronizing multiple concurrently executed coroutines, which can be implemented in different programming languages. For example: WaitGroup implemented in golang, CountDownLatch implemented in Java, etc. The coroutine synchronizer generally provides an initialization operation: set the count of the built-in counter, and the initial value of the counter is the number of coroutines to be synchronized. Alternatively or additionally, the coroutine synchronizer can also provide a counting operation: in all concurrently executed coroutines, this method is called after each coroutine is executed, and the counter is reduced by 1. Alternatively or additionally, the coroutine synchronizer can also provide a waiting operation: usually after starting multiple concurrent coroutines in the main coroutine, the waiting method will be called to block the main coroutine. When all concurrent coroutines are executed, the counter becomes 0, and the main coroutine will be awakened and continue to execute.
[0129] Additionally or alternatively, the initialization work also includes initializing the nodes to be executed: creating an empty set W for storing the identifiers (IDs) of the nodes waiting to be executed.
[0130] Additionally or alternatively, the initialization work also includes initializing the head node: assigning the head node of the workflow graph to parameter A, which is of type Action.
[0131] In some embodiments, the following initialization is also required: Initialization of edges to be pruned: Create an empty set F to store the edges to be pruned. In the embodiments of the present disclosure, an "edge" is a line connecting a predecessor node and a successor node, which can also be called a connection, such as: an edge<PA,A> It is the connection between node PA and node A.
[0132] After the initialization module 221 completes parameter initialization, the parameters are passed to the scheduling execution module 222 for scheduling and executing the workflow.
[0133] Reference Figure 2 As an example, the scheduling execution module 222 includes two main submodules: a workflow scheduling submodule D, a node execution submodule E, a node removal submodule P (which can also be described as a node pruning submodule in the embodiment of the present disclosure) and a timeout control module T. In addition, Figure 2 , six coroutines G1 to G6 are shown, each of which includes a workflow scheduling submodule D, a node execution submodule E, a node removal submodule P, and a timeout control module T. Moreover, the present disclosure does not limit the number of coroutines G.
[0134] The workflow scheduling submodule D schedules nodes in the target workflow based on the algorithm. The node execution submodule E is responsible for the execution of the node and calls the node removal submodule P during the execution of the node. The timeout control module T executes the control logic including inter-node timeout skipping, intra-node timeout skipping, timeout callback, and node dynamic timeout.
[0135] The following is a detailed description of the workflow scheduling execution algorithm, which can be executed by the workflow scheduling submodule D as follows:
[0136] The workflow scheduling submodule D executes executeFlow(Ctx,CA,CT,CF,W,A,F) according to the initialization parameters Ctx,CA,CT,CF,W,A,F.
[0137] If the number of predecessor nodes of the current node A is greater than 1, then if A exists in the set of nodes to be executed W, then return. If A does not exist in the set of nodes to be executed W, then add the current node A to the set of nodes to be executed W.
[0138] Additionally or alternatively, the predecessor node of node A is searched to see whether there is a node of type "timeout node". If there is no node of type "timeout node", the waiting method of the coroutine synchronizer CA(A) of node A is called to wait for the predecessor nodes to be fully executed (described in detail below).
[0139] Additionally or alternatively, if there is a node of type "timeout node", assuming that the timeout node is PA, the following steps are performed: create a new coroutine in the current coroutine, and perform the following operations in the new coroutine: first call the waiting method of the coroutine synchronizer CA(A) of node A to wait for all the predecessor nodes to be executed, and after the execution is completed, call the end timing module of the timeout controller CT(PA) of node PA to write the end mark to the end pipe. At the same time, after creating the above-mentioned new coroutine, use the timing module of the timeout controller CT(PA) in the current coroutine to start timing immediately, and once the timeout time is reached, write the timeout mark to the timeout pipe. In addition, after calling the "timing module" to start the timeout timing, the timeout controller CT(PA) will listen to the timeout pipe and the end pipe at the same time. If the task execution times out, the timeout mark will be obtained from the timeout pipe; if the task is completed normally, the end mark will be obtained from the end pipe, and then the obtained mark will be returned to the parent coroutine. If the current coroutine receives a timeout mark, the callback type is read. If the callback type is synchronous, the timeout callback function OnTimeout is directly called synchronously; if the callback type is asynchronous, a new coroutine is started to asynchronously call the timeout callback function OnTimeout. If the parent coroutine obtains the end mark from the end pipeline, it means that the task is completed normally and there is no need to execute the timeout callback function.
[0140] Call the node execution algorithm to execute the current node: L = executeAction (Ctx, CA, CT, CF, A, F). L is the list of nodes to be executed returned after the method is executed.
[0141] Next, if the length of the list L is 0, it indicates that there is no node to be executed, and the node is the tail node, then it returns directly and the workflow execution ends.
[0142] Additionally or alternatively, if the length of list L is 1, indicating that node A has a single successor node, then for the only node L(0) in L, recursively call executeFlow(Ctx, CA, CT, CF, W, L(0), F) and then return.
[0143] Additionally or alternatively, if the length of L is greater than 1, for each node L(i) to be executed in L, a new coroutine is started, and executeFlow(Ctx, CA, CT, CF, W, L(i), F) is recursively called in the new coroutine.
[0144] Additionally or alternatively, during the process of scheduling the workflow, the workflow state synchronizer (CF) is blocked, waiting for the workflow to be executed and completed. After the workflow is executed and completed, the workflow state synchronizer is released.
[0145] For each node, the node execution submodule E is responsible for the execution of the corresponding node. The specific execution process of the node execution submodule E is as follows:
[0146] The node execution submodule E executes executeAction(Ctx,CA,CT,CF,A,F) according to the initialization parameters Ctx,CA,CT,CF,A,F.
[0147] The node execution submodule E initializes an empty node list L, which is used to store the list of nodes to be executed after the current node A is executed.
[0148] Alternatively or additionally, if the current node A is a conditional node, the operator in the operator library with the same name as node A is executed. If the execution is successful, the next node to be executed that matches the execution result is found according to the execution result, and the node is added to L. If the execution fails, a default node is selected from the list of nodes to be executed as the node to be executed, and the node is added to L.
[0149] If the process status in Ctx is not set to skip, perform the following operations:
[0150] If the timeout of node A is greater than 0 and the node type is not "timeout node", the following operations are performed: a new coroutine is started in the current coroutine, the operator with the same name as node A in the operator library is executed in the new coroutine, and after the execution, the end timing module of A's timeout controller CT(A) is called to write the end marker to the end pipe, and then the coroutine is ended.
[0151] Next, after starting the new coroutine described in the previous step in the current coroutine, the "timing module" of the timeout controller CT(A) of node A is immediately called to start timing waiting.
[0152] Next, after calling the "timing module" to start the timeout timing, the timeout controller CT(A) will listen to the timeout pipe and the end pipe at the same time. If the task execution times out, it will obtain the timeout mark from the timeout pipe; if the task is completed normally, it will obtain the end mark from the end pipe, and then return the obtained mark to the current coroutine.
[0153] Next, if the current coroutine receives a timeout mark, the callback type is read. If the callback type is synchronous, the timeout callback function OnTimeout is directly called synchronously; if the callback type is asynchronous, a new coroutine is started to asynchronously call the timeout callback function OnTimeout.
[0154] Alternatively or additionally, if the current coroutine receives an end tag, it means that node A has been executed in advance before the timeout period. At this time, the dynamic timeout tag of node A needs to be read. If the tag is True, the following operations are performed for each successor node NA of A that has a timeout set: subtract the actual execution time of A from the timeout period of A to obtain the remaining time T(A) of node A, and then call the "timeout transfer module" of the timeout controller CT(NA) of NA to assign (transfer) the remaining time value T(A) to the remaining time of the successor node NA.
[0155] Alternatively or additionally, if the timeout of node A is not greater than 0, the operator in the operator library with the same name as node A is executed. Finally, all successor node lists of node A are added to L.
[0156] If the number of successor nodes of node A is greater than 0, the following logic is executed for each successor node NA of node A:
[0157] Alternatively or additionally, if node A is a conditional node, the node removal submodule P is called for all nodes in the successor nodes of A that are not in L, and the pruning function is executed: Prune(Ctx, CA, CF, A, NA, F).
[0158] Alternatively or additionally, if the current node A is not a conditional node and the number of predecessor nodes of NA is greater than 1, the counter value of NA's coroutine synchronizer CA(NA) is reduced by 1. If the counter value becomes 0, all coroutines blocked on NA's coroutine synchronizer CA(NA) will be awakened by the coroutine synchronizer CA(NA) of NA.
[0159] Alternatively or additionally, if the current node A is the tail node of the workflow graph to which it belongs, the count of the workflow state synchronizer (CF) is reduced by 1. If the counter value becomes 0 after reduction by 1, the main coroutine of the upstream blocked workflow scheduling is awakened by the workflow state synchronizer (CF).
[0160] Alternatively or additionally, the node execution submodule E returns to L after executing the above steps.
[0161] In some embodiments, according to the pruning function Prune(Ctx, CA, CF, A, NA, F) mentioned in the execution algorithm of the node execution submodule E above, the execution logic of the pruning function Prune(Ctx, CA, CF, A, NA, F) will be described in detail here.
[0162] According to the above description, A is the currently pruned node, and PA is the predecessor node of node A. The specific execution logic is as follows:
[0163] 1. If the predecessor node PA or node A is empty, return.
[0164] 2. Alternatively, if the number of predecessor nodes of node A is greater than 1, determine the edge<PA,A> (also called the connection between PA and A) is in F, if the edge<PA,A> If it is not in F, then<PA,A> Add it to F and reduce the count value of A's coroutine synchronizer CA(A) by 1. If the count becomes 0 after reduction, all coroutines blocked on CA(A) will be awakened by CA(A).
[0165] 3. Next, delete the predecessor node PA from the predecessor node list of node A, and delete A from the successor node list of predecessor node PA.
[0166] 4. Alternatively or additionally, if the number of predecessor nodes of node A is greater than 0, return.
[0167] 5. Alternatively or additionally, if the number of successor nodes of node A is greater than 0, each successor node NA of node A is pruned, that is, a recursive function is executed: Prune(Ctx, CA, CF, A, NA, F).
[0168] Example Process
[0169] Figure 8FIG. 8 is a flow chart of a method for processing a workflow according to some embodiments of the present disclosure. Process 800 may be implemented at the workflow engine 130. For ease of discussion, reference will be made to Figure 1 The process 800 is described with reference to the environment 100 of FIG. It should be understood that the process 800 may include additional actions not shown and / or may omit actions shown, and the scope of the present disclosure is not limited in this respect.
[0170] In box 810, the workflow engine 130 obtains a source workflow for a business process and preprocesses the source workflow to obtain a target workflow, the target workflow includes a set of nodes, and the set of nodes includes a target node configured with a configured timeout. In box 820, during the execution of the target node, the workflow engine 130 uses the parent coroutine to determine the execution timing of the target node, and uses the child coroutine of the parent coroutine to execute the target task corresponding to the target node. In box 830, the workflow engine 130 controls the execution of the target workflow based on the comparison of the execution timing with the actual timeout of the target node, and the actual timeout is determined based on the configured timeout.
[0171] In some embodiments, controlling the execution of the target workflow includes: in response to the execution timing exceeding the actual timeout time of the target node, executing a preconfigured first process according to a timeout control policy of the target node.
[0172] In some embodiments, executing a preconfigured first process according to a timeout control policy of a target node includes: if the timeout control policy indicates a synchronous call policy, using a parent coroutine to call a first callback function corresponding to the preconfigured first process. Or if the timeout control policy indicates an asynchronous call policy, using a parent coroutine to create a new child coroutine to call the first callback function corresponding to the preconfigured first process.
[0173] In some embodiments, the target node corresponds to a dynamic timeout control logic, and the method further includes: in response to the target task being executed, determining a difference between an actual timeout of the dynamic target node and a first execution duration of the target task as a first remaining duration, and controlling execution of a target successor node of the target node based at least on the first remaining duration.
[0174] In some embodiments, controlling the execution of a target successor node of the target node includes: if the target successor node corresponds to a dynamic timeout control logic, determining an actual timeout of the target successor node based on a first remaining duration and a configured timeout of the target successor node, and determining a second remaining duration of the target successor node based on the actual timeout of the target successor node and a second execution duration of the target successor node, and controlling the execution of at least one successor node of the target successor node according to the second remaining duration.
[0175] In some embodiments, controlling the execution of the target successor node of the first timeout control node includes: if the target successor node corresponds to the static timeout control logic, determining the actual timeout time of the target successor node based on the first balance duration and the configured timeout time of the target successor node. And in response to the execution timing of the target successor node exceeding the actual timeout time of the target successor node, executing a pre-configured second process according to the timeout control policy of the target successor node.
[0176] In some embodiments, preprocessing the source workflow to obtain the target workflow includes: obtaining a parent workflow for a business process, the parent workflow includes a child workflow node, the child workflow node corresponds to the child workflow, and updating the parent workflow using a first group of nodes in the child workflow to obtain the target workflow.
[0177] In some embodiments, the child workflow node has a predecessor node in the parent workflow, and updating the parent workflow with the first set of nodes in the child workflow includes: if the child workflow node is configured with a configuration timeout, adding the head node in the child workflow to the successor node list of the predecessor node in the target workflow. Or if the child workflow node is not configured with a configuration timeout, replacing the child workflow node in the successor node list of the predecessor node with the head node in the child workflow.
[0178] In some embodiments, the child workflow node has a successor node in the parent workflow, and updating the parent workflow with the first set of nodes in the child workflow includes: if the child workflow node is configured with a configuration timeout, adding the tail node in the child workflow to the predecessor node list of the successor node in the target workflow. Or if the child workflow node is not configured with a configuration timeout, replacing the child workflow node in the predecessor node list of the successor node with the tail node in the child workflow.
[0179] In some embodiments, process 800 further includes: if the sub-workflow node is configured with a configuration timeout, marking the sub-workflow node as a timed-out node in the target workflow, or if the sub-workflow node is not configured with a configuration timeout, deleting the sub-workflow node from the target workflow.
[0180] In some embodiments, the sub-workflow node is configured with a configuration timeout, the execution timing is a first execution timing, wherein the parent coroutine is a first parent coroutine, and the method further includes, for the target successor node of the timeout node in the target workflow: using the sub-coroutine of the second parent coroutine to call the timeout controller of the timeout node to determine the execution timing of the timeout node, and using the sub-coroutine of the second parent coroutine to call the coroutine synchronizer of the target successor node, the coroutine synchronizer is configured to be decremented according to the completion of the execution of the predecessor node of the target successor node. And according to the comparison of the execution timing of the timeout node and the actual timeout time of the sub-workflow node, the execution of the target workflow is controlled, wherein the actual timeout time of the sub-workflow node is determined based on the configuration timeout time of the sub-workflow node.
[0181] In some embodiments, controlling the execution of the target workflow based on a comparison between the execution timing of the timeout node and the actual timeout time of the sub-workflow node includes: in response to the execution timing of the timeout node exceeding the actual timeout time of the timeout node, executing a preconfigured third process according to the timeout control policy of the timeout node.
[0182] In some embodiments, executing the pre-configured third process according to the timeout control policy of the timeout node includes: if the timeout control policy indicates a synchronous call policy, using the second parent coroutine to call the second callback function corresponding to the pre-configured second process. Or if the timeout control policy indicates an asynchronous call policy, using the second parent coroutine to create a new child coroutine to call the second callback function corresponding to the pre-configured second process.
[0183] In some embodiments, determining the execution timing of the target node using the sub-coroutine includes determining the execution timing using a timeout controller, the timeout controller including: a timing module configured to execute a timing process; an end timing module configured to obtain an end timing signal according to the completion of the execution of the target task; and a data update module configured to update a timeout pipeline or an end pipeline according to a comparison between the execution duration and the actual timeout time.
[0184] In some embodiments, updating the timeout pipeline or the end pipeline according to the comparison between the execution duration and the actual timeout time includes: if the execution duration is less than or equal to the actual timeout time, updating the end pipeline to indicate that the target task is completed normally. Or if the execution duration exceeds the actual timeout time, updating the timeout pipeline to indicate that the target task has timed out.
[0185] Example devices and equipment
[0186] Fig. 9A schematic structural block diagram of an apparatus 900 for processing a workflow according to some embodiments of the present disclosure is shown. The apparatus 900 may be implemented as or included in a workflow engine 130. Each module / component in the apparatus 900 may be implemented by hardware, software, firmware, or any combination thereof.
[0187] As shown in the figure, the device 900 includes a source workflow acquisition module 910, a preprocessing module 920, a target task execution module 930, an execution timing acquisition module 940 and an execution control module 950. The source workflow acquisition module 910 is configured to acquire a source workflow for a business process. The preprocessing module 920 is configured to preprocess the source workflow to obtain a target workflow, the target workflow includes a group of nodes, and a group of nodes includes a target node configured with a configuration timeout. The target task execution module 930 is configured to execute the target task corresponding to the target node using the child coroutine of the parent coroutine during the execution of the target node. The execution timing acquisition module 940 is configured to determine the execution timing of the target node using the parent coroutine during the execution of the target node. And the execution control module 950 is configured to control the execution of the target workflow according to the comparison of the execution timing with the actual timeout time of the target node, and the actual timeout time is determined based on the configuration timeout time.
[0188] In some embodiments, controlling the execution of the target workflow includes: in response to the execution timing exceeding the actual timeout time of the target node, executing a preconfigured first process according to a timeout control policy of the target node.
[0189] In some embodiments, executing a preconfigured first process according to a timeout control policy of a target node includes: if the timeout control policy indicates a synchronous call policy, using a parent coroutine to call a first callback function corresponding to the preconfigured first process. Or if the timeout control policy indicates an asynchronous call policy, using a parent coroutine to create a new child coroutine to call the first callback function corresponding to the preconfigured first process.
[0190] In some embodiments, the target node corresponds to a dynamic timeout control logic, and the method further includes: in response to the target task being executed, determining a difference between an actual timeout of the dynamic target node and a first execution duration of the target task as a first remaining duration, and controlling execution of a target successor node of the target node based at least on the first remaining duration.
[0191] In some embodiments, controlling the execution of a target successor node of the target node includes: if the target successor node corresponds to a dynamic timeout control logic, determining an actual timeout of the target successor node based on a first remaining duration and a configured timeout of the target successor node, and determining a second remaining duration of the target successor node based on the actual timeout of the target successor node and a second execution duration of the target successor node, and controlling the execution of at least one successor node of the target successor node according to the second remaining duration.
[0192] In some embodiments, controlling the execution of the target successor node of the first timeout control node includes: if the target successor node corresponds to the static timeout control logic, determining the actual timeout time of the target successor node based on the first balance duration and the configured timeout time of the target successor node. And in response to the execution timing of the target successor node exceeding the actual timeout time of the target successor node, executing a pre-configured second process according to the timeout control policy of the target successor node.
[0193] In some embodiments, preprocessing the source workflow to obtain the target workflow includes: obtaining a parent workflow for a business process, the parent workflow includes a child workflow node, the child workflow node corresponds to the child workflow, and updating the parent workflow using a first group of nodes in the child workflow to obtain the target workflow.
[0194] In some embodiments, the child workflow node has a predecessor node in the parent workflow, and updating the parent workflow with the first set of nodes in the child workflow includes: if the child workflow node is configured with a configuration timeout, adding the head node in the child workflow to the successor node list of the predecessor node in the target workflow. Or if the child workflow node is not configured with a configuration timeout, replacing the child workflow node in the successor node list of the predecessor node with the head node in the child workflow.
[0195] In some embodiments, the child workflow node has a successor node in the parent workflow, and updating the parent workflow with the first set of nodes in the child workflow includes: if the child workflow node is configured with a configuration timeout, adding the tail node in the child workflow to the predecessor node list of the successor node in the target workflow. Or if the child workflow node is not configured with a configuration timeout, replacing the child workflow node in the predecessor node list of the successor node with the tail node in the child workflow.
[0196] In some embodiments, the apparatus 900 further includes: if the sub-workflow node is configured with a configuration timeout, marking the sub-workflow node as a timeout node in the target workflow, or if the sub-workflow node is not configured with a configuration timeout, deleting the sub-workflow node from the target workflow.
[0197] In some embodiments, the sub-workflow node is configured with a configuration timeout, the execution timing is a first execution timing, wherein the parent coroutine is a first parent coroutine, and the method further includes, for the target successor node of the timeout node in the target workflow: using the sub-coroutine of the second parent coroutine to call the timeout controller of the timeout node to determine the execution timing of the timeout node, and using the sub-coroutine of the second parent coroutine to call the coroutine synchronizer of the target successor node, the coroutine synchronizer is configured to be decremented according to the completion of the execution of the predecessor node of the target successor node. And according to the comparison of the execution timing of the timeout node and the actual timeout time of the sub-workflow node, the execution of the target workflow is controlled, wherein the actual timeout time of the sub-workflow node is determined based on the configuration timeout time of the sub-workflow node.
[0198] In some embodiments, controlling the execution of the target workflow based on a comparison between the execution timing of the timeout node and the actual timeout time of the sub-workflow node includes: in response to the execution timing of the timeout node exceeding the actual timeout time of the timeout node, executing a preconfigured third process according to the timeout control policy of the timeout node.
[0199] In some embodiments, executing the pre-configured third process according to the timeout control policy of the timeout node includes: if the timeout control policy indicates a synchronous call policy, using the second parent coroutine to call the second callback function corresponding to the pre-configured second process. Or if the timeout control policy indicates an asynchronous call policy, using the second parent coroutine to create a new child coroutine to call the second callback function corresponding to the pre-configured second process.
[0200] In some embodiments, determining the execution timing of the target node using the sub-coroutine includes determining the execution timing using a timeout controller, the timeout controller including: a timing module configured to execute a timing process; an end timing module configured to obtain an end timing signal according to the completion of the execution of the target task; and a data update module configured to update a timeout pipeline or an end pipeline according to a comparison between the execution duration and the actual timeout time.
[0201] In some embodiments, updating the timeout pipeline or the end pipeline according to the comparison between the execution duration and the actual timeout time includes: if the execution duration is less than or equal to the actual timeout time, updating the end pipeline to indicate that the target task is completed normally. Or if the execution duration exceeds the actual timeout time, updating the timeout pipeline to indicate that the target task has timed out.
[0202] Fig.10 A block diagram illustrating a computing device 1000 in which one or more embodiments of the present disclosure may be implemented is shown. It should be understood that Fig.10 The computing device 1000 shown is merely exemplary and should not constitute any limitation on the functionality and scope of the embodiments described herein. Fig.10The computing device 1000 shown may be used to implement Figure 1 The workflow engine 130 is configured to:
[0203] like Fig.10 As shown, computing device 1000 is in the form of a general-purpose computing device. Components of computing device 1000 may include, but are not limited to, one or more processors or processing units 1010, memory 1020, storage device 1030, one or more communication units 1040, one or more input devices 1050, and one or more output devices 1060. Processing unit 1010 may be an actual or virtual processor and is capable of performing various processes according to a program stored in memory 1020. In a multi-processor system, multiple processing units execute computer executable instructions in parallel to increase the parallel processing capabilities of computing device 1000.
[0204] The computing device 1000 typically includes a plurality of computer storage media. Such media may be any accessible media that is accessible to the computing device 1000, including but not limited to volatile and non-volatile media, removable and non-removable media. The memory 1020 may be a volatile memory (e.g., a register, a cache, a random access memory (RAM)), a non-volatile memory (e.g., a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), flash memory), or some combination thereof. The storage device 1030 may be a removable or non-removable medium, and may include a machine-readable medium, such as a flash drive, a disk, or any other medium, which may be capable of being used to store information and / or data (e.g., training data for training) and may be accessed within the computing device 1000.
[0205] The computing device 1000 may further include additional removable / non-removable, volatile / non-volatile storage media. Fig.10 As shown in , a disk drive for reading or writing from a removable, non-volatile disk (e.g., a "floppy disk") and an optical drive for reading or writing from a removable, non-volatile optical disk may be provided. In these cases, each drive may be connected to the bus (not shown) by one or more data media interfaces. Memory 1020 may include a computer program product 1025 having one or more program modules that are configured to perform various methods or actions of various embodiments of the present disclosure.
[0206] The communication unit 1040 enables communication with other computing devices via a communication medium. Additionally, the functions of the components of the computing device 1000 can be implemented in a single computing cluster or multiple computing machines that can communicate via a communication connection. Therefore, the computing device 1000 can operate in a networked environment using a logical connection with one or more other servers, a network personal computer (PC), or another network node.
[0207] Input device 1050 may be one or more input devices, such as a mouse, keyboard, tracking ball, etc. Output device 1060 may be one or more output devices, such as a display, a speaker, a printer, etc. Computing device 1000 may also communicate with one or more external devices (not shown) through communication unit 1040 as needed, such as storage devices, display devices, etc., communicate with one or more devices that allow a user to interact with computing device 1000, or communicate with any device that allows computing device 1000 to communicate with one or more other computing devices (e.g., a network card, a modem, etc.). Such communication may be performed via an input / output (I / O) interface (not shown).
[0208] According to an exemplary implementation of the present disclosure, a computer-readable storage medium is provided, on which computer-executable instructions are stored, wherein the computer-executable instructions are executed by a processor to implement the method described above. According to an exemplary implementation of the present disclosure, a computer program product is also provided, which is tangibly stored on a non-transitory computer-readable medium and includes computer-executable instructions, and the computer-executable instructions are executed by a processor to implement the method described above.
[0209] Various aspects of the present disclosure are described herein with reference to the flowcharts and / or block diagrams of the methods, devices, equipment, and computer program products implemented according to the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer-readable program instructions.
[0210] These computer-readable program instructions can be provided to a processing unit of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processing unit of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0211] Computer-readable program instructions can be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operational steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, so that the instructions executed on the computer, other programmable data processing apparatus, or other device implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0212] The flow chart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system, method and computer program product according to multiple implementations of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a part of a module, program segment or instruction, and a part of a module, program segment or instruction includes one or more executable instructions for realizing the logical function of the specification. In some implementations as replacements, the function marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two continuous square boxes can actually be executed substantially in parallel, and they can sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be realized by a special hardware-based system that performs the function or action of the specification, or can be realized by a combination of special hardware and computer instructions.
[0213] The above descriptions of various implementations of the present disclosure are exemplary, non-exhaustive, and not limited to the disclosed implementations. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described implementations. The selection of terms used herein is intended to best explain the principles of the implementations, practical applications, or improvements to the technology in the market, or to enable other persons of ordinary skill in the art to understand the various implementations disclosed herein.
Claims
1. A method for processing a workflow, comprising: Acquire a source workflow for a business process and preprocess the source workflow to obtain a target workflow, wherein the target workflow includes a group of nodes, and the group of nodes includes a target node configured with a configured timeout time; During the execution of the target node, determining the execution timing of the target node using the parent coroutine, and executing the target task corresponding to the target node using the child coroutine of the parent coroutine; as well as controlling execution of the target workflow based on a comparison of the execution timing with an actual timeout of the target node, the actual timeout being determined based on the configured timeout, and Preprocessing the source workflow to obtain the target workflow includes: replacing the sub-workflow nodes in the parent workflow with the first group of nodes in the sub-workflow to obtain the target workflow for subsequent execution of the business process.
2. The method according to claim 1, wherein controlling the execution of the target workflow comprises: In response to the execution timing exceeding the actual timeout period of the target node, a preconfigured first process is executed according to a timeout control policy of the target node.
3. The method according to claim 2, wherein executing a preconfigured first process according to the timeout control policy of the target node comprises: If the timeout control strategy indicates a synchronous call strategy, using the parent coroutine to call a first callback function corresponding to the pre-configured first process; or If the timeout control policy indicates an asynchronous call policy, a new child coroutine is created using the parent coroutine to asynchronously call the first callback function corresponding to the pre-configured first process.
4. The method according to claim 1, wherein the target node corresponds to a dynamic timeout control logic, the method further comprising: In response to the target task being executed, determining a difference between the actual timeout time of the dynamic target node and the first execution duration of the target task as a first remaining duration; as well as Based at least on the first balance duration, the execution of the target successor node of the target node is controlled.
5. The method according to claim 4, wherein controlling the execution of the target successor node of the target node comprises: If the target successor node corresponds to a dynamic timeout control logic, determining an actual timeout time of the target successor node based on the first remaining duration and a configured timeout time of the target successor node; as well as Determine a second remaining duration of the target successor node based on the actual timeout time of the target successor node and the second execution duration of the target successor node; as well as Controlling the execution of at least one successor node of the target successor node according to the second balance duration.
6. The method according to claim 4, wherein controlling the execution of the target successor node of the target node comprises: If the target successor node corresponds to a static timeout control logic, determining an actual timeout time of the target successor node based on the first remaining duration and a configured timeout time of the target successor node; as well as In response to the execution timing of the target successor node exceeding the actual timeout time of the target successor node, a preconfigured second process is executed according to the timeout control policy of the target successor node.
7. The method according to claim 1, wherein preprocessing the source workflow to obtain the target workflow comprises: Acquire a parent workflow for a business process, wherein the parent workflow includes a child workflow node, and the child workflow node corresponds to the child workflow; as well as The parent workflow is updated using the first group of nodes in the child workflow to obtain the target workflow.
8. The method of claim 7, wherein the child workflow node has a predecessor node in the parent workflow, and updating the parent workflow using the first set of nodes in the child workflow comprises: If the sub-workflow node is configured with a configuration timeout, adding the head node in the sub-workflow to the successor node list of the predecessor node in the target workflow; or If the sub-workflow node is not configured with a configuration timeout, the sub-workflow node in the successor node list of the predecessor node is replaced with the head node in the sub-workflow.
9. The method of claim 7, wherein the child workflow node has a successor node in the parent workflow, and updating the parent workflow using the first set of nodes in the child workflow comprises: If the sub-workflow node is configured with a configuration timeout, adding the tail node in the sub-workflow to the predecessor node list of the successor node in the target workflow; or If the sub-workflow node is not configured with a configuration timeout, the sub-workflow node in the predecessor node list of the successor node is replaced with the tail node in the sub-workflow.
10. The method according to claim 7, further comprising: If the sub-workflow node is configured with a timeout period, marking the sub-workflow node as a timeout node in the target workflow; or If the sub-workflow node is not configured with a configuration timeout period, the sub-workflow node is deleted from the target workflow.
11. The method according to claim 10, wherein the child workflow node is configured with a configuration timeout, the execution timing is a first execution timing, and the parent coroutine is a first parent coroutine, the method further comprising, for a target successor node of the timeout node in the target workflow: Using the child coroutine of the second parent coroutine to call the timeout controller of the timeout node to determine the execution timing of the timeout node, and using the child coroutine of the second parent coroutine to call the coroutine synchronizer of the target successor node, the coroutine synchronizer is configured to be decremented according to the completion of the execution of the predecessor node of the target successor node; and The execution of the target workflow is controlled based on a comparison of the execution timing of the timeout node and the actual timeout time of the sub-workflow node, wherein the actual timeout time of the sub-workflow node is determined based on the configured timeout time of the sub-workflow node.
12. The method according to claim 11, wherein controlling the execution of the target workflow according to the comparison between the execution timing of the timeout node and the actual timeout time of the sub-workflow node comprises: In response to the execution timing of the timeout node exceeding the actual timeout time of the timeout node, a preconfigured third process is executed according to the timeout control policy of the timeout node.
13. The method according to claim 12, wherein executing a pre-configured third process according to the timeout control policy of the timeout node comprises: If the timeout control strategy indicates a synchronous call strategy, using the second parent coroutine to call a second callback function corresponding to the pre-configured second process; or If the timeout control policy indicates an asynchronous call policy, a new child coroutine is created using the second parent coroutine to call the second callback function corresponding to the pre-configured second process.
14. The method according to claim 1, wherein determining the execution timing of the target node using a sub-coroutine comprises determining the execution timing using a timeout controller, the timeout controller comprising: A timing module, configured to execute a timing process; An end timing module is configured to obtain an end timing signal according to the completion of execution of the target task; The data update module is configured to update the timeout pipeline or the end pipeline according to the comparison between the execution time and the actual timeout time.
15. The method according to claim 14, wherein updating the timeout pipeline or terminating the pipeline according to the comparison between the execution time and the actual timeout time comprises: If the execution duration is less than or equal to the actual timeout time, updating the end pipeline to indicate that the target task is completed normally; or If the execution duration exceeds the actual timeout period, the timeout pipeline is updated to indicate that the target task execution has timed out.
16. An apparatus for processing a workflow, comprising: A source workflow acquisition module, configured to acquire a source workflow for a business process; A preprocessing module is configured to preprocess the source workflow to obtain a target workflow, wherein the target workflow includes a group of nodes, and the group of nodes includes a target node configured with a configuration timeout period; an execution timing acquisition module, configured to determine the execution timing of the target node using a parent coroutine during the execution of the target node; A target task execution module is configured to execute a target task corresponding to the target node using a child coroutine of the parent coroutine during execution of the target node; as well as an execution control module configured to control the execution of the target workflow based on a comparison of the execution timing with an actual timeout of the target node, the actual timeout being determined based on the configured timeout, and The preprocessing module is further configured to replace the sub-workflow nodes in the parent workflow with the first group of nodes in the sub-workflow to obtain a target workflow for subsequent execution of the business process.
17. An electronic device comprising: at least one processing unit; as well as At least one memory, the at least one memory being coupled to the at least one processing unit and storing instructions for execution by the at least one processing unit, the instructions causing the electronic device to perform the method according to any one of claims 1 to 15 when executed by the at least one processing unit.
18. A computer-readable storage medium having a computer program stored thereon, wherein the computer program can be executed by a processor to implement the method according to any one of claims 1 to 15.
19. A computer program product comprising computer executable instructions, wherein the computer executable instructions, when executed by a processor, implement the method according to any one of claims 1 to 15.
Citation Information
Patent Citations
Work flow time method, device and system
CN101551880A