State machine configuration method, device and electronic device
By acquiring and processing state machine configuration data, determining state node feature data, and generating state machines suitable for complex business processes, the problem of insufficient state machine description capabilities in the prior art is solved, and accurate description of business workflows is achieved.
Patent Information
- Application Number
- CN202110574913.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-05-25
- Publication Date
- 2024-12-10
- Estimated Expiration
- 2041-05-25
AI Technical Summary
Existing state machines have relatively single description capabilities when describing complex business processes, and cannot accurately and comprehensively describe the workflow of the business.
By obtaining the state machine configuration data of the target service, determining the state node and its characteristic data, including common attributes and unique attributes, a feature-rich state machine is generated to accurately describe the business process.
It realizes an accurate and comprehensive description of business workflows, provides a rich and diverse state node, and is suitable for state machine configurations of complex business processes.
Smart Images

Figure CN114675873B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a state machine configuration method, device and electronic device. Background Art
[0002] State machine is short for finite state automaton, which is a mathematical model abstracted from the operating rules of real things. State machine can be used to describe a finite number of states, as well as behaviors such as transitions and actions between these states. Each state node of the state machine, also called a step, will perform a response operation based on the input and pass the output to the next state node. At present, the description ability of various states of the state machine is relatively single and cannot be applied to more complex business flows. Therefore, how to enrich the description of the state machine to accurately and comprehensively describe the business workflow has become a problem that needs to be solved urgently. Summary of the invention
[0003] The embodiments of the present invention provide a state machine configuration method, device and electronic device, which can provide state nodes with rich and diverse functions, thereby accurately and comprehensively describing the workflow of a business.
[0004] On the one hand, an embodiment of the present invention provides a state machine configuration method, including:
[0005] Obtain state machine configuration data for the target business;
[0006] Determine one or more state nodes and characteristic data of each state node according to the state machine configuration data, wherein the characteristic data includes common attributes and specific attributes, and the common attributes include node type and terminal state node indication information;
[0007] A state machine corresponding to the target business is generated according to one or more state nodes and characteristic data of each state node, wherein each state node is used to execute a business process of the target business.
[0008] On the one hand, an embodiment of the present invention provides a state machine configuration device, the device comprising:
[0009] An acquisition unit, used to acquire state machine configuration data for a target business;
[0010] A determination unit, configured to determine one or more state nodes and characteristic data of each state node according to the state machine configuration data, wherein the characteristic data includes common attributes and specific attributes, and the common attributes include node type and terminal state node indication information;
[0011] The processing unit is used to generate a state machine corresponding to the target business according to one or more state nodes and characteristic data of each state node, wherein each state node is used to execute a business process of the target business.
[0012] In one aspect, an embodiment of the present invention provides an electronic device, including:
[0013] a processor adapted to implement one or more instructions; and
[0014] A computer storage medium storing one or more instructions adapted to be loaded and executed by the processor:
[0015] Obtain state machine configuration data for the target business;
[0016] Determine one or more state nodes and characteristic data of each state node according to the state machine configuration data, wherein the characteristic data includes common attributes and specific attributes, and the common attributes include node type and terminal state node indication information;
[0017] A state machine corresponding to the target business is generated according to one or more state nodes and characteristic data of each state node, wherein each state node is used to execute a business process of the target business.
[0018] Correspondingly, an embodiment of the present application further provides a computer-readable storage medium, in which instructions are stored, and when the computer-readable storage medium is run on a computer, the computer executes the above-mentioned state machine configuration method.
[0019] Accordingly, an embodiment of the present application further provides a computer program product or a computer program, wherein the computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the above-mentioned state machine configuration method.
[0020] In the embodiment of the present application, by obtaining the state machine configuration data for the target business, and determining one or more state nodes and characteristic data of each state node according to the state machine configuration data, the state machine corresponding to the target business can be generated according to the one or more state nodes and characteristic data of each state node. By implementing the method provided in the embodiment of the present application, a state node with rich functions can be provided, thereby accurately and comprehensively describing the workflow of the business. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying any creative work.
[0022] Figure 1 is a schematic diagram of an exemplary state machine provided by an embodiment of the present invention;
[0023] Figure 2 is an architecture diagram of a state machine configuration system provided by an embodiment of the present invention;
[0024] Figure 3 It is a flow chart of a state machine configuration method provided by an embodiment of the present invention;
[0025] Figure 4 is a flow chart of another state machine configuration method provided by an embodiment of the present invention;
[0026] Figure 5 It is a flow chart of a state machine for changing input data provided by an embodiment of the present invention;
[0027] Figure 6 It is a flow chart of a parallel logic state machine provided by an embodiment of the present invention;
[0028] Figure 7 A state machine configuration device provided by an embodiment of the present invention;
[0029] Figure 8 An electronic device is provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0030] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0031] Cloud technology refers to a hosting technology that unifies hardware, software, network and other resources within a wide area network or local area network to achieve data computing, storage, processing and sharing.
[0032] Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, application technology, etc. based on the cloud computing business model. It can form a resource pool, which can be used on demand and is flexible and convenient. Cloud computing technology will become an important support. The backend services of the technical network system require a large amount of computing and storage resources, such as video websites, picture websites and more portal websites. With the rapid development and application of the Internet industry, in the future, each item may have its own identification mark, which needs to be transmitted to the backend system for logical processing. Data of different levels will be processed separately. All kinds of industry data need strong system backing support, which can only be achieved through cloud computing.
[0033] Cloud computing refers to the delivery and use model of IT infrastructure, which means obtaining required resources through the network in an on-demand and easily scalable manner; in a broad sense, cloud computing refers to the delivery and use model of services, which means obtaining required services through the network in an on-demand and easily scalable manner. This service can be IT and software, Internet-related, or other services. Cloud computing is the product of the development and integration of traditional computer and network technologies such as grid computing, distributed computing, parallel computing, utility computing, network storage technologies, virtualization, and load balancing.
[0034] With the development of the Internet, real-time data streams, and the diversification of connected devices, as well as the demand for search services, social networks, mobile commerce, and open collaboration, cloud computing has developed rapidly. Different from the previous parallel distributed computing, the emergence of cloud computing will promote revolutionary changes in the entire Internet model and enterprise management model from a conceptual perspective.
[0035] The embodiments of the present application mainly involve cloud computing and other technologies in cloud technologies, which are specifically described below:
[0036] To facilitate understanding, the terms involved in the embodiments of the present application are first introduced.
[0037] 1. State Machine
[0038] State machine is short for finite state automaton, which is a mathematical model abstracted from the operating rules of real things. State machine can be used to describe a finite number of states, as well as the transitions and actions between these states. For example, see Figure 1 , Figure 1 The shown figure can be a state machine.
[0039] For example, Figure 1 visible, Figure 1 This is a state machine taking the speech recognition service as an example. The speech recognition service may include six business processes as shown in the figure, namely, the preprocessing process, the video processing process, the text recognition process, the speech recognition process, the natural language processing process and the merged storage process. Optionally, the video processing process, the text recognition process and the speech recognition process may also be regarded as a business process, that is, as an independent state machine, and this application does not limit this.
[0040] 2. Status Node
[0041] Each state node of the state machine, also known as a business process or step, will perform a response operation based on the input and pass the output to the next state node. For example, see Figure 1 , Figure 1 The speech recognition shown in can be a state node, which can be used to implement the business process corresponding to the speech recognition; the natural language processing can also be a state node, which can be used to implement the business process corresponding to the natural language processing.
[0042] Based on this, the present application provides a state machine configuration method, which includes obtaining state machine configuration data for a target business; determining one or more state nodes and characteristic data of each state node based on the state machine configuration data, the characteristic data including common attributes and unique attributes, the common attributes including node type and termination state node indication information; generating a state machine corresponding to the target business based on one or more state nodes and the characteristic data of each state node, wherein each of the above state nodes is used to execute a business process of the target business.
[0043] In order to implement the above-mentioned state machine configuration method, the embodiment of the present invention provides a state machine configuration system, see Figure 2 , Figure 2 This is a state machine configuration system architecture diagram provided by an embodiment of the present invention. The state machine configuration system includes but is not limited to one or more terminal devices, one or more servers, Figure 2 In the description, a terminal device 201 and a server 202 are taken as an example for explanation. Figure 2 The number and form of the devices shown are for illustrative purposes only and do not constitute a limitation on the embodiments of the present invention.
[0044] Among them, the terminal device 201 can be used to receive the configuration data of the state machine, and provide a visual interface or a non-visual interface for the user to fill in the configuration data of the state machine according to the configured grammatical rule configuration template according to different services. The server 202 can be used to execute the state machine configuration method provided by the embodiment of the present invention, and determine the state nodes of the state machine and the characteristic data of each state node by obtaining the state machine configuration data, so as to generate a state machine corresponding to the target business, thereby accurately and comprehensively describing the workflow of the business.
[0045] The server 202 may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The terminal device 201 may be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, etc., but is not limited thereto. The terminal device 201 and the server 202 may be directly or indirectly connected via wired or wireless communication, which is not limited in this application.
[0046] Based on the above state machine configuration system, the embodiment of the present invention provides a state machine configuration method. Figure 3 , is a flow chart of a state machine configuration method provided by an embodiment of the present invention. The state machine configuration method can be applied to Figure 2 The state machine configuration system shown is executed by a server, and specifically can be executed by a processor of the server. The state machine configuration method includes the following steps:
[0047] S301. The server obtains state machine configuration data for a target service.
[0048] Specifically, the server can receive state machine configuration data for the target service sent by the terminal device, which is configured by the user on the terminal device, and can be specifically input according to the grammar rule configuration template. The grammar rule configuration template can specifically include a state machine description template, a node definition template, and an input and output rule configuration template.
[0049] In one embodiment, the state machine configuration data may include definition information of one or more state nodes and indication information of a start state node.
[0050] It should be noted that the above target business may correspond to one or more state nodes, which may be understood as one or more business processes corresponding to the target business. It is understandable that one business process may correspond to one state node, and optionally, one business process may correspond to multiple state nodes, which is not limited in this application.
[0051] The state machine configuration data may include mandatory parameters, including state node definition information and start state node indication information, and optional parameters, including state machine description information, state machine operation timeout information, etc. The mandatory and optional parameters of the state machine configuration data are defined as follows:
[0052] startAt Indication information of the starting state node: specifies the starting node of the state machine.
[0053] Steps state node definition information: definition information of all state nodes contained in the state machine.
[0054] description: Defines the description of the state machine.
[0055] timeoutSeconds: The timeout information of the state machine operation: specifies the timeout of the state machine operation, in seconds.
[0056] timeoutMilliseconds The timeout information of the state machine operation: specifies the timeout of the state machine operation, in milliseconds.
[0057] It should be noted that the timeout time represented by the keyword "timeoutSeconds" is in seconds; the timeout time represented by the keyword "timeoutMilliseconds" is in milliseconds. When using the above two keywords to describe the state machine, any of the above two keywords can be used alone or in combination, and this application does not impose any restrictions on this.
[0058] It should also be noted that the above state machine configuration data may also include other keywords, and the keywords mentioned in this application are used for illustration and do not limit this application. Optionally, the names of the above keywords are only used for examples and do not limit this application. The scheme of converting the uppercase and lowercase of keywords or replacing a small number of keywords also falls within the scope of protection of this application.
[0059] S302: The server determines one or more state nodes and characteristic data of each state node according to the state machine configuration data. The characteristic data includes common attributes and specific attributes. The common attributes include node type and termination state node indication information.
[0060] In one embodiment, the above-mentioned determining one or more state nodes and characteristic data of each state node based on state machine configuration data includes: determining one or more state nodes and characteristic data of each state node based on definition information of one or more state nodes; determining the starting state node from one or more state nodes based on indication information of the starting state node.
[0061] It should be noted that each state node of the state machine contains characteristic data of the state node, and the characteristic data contains common attributes and unique attributes. It is understandable that the common attributes can be attributes that each state node has; the unique attributes can be attributes that each state node has individually.
[0062] As can be seen from the above content, general attributes can include node type and terminal state node indication information. It should be noted that the above node type and terminal state node indication information are mandatory parameters in general attributes, and general attributes can also include optional parameters: description information of the state node, data input rules, data output rules, etc. The definitions of the mandatory parameters and optional parameters of the above general attributes are as follows:
[0063] Description: Description information of the state node: description information of the state machine state node.
[0064] type node type: the type of state machine state node. For specific node types, see the description below.
[0065] nextStep terminal state node indication information: specifies the next step node.
[0066] end terminal status node indication information: specifies whether the current step node is the last node.
[0067] inputData input rules: Specify data input rules.
[0068] output data output rules: specify data output rules.
[0069] The terminal state node indication information can be represented by the keyword "nextStep" or "end". It should be noted that the terminal state node indication information is at least selected from the keywords "nextStep" and "end".
[0070] In one embodiment, the node type can be any one of a task processing type, a data transmission type, a branch selection type, a loop execution type, a parallel execution type, a waiting execution type, an execution success type, and an execution failure type. The definitions of the node types are as follows:
[0071] Task processing type: a node that performs some work in the state machine.
[0072] Pass data transmission type: simply transparently transmit node data or perform data processing in the state machine.
[0073] Choice branch selection type: select between execution branches in the state machine.
[0074] foreach loop execution type: state node that dynamically iterates in the state machine.
[0075] Parallel execution type: executes parallel branches in the state machine.
[0076] Wait execution type: The state machine waits for a period of time before continuing to execute.
[0077] Success Execution Success Type: The state machine will be stopped and marked as executed successfully.
[0078] fail Execution failure type: the state machine will be stopped and marked as execution failure.
[0079] It should be noted that the above node types are only used for example, and other node types can be added or one or more of the above node types can be reduced according to user needs, and this application does not limit this. Similarly, the names of the above node types and the names of keywords are also only used for example and do not limit this application.
[0080] In one embodiment, if the node type of the first state node is a task processing type, the specific attributes of the first state node include interface parameters and function indication parameters, and the first state node is any one of the one or more state nodes.
[0081] Among them, the above interface parameters and function indication parameters are mandatory parameters in the unique attributes of the task processing type state node, and the unique attributes of the task processing type state node may also include optional parameters: timeout period of state node operation, error retry, error capture, etc. The mandatory parameters and optional parameters of the unique attributes of the above task processing type state node are defined as follows:
[0082] resourceQrn interface parameter: indicates the interface information of the next state node.
[0083] The parameters function indicates parameters: indicates some parameters in the state node.
[0084] timeoutSeconds: The timeout for the state node to run: specifies the timeout for the step node to run, in seconds.
[0085] timeoutMilliseconds: The timeout for the status node to run: specifies the timeout for the step node to run, in milliseconds.
[0086] retries error retry: indicates that the state node has an error and retries are performed.
[0087] catchesError capture: indicates that the state node has an error and captures it.
[0088] Among them, the timeout time of the state node operation can also be expressed by the keywords "timeoutSeconds" or "timeoutMilliseconds", which is used to indicate the timeout time of the state node operation; please refer to the detailed description of the timeout time of the aforementioned state machine operation, and this application will not repeat it here.
[0089] In one embodiment, if the node type of the first state node is a branch selection type, the unique attribute of the first state node includes a selection logic rule array, and the selection logic rule array includes a selection condition and a next state node.
[0090] The selection logic rule array, as well as the selection conditions and next state nodes contained in the selection logic rule array, are mandatory parameters in the unique attributes of the branch selection type state node. The unique attributes of the branch selection type state node may also include optional parameters: default next state node, etc. The mandatory parameters and optional parameters of the unique attributes of the branch selection type state node are defined as follows:
[0091] choices selection logic rule array: an array of rules that define the selection logic.
[0092] condition selection condition: defines the conditional expression for the selection operation.
[0093] nextStep next state node: defines the next state node that meets the conditions.
[0094] default default next state node: defines the default next state node when all conditional expressions are not met.
[0095] It should be noted that the conditional expression can be of different types, such as a string matching judgment, for example: "$.name==John"; it can also be a number size judgment, for example: "$.age>=18"; it can also be a string type number matching judgment, for example: "$.grade.number==string(100)", and this application does not impose any restrictions on this.
[0096] The following string is an example of a branch selection type:
[0097]
[0098] From the above code, we can see that the string describes a status node named "scoreChoices". The node type of this status node is a branch selection type, which contains two selection logic arrays. The selection condition of the first selection logic array is "$.status<=20", and the next status node is "addScore"; the selection condition of the second selection logic array is "$.status>100", and the next status node is "subScore". This branch selection type contains a default next status node, that is, the default next status node is "defaultOperate" when the above two selection conditions are not met.
[0099] In one embodiment, if the node type of the first state node is a loop execution type, the specific attributes of the first state node include path information of loop variables and a loop logic state machine.
[0100] Among them, the path information of the loop variable and the loop logic state machine are mandatory parameters in the unique attributes of the loop execution type state node, and the unique attributes of the loop execution type state node may also include optional parameters: maximum concurrency, error retry, error capture, etc. The mandatory parameters and optional parameters of the unique attributes of the loop execution type state node are defined as follows:
[0101] iterationPath loop variable path information: specifies the JsonPath path of the loop variable.
[0102] Iterator loop logic state machine: defines the state machine of loop logic. For specific fields of the state machine, refer to the relevant description of the aforementioned state machine configuration data.
[0103] maxConcurrency: Specifies the maximum number of concurrent loops.
[0104] retries error retry: indicates that the state node has an error and retries are performed.
[0105] catchesError capture: indicates that the state node has an error and captures it.
[0106] It should be noted that the above-mentioned loop logic state machine can be understood as describing the logic loop part as a new state machine. Therefore, the above-mentioned loop logic state machine will include two mandatory parameters in the state machine configuration data, namely, the state node definition information and the indication information of the starting state node; it may also include optional parameters, namely, the description information of the state machine, the timeout information of the state machine operation, etc. The description of specific keywords can be found in the above content, and this application will not repeat them here.
[0107] It should also be noted that the default value of the above-mentioned maximum concurrency number is 1, which is used to indicate that there is at least one worker thread to process; the maximum value of the maximum concurrency number can be 100 or other values, and this application does not impose any restrictions on this.
[0108] The following string is an example of a loop execution type:
[0109]
[0110]
[0111] It can be seen from the above string that the starting node of the above state machine is "foreachVideos", and the node type of the state node named "foreachVideos" is a loop execution type, the JsonPath path of the loop variable of the state node is "$.videos", and the state node contains a loop logic state machine. The starting node of the loop logic state machine is "checkPath", as well as the definition information of all state nodes of the loop state machine. It should be noted that the above state node is configured with data input rules, which will be described in detail later when describing the data input rules.
[0112] In one embodiment, if the node type of the first state node is a parallel execution type, the unique attribute of the first state node includes a parallel logic state machine.
[0113] The parallel logic state machine is a mandatory parameter in the unique attributes of the parallel execution type state node, and the unique attributes of the parallel execution type state node may also include optional parameters: error retry, error capture, etc. The mandatory and optional parameters of the unique attributes of the parallel execution type state node are defined as follows:
[0114] Branches parallel logic state machine: defines the state machine array of parallel logic. For specific fields of the state machine, refer to the relevant description of the aforementioned state machine configuration data.
[0115] retries error retry: indicates that the state node has an error and retries are performed.
[0116] catchesError capture: indicates that the state node has an error and captures it.
[0117] It should be noted that the above parallel logic state machine can also be understood as describing the parallel logic part as a new state machine. The specific content can be found in the description of the above cyclic logic state machine, and this application will not repeat it here.
[0118] In one embodiment, if the node type of the first state node is a data transmission type, the unique attributes of the first state node may include an optional parameter: data output information. The optional parameters of the unique attributes of the data transmission type state node are defined as follows:
[0119] Result data output information: construct some data as the output of the current state node.
[0120] In one embodiment, if the node type of the first state node is the waiting execution type, the unique attributes of the first state node may include optional parameters: waiting duration and waiting time point. The optional parameters of the unique attributes of the waiting execution type state node are defined as follows:
[0121] seconds Waiting time: specifies the waiting time of the current state node, the unit of which is seconds.
[0122] timestamp waiting time point: specifies the time point that the current status node waits for. The format of the time point can be "2021-01-01 10:00:00".
[0123] In one embodiment, if the node type of the first state node is an execution success type, the unique attribute of the first state node may include an optional parameter: success reason information. The optional parameter definition of the unique attribute of the execution success type state node is as follows:
[0124] info Success reason information: defines the descriptive reason for success.
[0125] In one embodiment, if the node type of the first state node is an execution failure type, the unique attribute of the first state node may include an optional parameter: failure reason information. The optional parameter definition of the unique attribute of the execution failure type state node is as follows:
[0126] cause Failure reason information: defines the description reason of the failure.
[0127] In one embodiment, the data input rule is used to select input data from source data and output results of other state nodes.
[0128] It should be noted that the allowed value types of the data input rule can be Json, JsonPath or $. If no data input rule is configured, the default value of the data input rule is $.
[0129] The following string is an example of a data entry rule with a default value:
[0130] input:$
[0131] It should be noted that $ is the JsonPath syntax, which represents the complete Json data. The above string can represent that all visible data can be obtained through the JsonPath $, that is, the current state node can see the source data entered by the user and the output results of the executed state node.
[0132] The string shown below is an example of a JsonPath data input rule:
[0133] input:$.user.name
[0134] It should be noted that the above string indicates that the data is obtained by specifying the path through JsonPath. In other words, the string is used to represent a path information, not a specific numerical information. When the string is run, the corresponding numerical information can be obtained according to the path information.
[0135] The following string is an example of a Json data input rule:
[0136]
[0137] It should be noted that the above string can represent direct assignment of keywords, for example, the above string can directly assign the keyword "memberId" to 100. It should also be noted that when using Json, if there is ".$" at the end of a keyword, it means that its value is obtained through JsonPath, such as "id.$" and "name.$" in the above string; if there is no ".$" at the end of a keyword, it means that its value is a static value, that is, a fixed value written in the state machine text.
[0138] Optionally, for a loop execution type state node, you can use the $$ symbol to obtain loop variable information. See the string example of the loop execution type above:
[0139]
[0140] It should be noted that the $$ symbol is used to describe some global variables and specific variables generated during the operation of the state machine. Currently, only the iteration variables generated in the loop execution type support the use of this symbol. In the state node of the loop execution type, you can support getting the index of the loop item through $$.foreachItem.index, and you can support getting the value of the loop item through $$.foreachItem.value.
[0141] In one embodiment, the data output rule is used to determine the output result according to the processing result.
[0142] It should be noted that the allowed value types of the data output rule can be Json, JsonPath or null. If no data output rule is configured, the default value of the data output rule is null.
[0143] The following string is an example of a data output rule with the default value:
[0144] output:null
[0145] It should be noted that when the data output rule is null, it means that the current state node has no output.
[0146] The string shown below is an example of a JsonPath data output rule:
[0147] output:$.local.name
[0148] It should be noted that the string represents the path specified by JsonPath, and the content corresponding to the path is output. For the relevant description of output through JsonPath, please refer to the specific description of input through JsonPath, and this application will not repeat it here.
[0149] The string shown below is an example of a Json data output rule:
[0150]
[0151] It should be noted that the assembly method and usage rules of the above-mentioned Json output can be found in the specific description of the aforementioned data input rules, and this application will not go into details here.
[0152] S303: The server generates a state machine corresponding to the target business according to the one or more state nodes and the characteristic data of each state node, and each state node is used to execute a business process of the target business.
[0153] In the embodiment of the present application, by obtaining the state machine configuration data for the target business, and determining one or more state nodes and characteristic data of each state node according to the state machine configuration data, the state machine corresponding to the target business can be generated according to the one or more state nodes and characteristic data of each state node. By implementing the method provided in the embodiment of the present application, a state node with rich functions can be provided, thereby accurately and comprehensively describing the workflow of the business.
[0154] Based on the above state machine configuration system, the embodiment of the present invention provides another state machine configuration method. Figure 4 , is a flow chart of another state machine configuration method provided by an embodiment of the present invention. The state machine configuration method can be applied to Figure 2 The state machine configuration system shown is executed by a server, and specifically can be executed by a processor of the server. The state machine configuration method includes the following steps:
[0155] S401: The server obtains state machine configuration data for a target service.
[0156] S402: The server determines one or more state nodes and characteristic data of each state node according to the state machine configuration data. The characteristic data includes common attributes and specific attributes. The common attributes include node type and terminal state node indication information.
[0157] S403: The server generates a state machine corresponding to the target business according to the one or more state nodes and the characteristic data of each state node, and each state node is used to execute a business process of the target business.
[0158] It should be noted that S401 to S403 are the same as S301 to S303 in the aforementioned embodiment. For detailed description, please refer to the aforementioned content, and this application will not repeat them here.
[0159] S404: The server obtains an input data storage object and an output result storage object, wherein the input data storage object stores source data input by the user, and the output result storage object stores output results of the executed state node.
[0160] It should be noted that the above-mentioned input data storage object and output result storage object can be understood as two different storage spaces. The input data storage object is used to store the source data input by the user, and the output result storage object is used to store the output results of the executed state node.
[0161] It should also be noted that the data in the above-mentioned input data storage object and output result storage object can be shared among state machine nodes, that is, the data in the input data storage object and output result storage object can be obtained through the above-mentioned data input rules and data output rules.
[0162] In one embodiment, the input data storage object may be set to a Json structure object with a keyword "input", and the output result storage object may be set to a Json structure object with a keyword "local".
[0163] It should be noted that when the state machine is started, the user's input data will be placed in the "input" Json structure object, and a "local" Json structure object will be initialized, that is, an output result storage object, which is used to store the output data of each node of the state machine.
[0164] It is understandable that one state machine may correspond to one output result storage object. As can be seen from the foregoing, the cyclic logic state machine and the parallel logic state machine may be regarded as a new state machine. Therefore, the cyclic logic state machine or the parallel logic state machine may set a new output result storage object for storing the output data of each node in the cyclic logic state machine or the parallel logic state machine.
[0165] S405. The server determines the input data of the second state node according to the input data storage object and the output result storage object. The second state node is any one of the one or more state nodes.
[0166] It should be noted that the second state node and the aforementioned first state node are any one of one or more state nodes, that is, the second state node can be the same state node as the first state node, or can be a different state node, and this application does not impose any restrictions on this.
[0167] Specifically, the second state node may be a node corresponding to a certain business process when the business is executed. When the state machine starts to execute, the second state node is the starting state node, that is, execution starts from the starting state node.
[0168] In one embodiment, the server determines the input data of the second state node based on the input data storage object and the output result storage object, including: obtaining the data input rule of the second state node; determining the target data from the source data included in the input data storage object and the output result included in the output result storage object according to the data input rule; and using the target data as the input data of the second state node.
[0169] As can be seen from the above content, when no data input rule is configured, the default value of the data input rule is $, that is, the default is the source data entered by the user. The server can change the input data of the current state node according to the data input rule, that is, change the data in the input data storage object.
[0170] It should be noted that the input data changed by the data input rule is only valid for the current state node; that is, only the input data of the current state node is changed, and the input data of other state nodes is not affected. Among them, the changed input data can be obtained in the state node by the keyword that can obtain data. In other words, the changed input data can be seen in the function indication parameters and data output rules.
[0171] For example, see Figure 5 , the string shown below is Figure 5 Corresponding example of changing input data through data input rules:
[0172]
[0173]
[0174] Assume that the source data entered by the user is input: {"key":"666"}, and the initial state machine storage is local: {}. Figure 5 It can be seen that the state machine has two state nodes, asr and asrPostProcessor. Taking the state node named asr as an example, add "version":"1.0" to the source data through the data input rule, so that Figure 5 The input data of the state node named ASR in the example is changed from the original key: "666" to key: "666", "version": "1.0". Figure 5 It can be seen that the changed input data can be shared among the current state nodes.
[0175] S406: The server calls the second state node to process the input data and obtains a processing result.
[0176] It should be noted that the above processing result can be the data obtained after the server processes the input data by calling the second state node. The processing result can indicate that the second state node processes the input data. The processing result can be used as an output result or not as an output result, and this application does not limit this.
[0177] S407: The server performs output processing on the processing result using the data output rule of the second state node, determines the output result of the second state node, and stores the output result of the second state node in an output result storage object.
[0178] As can be seen from the above content, the data output rule of each state node defaults to null, that is, the processing result of the current node will not be stored in the output result storage object by default, that is, the processing result will not be output to other state nodes. The server can change the output result of the current node through the data output rule and store the output result in the output result storage object.
[0179] It should be noted that the output results of each state node in the state machine can be stored in the output result storage object. In addition, the next state node of the current state node can obtain any output result stored in the output result storage object. For example, the data stored in the output result storage object can be obtained through the string: $.local.
[0180] In one embodiment, the above method also includes: if the termination state node indication information of the second state node indicates that the second state node is a termination state node, obtaining the data output rule of the state machine; according to the data output rule of the state machine, determining the output result of the state machine from the source data included in the input data storage object and the output result included in the output result storage object.
[0181] It should be noted that, when the second state node is a terminal state node and the state machine is not configured with a data output rule, the output result of the state machine can default to the output result of the second state node. Optionally, when the state machine is configured with a data output rule, the server can also determine the output result of the state machine from the input data storage object and the output result storage object according to the data output rule of the state machine.
[0182] Optionally, for the cyclic logic state machine and the parallel logic state machine, the server can store the source data output by the user in the input data storage object by default, and recreate an output result storage object, and the recreated output result storage object is only visible to the current state machine. Therefore, if the cyclic logic state machine and the parallel logic state machine are not configured with data output rules, the data in the output result storage object of the current state machine is only visible to the current state machine.
[0183] For example, see Figure 6 , assuming that the source data entered by the user is input: {"key":"666"}, and the storage of the initialized state machine is local: {}. Figure 6 It can be seen that due to Figure 6The B state node in is a parallel execution type, so the B state node is a parallel logic state machine. It can be seen that the input data of the parallel logic state machine defaults to the source data entered by the user, that is, key: "666"; the parallel logic state machine has no data output rule configured, that is, output: null. Therefore, the output result in the above output result storage object, that is, "ccData": "123456", is only visible to the parallel logic state machine.
[0184] Optionally, the server may also change the input data of the cyclic logic state machine or the parallel logic state machine according to the data input rule. For a specific description, please refer to the above content, and this application will not repeat it here. It is understandable that if the above input data is changed, the changed input data is also only visible to the current state machine.
[0185] By implementing the method provided in the embodiment of the present application, the server can utilize the aforementioned state machine configuration method to determine the input data and output data of each state node and the current state machine according to the data input rules and data output rules, and configure the template by using the above-mentioned grammar rules to accurately and comprehensively describe the workflow of the business to generate a state machine corresponding to the target business.
[0186] Based on the above state machine configuration method, an embodiment of the present invention provides a state machine configuration device. Figure 7 , Figure 7 : is a schematic diagram of the structure of a state machine configuration device provided by an embodiment of the present invention. The state machine configuration device 700 can run the following units:
[0187] An acquisition unit 701 is used to acquire state machine configuration data for a target service;
[0188] A determination unit 702, configured to determine one or more state nodes and feature data of each state node according to the state machine configuration data, wherein the feature data includes common attributes and specific attributes, and the common attributes include node type and terminal state node indication information;
[0189] The processing unit 703 is used to generate a state machine corresponding to the target business according to one or more state nodes and characteristic data of each state node, wherein each state node is used to execute a business process of the target business.
[0190] In one embodiment, the node type is any one of a task processing type, a data transmission type, a branch selection type, a loop execution type, a parallel execution type, a waiting execution type, an execution success type and an execution failure type.
[0191] In one embodiment, the above-mentioned determination unit 702 is also used to determine one or more state nodes and characteristic data of each state node based on definition information of one or more state nodes; the above-mentioned determination unit 702 is also used to determine the starting state node from one or more state nodes based on indication information of the starting state node.
[0192] In one embodiment, if the node type of the first state node is a task processing type, the unique attributes of the first state node include interface parameters and function indication parameters, and the first state node is any one of one or more state nodes; if the node type of the first state node is a branch selection type, the unique attributes of the first state node include a selection logic rule array, and the selection logic rule array includes a selection condition and a next state node; if the node type of the first state node is a loop execution type, the unique attributes of the first state node include path information of the loop variable and a loop logic state machine; if the node type of the first state node is a parallel execution type, the unique attributes of the first state node include a parallel logic state machine.
[0193] In one embodiment, the above-mentioned general attributes also include data input rules and data output rules; the data input rules are used to select input data from source data and output results of other state nodes; the data output rules are used to determine output results according to processing results.
[0194] In one embodiment, the acquisition unit 701 is further used to acquire an input data storage object and an output result storage object, wherein the input data storage object stores source data input by a user, and the output result storage object stores the output result of a state node that has been executed; the determination unit 702 is further used to determine the input data of a second state node according to the input data storage object and the output result storage object, wherein the second state node is any one of one or more state nodes; the processing unit 703 is further used to call the second state node to process the input data to obtain a processing result; the determination unit 702 is further used to output the processing result using the data output rule of the second state node to determine the output result of the second state node, and the processing unit 703 is further used to store the output result of the second state node in the output result storage object.
[0195] In one embodiment, the acquisition unit 701 is also used to acquire the data input rule of the second state node; the determination unit 702 is also used to determine the target data from the source data included in the input data storage object and the output result included in the output result storage object according to the data input rule; the processing unit 703 is also used to use the target data as the input data of the second state node.
[0196] In one embodiment, if the termination state node indication information of the second state node indicates that the second state node is a termination state node, the above-mentioned acquisition unit 701 is also used to obtain the data output rule of the state machine; the above-mentioned determination unit 702 is also used to determine the output result of the state machine from the source data included in the input data storage object and the output result included in the output result storage object according to the data output rule of the state machine.
[0197] According to one embodiment of the present invention, Figure 3 The various steps involved in the state machine configuration method shown can be performed by Figure 7 The state machine shown configures each unit in the device to execute. For example, Figure 3 The step S301 can be performed by Figure 7 The state machine configuration device 700 shown in FIG. 1 is configured to be executed by the acquisition unit 701, and step S302 can be performed by Figure 7 The state machine configuration device 700 shown in FIG. 1 is configured to be executed by the determination unit 702, and step S303 can be performed by Figure 7 The illustrated state machine configures the processing unit 703 in the apparatus 700 to execute.
[0198] According to another embodiment of the present invention, Figure 7 The various units in the state machine configuration device shown can be separately or completely combined into one or several other units to form, or one (some) of the units can be further divided into multiple functionally smaller units to form, which can achieve the same operation without affecting the realization of the technical effects of the embodiments of the present invention. The above-mentioned units are divided based on logical functions. In practical applications, the function of one unit can also be implemented by multiple units, or the functions of multiple units can be implemented by one unit. In other embodiments of the present invention, other units can also be included based on the state machine configuration device. In practical applications, these functions can also be implemented with the assistance of other units, and can be implemented by the collaboration of multiple units.
[0199] According to another embodiment of the present invention, the program can be executed by running a program on a general computing device such as a computer including a central processing unit (CPU), a random access memory medium (RAM), a read-only memory medium (ROM), and other processing elements and storage elements. Figure 3 A computer program (including program code) for each step involved in the corresponding method shown in FIG. Figure 7 The state machine configuration device shown in and the state machine configuration method of the embodiment of the present invention are implemented. The computer program can be recorded on, for example, a computer storage medium, and loaded into the above-mentioned computing device through the computer storage medium and run therein.
[0200] Based on the above-mentioned state machine configuration method and state machine configuration device embodiments, the present invention provides an electronic device, and the electronic device described herein corresponds to the above-mentioned server. Figure 8 , is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention, the electronic device 800 may at least include: a processor 801, a communication interface 802 and a computer storage medium 803. The processor 801, the communication interface 802 and the computer storage medium 803 may be connected via a bus or other means.
[0201] The computer storage medium 804 can be stored in the memory 804 of the electronic device 800, the computer storage medium 801 is used to store a computer program, the computer program includes program instructions, and the processor 801 is used to execute the program instructions stored in the computer storage medium 803. The processor 801 (or CPU (Central Processing Unit)) is the computing core and control core of the electronic device 800, which is suitable for implementing one or more instructions, specifically suitable for loading and executing:
[0202] Obtain state machine configuration data for the target business; determine one or more state nodes and characteristic data of each state node based on the state machine configuration data, the characteristic data including common attributes and unique attributes, the common attributes including node type and termination state node indication information; generate a state machine corresponding to the target business based on one or more state nodes and the characteristic data of each state node, each of the above state nodes is used to execute a business process of the target business.
[0203] In the embodiment of the present application, by obtaining the state machine configuration data for the target business, and determining one or more state nodes and characteristic data of each state node according to the state machine configuration data, the state machine corresponding to the target business can be generated according to the one or more state nodes and characteristic data of each state node. By implementing the method provided in the embodiment of the present application, a state node with rich functions can be provided, thereby accurately and comprehensively describing the workflow of the business.
[0204] Those of ordinary skill in the art will appreciate that the units and steps of each example described in conjunction with the embodiments disclosed in this application can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0205] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer storage medium or transmitted through a computer storage medium. The computer instructions can be transmitted from a website site, a computer, a server or a data center to another website site, a computer, a server or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer storage medium can be any available medium that a computer can access or a data storage device such as a server or a data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.
[0206] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A state machine configuration method, characterized in that: The method comprises: Obtain state machine configuration data for the target business; wherein the state machine configuration data is input based on the grammar rule configuration template displayed in the interface, and the grammar rule configuration template includes a state machine description template, a node definition template, and an input and output rule configuration template; the state machine configuration data includes mandatory parameters and optional parameters, the mandatory parameters in the state machine configuration data include state node definition information and indication information of the starting state node, and the optional parameters in the state machine configuration data include description information of the state machine and / or timeout information of the state machine operation; Determine one or more state nodes and characteristic data of each state node according to the state machine configuration data, wherein the characteristic data includes common attributes and specific attributes, wherein the common attributes include node type and terminal state node indication information; wherein the common attributes also include optional parameters, wherein the optional parameters in the common attributes include one or more of description information of the state node, data input rules, and data output rules; A state machine corresponding to the target business is generated according to the one or more state nodes and the characteristic data of each state node, and each state node is used to execute a business process of the target business.
2. The method according to claim 1, characterized in that The node type is any one of a task processing type, a data transmission type, a branch selection type, a loop execution type, a parallel execution type, a waiting execution type, an execution success type and an execution failure type.
3. The method according to claim 1 or 2, characterized in that: The state machine configuration data includes definition information of the one or more state nodes and indication information of the starting state node, and the determining of the one or more state nodes and characteristic data of each state node according to the state machine configuration data includes: Determine the one or more state nodes and feature data of each state node according to definition information of the one or more state nodes; The starting state node is determined from the one or more state nodes according to the indication information of the starting state node.
4. The method according to claim 1 or 2, characterized in that: If the node type of the first state node is a task processing type, the specific attributes of the first state node include an interface parameter and a function indication parameter, and the first state node is any one of the one or more state nodes; If the node type of the first state node is a branch selection type, the unique attribute of the first state node includes a selection logic rule array, and the selection logic rule array includes a selection condition and a next state node; If the node type of the first state node is a loop execution type, the specific attributes of the first state node include path information of loop variables and a loop logic state machine; If the node type of the first state node is a parallel execution type, the unique attribute of the first state node includes a parallel logic state machine.
5. The method according to claim 1 or 2, characterized in that: The general attributes also include data input rules and data output rules; The data input rule is used to select input data from source data and output results of other state nodes; The data output rule is used to determine the output result according to the processing result.
6. The method according to claim 1 or 2, characterized in that: The method further comprises: Obtain an input data storage object and an output result storage object, wherein the input data storage object stores source data input by a user, and the output result storage object stores output results of the executed state node; Determine input data of a second state node according to the input data storage object and the output result storage object, the second state node being any one of the one or more state nodes; Calling the second state node to process the input data to obtain a processing result; The processing result is output-processed using the data output rule of the second state node to determine the output result of the second state node, and the output result of the second state node is stored in the output result storage object.
7. The method according to claim 6, characterized in that The step of determining the input data of the second state node according to the input data storage object and the output result storage object comprises: Obtaining data input rules for the second state node; According to the data input rule, determining target data from the source data included in the input data storage object and the output result included in the output result storage object; The target data is used as input data of the second state node.
8. The method according to claim 6, characterized in that The method further comprises: If the termination state node indication information of the second state node indicates that the second state node is a termination state node, obtaining a data output rule of the state machine; According to the data output rule of the state machine, the output result of the state machine is determined from the source data included in the input data storage object and the output result included in the output result storage object.
9. A state machine configuration device, characterized in that: The device comprises: An acquisition unit, used to acquire state machine configuration data for a target business; wherein the state machine configuration data is input based on a grammar rule configuration template displayed in an interface, and the grammar rule configuration template includes a state machine description template, a node definition template, and an input-output rule configuration template; the state machine configuration data includes mandatory parameters and optional parameters, the mandatory parameters in the state machine configuration data include state node definition information and indication information of a starting state node, and the optional parameters in the state machine configuration data include description information of the state machine and / or timeout information of the state machine operation; A determination unit, configured to determine one or more state nodes and characteristic data of each state node according to the state machine configuration data, wherein the characteristic data includes common attributes and specific attributes, wherein the common attributes include node type and terminal state node indication information; wherein the common attributes also include optional parameters, wherein the optional parameters in the common attributes include one or more of description information of the state node, data input rules, and data output rules; The processing unit is used to generate a state machine corresponding to the target business according to the one or more state nodes and the characteristic data of each state node, and each state node is used to execute a business process of the target business.
10. An electronic device, characterized in that: include: a processor adapted to implement one or more instructions; as well as A computer storage medium storing one or more instructions, wherein the one or more instructions are suitable for being loaded by the processor and executing the method according to any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and the program instructions are executed by a processor to implement the method according to any one of claims 1 to 8.
12. A computer program product, characterized in that The computer program product comprises a computer program or a computer instruction, and when the computer program or the computer instruction is executed by a processor, it is used to implement the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
A flow control method and a flow engine
CN101216906A
Method and system for processing state machine
CN102109984A
Service construction method and device and computer equipment
CN110765099A
State machine template generation and task processing method and device, medium and equipment
CN112051993A
General purpose dynamically programmable state engine for executing finite state machines
US6212625B1
