Application programming interface arrangement method and device, equipment and storage medium
By analyzing the orchestration templates to generate a task stack and submitting it to the thread pool, the problem of low API orchestration in the existing technology is solved, and efficient API orchestration and complex call logic choreography are realized.
Patent Information
- Application Number
- CN202311107890.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-30
- Publication Date
- 2025-02-28
AI Technical Summary
In the prior art, the combination and call between multiple APIs is realized through encoding, resulting in low encoding efficiency and thus reducing API orchestration efficiency.
Provides an application programming interface orchestration method, which generates a task stack for topology sorting of vertex active networks by parsing the configured orchestration template, and stores the task stack to a database. According to the topology sorting of vertex activity network, subtasks in the task stack are submitted to the thread pool, subtasks are executed, and resource requests are generated, and sent to the resource service system to implement API orchestration.
It reduces the coding workload of programmers, improves the efficiency of API orchestration, and realizes complex calling logic orchestration without writing a lot of coding.
Smart Images

Figure CN119536923A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to an application programming interface arrangement method, device, equipment and storage medium. Background Art
[0002] With the popularity and widespread use of microservices, the communication and calls between services are increasing day by day. At the same time, the orchestration of multiple asynchronous application programming interfaces (Application Programming Interface, API) has also become a problem that needs to be solved.
[0003] In some related technologies, developers can implement the combination and calling of multiple APIs through coding. However, due to the low coding efficiency, the API orchestration efficiency is low. Summary of the invention
[0004] The present application provides an application programming interface (API) arrangement method, apparatus, device and storage medium, which are used to solve the technical problem in the related art that the combination and calling of multiple APIs are realized by coding, and the API arrangement efficiency is low due to the low coding efficiency.
[0005] In a first aspect, the present application provides an application programming interface orchestration method, which is applied to an orchestration engine of an orchestration system, wherein the orchestration system further includes a database, and the database stores an orchestration template, an interface template, and a platform template; including:
[0006] receiving an arrangement request input by a user;
[0007] Based on the orchestration request, the orchestration template is parsed to generate a task stack with topological sorting of the vertex activity network, and the task stack is stored in the database. The task stack contains multiple subtasks.
[0008] Submit the subtasks in the task stack to the thread pool according to the topological sorting of the vertex activity network, so that the thread executing the subtask obtains the interface parameter information corresponding to the subtask from the interface template;
[0009] Generate a corresponding resource request according to the interface parameter information of the subtask, determine the resource service system corresponding to the interface parameter information according to the platform template, and send the resource request to the resource service system so that the resource service system executes the subtask.
[0010] Optionally, in the method described above, the task stack further includes dependencies between subtasks and the status of each subtask; and submitting the subtasks in the task stack to the thread pool according to the topological sorting of the vertex activity network includes:
[0011] Subtasks that do not depend on any subtask are submitted to the thread pool according to the topological sorting of the vertex activity network to execute multiple subtasks concurrently;
[0012] For a subtask that depends on any subtask, if the status of the dependent subtask is completed, the subtask that depends on the dependent subtask is submitted to the thread pool to execute the subtask and the dependent subtask serially.
[0013] Optionally, in the method as described above, sending the resource request to the resource service system includes:
[0014] Based on message queue or hypertext transfer protocol, resource requests are sent to the resource service system.
[0015] Optionally, the method as described above further comprises:
[0016] Determine whether the subtask is an asynchronous task based on the interface parameter information;
[0017] If the subtask is an asynchronous task, based on the message queue monitoring mechanism, obtain the subtask execution message returned by the resource service system through the message queue. The subtask execution message includes an execution end message, and the execution end message includes the execution result of the subtask.
[0018] If the execution result of the subtask is completion, the status of the subtask in the task stack is updated to completion status.
[0019] Optionally, in the above method, the database further includes a rollback interface template; the method further includes:
[0020] If the execution result of the subtask is execution failure, an inverse task stack of the inverse topological sorting corresponding to the vertex activity network topological sorting is generated according to the rollback interface template;
[0021] The inverse task stack is stored in the database, and the subtasks contained in the inverse task stack are submitted to the thread pool according to the inverse topological sorting, so as to send a rollback request to the corresponding resource service system, and the resource service system executes the subtasks;
[0022] Receive the rollback result fed back by the resource service system.
[0023] Optionally, in the above method, the subtask execution message further includes an execution notification message; and the method further includes:
[0024] If the subtask is an asynchronous task, the execution notification message returned by the resource service system through the message queue is received, and the state of the subtask in the task stack is updated to the execution state.
[0025] Optionally, the method as described above further comprises:
[0026] Determine whether there are unexecuted subtasks in the task stack according to the status of each subtask in the task stack;
[0027] If so, submit the unexecuted subtasks to the thread pool according to the topological sorting of the vertex activity network to execute the unexecuted subtasks;
[0028] If not, the subtask that is finally executed is recorded as the task stack end task.
[0029] In a second aspect, the present application provides an application programming interface orchestration device, which is applied to an orchestration engine of an orchestration system, wherein the orchestration system further includes a database, and the database stores an orchestration template, an interface template, and a platform template; including:
[0030] A receiving module, used for receiving an arrangement request input by a user;
[0031] A processing module is used to parse the orchestration template based on the orchestration request, generate a task stack of topological sorting of the vertex activity network, and store the task stack in a database, wherein the task stack includes multiple subtasks;
[0032] The processing module is further used to submit the subtasks in the task stack to the thread pool according to the topological sorting of the vertex activity network, so that the thread executing the subtask obtains the interface parameter information corresponding to the subtask from the interface template;
[0033] The processing module is further used to generate a corresponding resource request according to the interface parameter information of the subtask, and determine the resource service system corresponding to the interface parameter information according to the platform template;
[0034] The sending module is used to send the resource request to the resource service system so that the resource service system executes the subtask.
[0035] In a third aspect, the present application provides an electronic device, comprising: a processor, and a memory communicatively connected to the processor;
[0036] Memory stores computer-executable instructions;
[0037] The processor executes the computer-executable instructions stored in the memory to implement any method of the first aspect.
[0038] In a fourth aspect, the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement any method as in the first aspect.
[0039] The application programming interface arrangement method, device, equipment and storage medium provided by the present application parse the arrangement template stored in the database based on the arrangement request input by the user, generate a task stack of vertex activity network topology sorting, and store the task stack in the database, wherein the task stack contains multiple subtasks. Submit the subtasks in the task stack to the thread pool according to the vertex activity network topology sorting, so that the thread executing the subtask obtains the interface parameter information corresponding to the subtask from the interface template. Generate the corresponding resource request according to the interface parameter information, and determine the resource service system corresponding to the interface parameter information according to the platform template, and send the resource request to the resource service system so that the resource service system executes the subtask, so as to realize the arrangement of the application programming interface, that is, resource arrangement. The method of the present application generates a task stack of vertex activity network topology sorting by parsing the configured arrangement template, and can complete the complex call logic arrangement by combining the configured interface template and platform template, without the need for programmers to write a large amount of code to realize the combination and call between multiple APIs, which reduces the coding workload and effectively improves the efficiency of API arrangement. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0041] Figure 1 A target system architecture diagram provided for an embodiment of the present application;
[0042] Figure 2 A flow chart of an application programming interface arrangement method provided in an embodiment of the present application;
[0043] Figure 3 A schematic diagram of AOV topological sorting provided in an embodiment of the present application;
[0044] Figure 4 A flow chart of a method for submitting a subtask to a thread pool provided in an embodiment of the present application;
[0045] Figure 5 A schematic diagram of an execution of an orchestration system provided in an embodiment of the present application;
[0046] Figure 6 A schematic diagram of a process of executing a subtask by an orchestration engine provided in an embodiment of the present application;
[0047] Figure 7 A flowchart of a subtask execution method provided in an embodiment of the present application;
[0048] Figure 8 A schematic diagram of an application programming interface arrangement device provided in an embodiment of the present application;
[0049] Fig. 9 A schematic diagram of an electronic device provided in an embodiment of the present application.
[0050] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0051] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0052] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0053] First, the terms involved in this application are explained:
[0054] Activity On Vertex Network (AOV): In a directed graph, if vertices represent activities and edges represent the sequence relationship between activities, the directed graph is called a vertex activity network.
[0055] With the popularity and widespread use of microservices, the communication and calls between services are increasing day by day. At the same time, the orchestration of multiple asynchronous application programming interfaces has become a problem that needs to be solved. At the same time, improving deployment efficiency, optimizing system architecture, saving costs, improving orchestration efficiency, and reducing the workload of programmers have also become issues of concern.
[0056] In some related technologies, developers, i.e., programmers, can implement the combination and calling of multiple APIs through coding, which results in low coding efficiency and low API orchestration efficiency.
[0057] Based on the above problems, this application provides an application programming interface orchestration method, which is based on the theoretical method of resource orchestration service. By parsing the configured orchestration template, a task stack of vertex activity network topology sorting is formed. The subtasks contained in the task stack can be executed in combination with the configured interface template and platform template, thereby realizing complex call logic orchestration. The orchestration template, interface template and platform template of this application only need json configuration to realize the corresponding configuration, which reduces the coding workload of programmers and effectively improves the orchestration efficiency.
[0058] Figure 1 A target system architecture diagram provided for an embodiment of the present application, wherein the target system may include product application services and an orchestration system, and the orchestration system may be embedded in the target system as middleware for use to execute complex orchestration logic of product application services. The orchestration system may include an orchestration engine, i.e., an orchestration service, and a database, wherein the orchestration engine is the main part of the orchestration system and may be implemented in Java. Figure 1 The application programming interface resources in the are application programming interfaces provided by a third-party resource service system. The orchestration system can orchestrate the application programming interfaces to implement user requests.
[0059] It should be noted that the orchestration system of the present application can be applied to a variety of application scenarios that require more complex orchestration logic, and the present application does not limit the application scenarios of the orchestration system.
[0060] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0061] Figure 2 The present application provides an application programming interface orchestration method flow chart, which is applied to the orchestration engine of the orchestration system. The orchestration system also includes a database, which stores the orchestration template, interface template and platform template. Figure 2 As shown, the method may include:
[0062] S201: receiving an arrangement request input by a user.
[0063] In some embodiments, the orchestration request may include information such as a template name and transfer parameters that need to be transferred to the interface template.
[0064] S202: Based on the orchestration request, the orchestration template is parsed to generate a task stack of topological sorting of the vertex activity network, and the task stack is stored in a database, where the task stack includes multiple subtasks.
[0065] In some embodiments, the orchestration template is the core configuration of the task stack that the orchestration system parses into the AOV topological sorting. The orchestration template can define each execution step, the execution interface, and the dependency relationship between each execution step. Among them, the dependency relationship between each execution step can be determined by setting the dependency relationship of the interface, and the interface is an application programming interface. The number of orchestration templates can be multiple.
[0066] In some embodiments, the orchestration template includes template name information, so the corresponding orchestration template can be determined according to the template name included in the orchestration request, and the orchestration template can be parsed according to the transmission parameters passed to the interface template as needed. The orchestration template also includes multiple API interfaces corresponding to the template name, and the dependency relationship between the API interfaces. For example, a template with a template name of task needs to call 3 API interfaces, among which API2 depends on API1, and API3 depends on API1. Figure 3 A schematic diagram of AOV topological sorting provided in an embodiment of the present application is shown in FIG. Figure 3 As shown, the AOV topological sorting diagram can represent the dependency relationship between API interfaces.
[0067] In some embodiments, during the parsing of the orchestration template, the dependencies of the API interfaces in the orchestration template and the transfer parameters of each API interface may be modified to generate subtasks corresponding to each API interface to achieve rearrangement of the API interfaces.
[0068] In some embodiments, after the task stack is stored in the database, the status of the subtasks included in the task stack can be refreshed, and the executable subtasks can be determined according to the status of the subtasks. The status of the subtasks can include an initial state, an execution state, a completion state, etc. The initial state can indicate that the subtask has not been executed, the execution state indicates that the subtask is in the process of execution, and the completion state indicates that the subtask has been completed. Since the subtasks in the process of execution and the subtasks that have been completed do not need to be executed again, the subtasks in the initial state are executable subtasks.
[0069] S203: Submitting the subtasks in the task stack to the thread pool according to the topological sorting of the vertex activity network, so that the thread executing the subtask obtains the interface parameter information corresponding to the subtask from the interface template.
[0070] In some embodiments, each application programming interface has an interface template corresponding to it, and the interface template can define the API parameter structure, return result, and return form that need to be parsed into the execution steps. In one implementation scenario, the API parameter structure may include the request parameter information contained in the http (Hypertext Transfer Protocol) request, which may specifically include the request header (header), response header (response), request body (body), etc., which will not be described one by one in this application. In another implementation scenario, the API parameter structure may also include the parameter information required for the mq (Message queue) request.
[0071] Since the subtasks in the task stack can represent the API interfaces that need to be called and executed, the corresponding interface template can be obtained according to the determined API interface, and then the interface template can be parsed to obtain the interface parameter information corresponding to the API interface. For example, since the template named task needs to call three interfaces API1, API2 and API3, each interface has a corresponding interface template to obtain the interface parameter information corresponding to each interface.
[0072] In some embodiments, configuration functions may be used in the orchestration template and the interface template to perform complex parameter settings. Configuration functions include but are not limited to assignment functions, functions for obtaining parameters, functions for selecting parameters, and other types of configuration functions.
[0073] S204: Generate a corresponding resource request according to the interface parameter information of the subtask, determine the resource service system corresponding to the interface parameter information according to the platform template, and send the resource request to the resource service system so that the resource service system executes the subtask.
[0074] In some embodiments, the platform template may define the platform to which the API belongs, namely the resource service system, including information such as the platform request address and the monitored message queue. In one implementation scenario, the resource request may be sent to the resource service system based on the message queue or the hypertext transfer protocol. The resource service system is a third-party platform that provides the API interface.
[0075] In some embodiments, the resource request can be a request in the form of an http request or an mq request. When generating a resource request, the resource request can be determined to be an http request or an mq request according to the form of the API interface provided by the resource service system. The orchestration system can execute the corresponding API interface to send the resource request to the resource service system. If the resource request is an http request, the resource request can be sent to the resource service system through the http service provided by the resource service system. If the resource request is an mq request, the resource request can be sent to the resource service system through the middleware message queue.
[0076] In some embodiments, the SPI (Service Provider Interface) method provided by Spring, that is, the extended SPI package, can be used to read the mq information configured by the platform template to achieve automatic binding and monitoring of mq without code writing.
[0077] In some embodiments, the database of the present application may include a persistent sql (Structured Query Language) database and a redis (Remote Dictionary Server) database. The persistent sql database may be used to store the above-mentioned orchestration templates, interface templates and platform templates, and the redis database may be used to store the AOV topologically sorted task stack obtained by parsing the orchestration template.
[0078] The embodiment of the present application provides an application programming interface orchestration method, which receives an orchestration request input by a user, parses the configured orchestration template based on the orchestration request, generates a task stack of vertex activity network topology sorting, and stores the task stack in a database, which may contain multiple subtasks. The subtasks of the task stack are submitted to the thread pool according to the vertex activity network topology sorting, so that the thread executing the subtask obtains the interface parameter information corresponding to the subtask from the interface template. The corresponding resource request is generated according to the interface parameter information of the subtask, and the resource service system corresponding to the interface parameter information is determined according to the configured platform template, and the resource request is sent to the resource service system so that the resource service system executes the subtask. The orchestration system of the present application is a specific implementation of a light-code complex API call orchestration system. It only needs to use json to configure the orchestration template, the interface templates of each API interface, and the platform template to complete the complex call logic orchestration, which reduces the coding workload of programmers, improves programming efficiency, and effectively improves the execution efficiency of the orchestration system, that is, improves the orchestration efficiency.
[0079] Figure 4 A flowchart of a method for submitting subtasks to a thread pool provided in an embodiment of the present application. In one or more embodiments of the present application, the task stack also includes dependencies between subtasks and the status of each subtask; the subtasks in the task stack are submitted to the thread pool according to the topological sorting of the vertex activity network, including: Figure 4 Steps shown:
[0080] S401: Submitting subtasks that do not depend on any subtask to a thread pool according to the topological sorting of the vertex activity network, so as to execute multiple subtasks concurrently.
[0081] In some embodiments, compared with some related technologies that perform orchestration based on event streams, since this method is based on a persistent SQL database, there is a problem of poor concurrency performance, resulting in low API orchestration efficiency and limiting the performance of the orchestration system. The task stack of this application is a topologically sorted data structure, which optimizes the execution order of subtasks. At the same time, concurrent means are used for subtasks that can be executed in parallel, that is, multiple subtasks that do not depend on any subtask, which effectively improves the execution efficiency of the orchestration system.
[0082] For example, Figure 5 A schematic diagram of an execution of an orchestration system provided in an embodiment of the present application, comprising Figure 5 It can be seen that subtask 1, subtask 2 and subtask 3 do not depend on other subtasks. Therefore, subtask 1, subtask 2 and subtask 3 can be submitted to the thread pool for concurrent execution of the above subtasks 1, subtask 2 and subtask 3. Specifically, the API interface corresponding to the subtask can be called to enable the resource service system to execute the subtask.
[0083] S402: For a subtask that depends on any subtask, if the state of the dependent subtask is completed, submit the subtask that depends on the dependent subtask to the thread pool, so as to execute the subtask and the dependent subtask serially.
[0084] In one implementation scenario, still refer to Figure 5 As shown, subtask 4 depends on subtask 1, and subtask 1 is the dependent subtask. Subtask 1 and subtask 4 can be executed serially. Therefore, when subtask 1 is completed, that is, the status of subtask 1 is completed, subtask 4 is submitted to the thread pool to execute subtask 4.
[0085] In summary, based on the topological sorting of the vertex activity network, the subtasks in the task stack that do not depend on any subtask can be determined. By concurrently executing multiple subtasks that do not depend on any subtask, the orchestration efficiency of the orchestration system is effectively improved.
[0086] Figure 6 A schematic diagram of a process of executing a subtask by an orchestration engine provided in an embodiment of the present application, referring to Figure 6 As shown, Figure 6 The AOV topological sorting based on the task stack is shown in the figure. The subtask is submitted to the thread pool. The threads in the thread pool perform parameter conversion on the subtask, that is, according to the interface template, the transmission parameters in the orchestration template are converted into the request parameter information contained in the interface template. A resource request is generated based on the request parameter information, and the API interface is executed to send the resource request to the resource service system. Among them, the thread pool writes the task task after creating the thread, obtains the thread context, and records it through the redis database.
[0087] During the execution process, the execution status of the subtask can be obtained based on the message queue monitoring mechanism. Figure 7 A flowchart of a subtask execution method provided in an embodiment of the present application. Figure 6 and Figure 7 , the subtask execution method can be as follows:
[0088] S701: Determine whether the subtask is an asynchronous task according to the interface parameter information.
[0089] In one implementation scenario, combined with Figure 6 As shown, it is possible to determine whether the API interface is an asynchronous interface based on the interface parameter information. If so, the subtask corresponding to the API interface is an asynchronous task. If not, the subtask corresponding to the API interface is a synchronous task.
[0090] S702: If the subtask is an asynchronous task, based on the message queue monitoring mechanism, obtain the subtask execution message returned by the resource service system through the message queue, the subtask execution message includes an execution end message, and the execution end message includes the execution result of the subtask.
[0091] In some embodiments, the execution end message indicates that the subtask has been completed, and the execution result of the subtask included in the execution end message may include two situations: execution completion and execution failure. If the execution is completed, step S703 may be executed, and if the execution fails, steps S704-S706 may be executed.
[0092] In some embodiments, the subtask execution message further includes an execution notification message. If the subtask is an asynchronous task, the execution notification message is returned by the receiving resource service system through the message queue, and the state of the subtask in the task stack is updated to the execution state.
[0093] In one implementation scenario, an asynchronous task is a task that takes a long time to process. To avoid affecting other functions of the orchestration system, after receiving a resource request, if the resource request meets the requirements, the resource service system can return an execution notification message, indicating that the resource service system has started to execute the subtask. Therefore, the status of the subtask can be updated to the execution status, indicating that the subtask is in the process of execution. When the execution is completed, the resource service system can return an execution end message.
[0094] In one implementation scenario, both asynchronous tasks and synchronous tasks can transmit corresponding resource requests based on message queues and hypertext transfer protocols. If the subtask is an asynchronous task and sends the resource request to the resource service system based on the hypertext transfer protocol, the resource service system also needs to return the subtask execution message to the orchestration system through the message queue, so it is also necessary to monitor the message queue based on the message queue monitoring mechanism.
[0095] In another implementation scenario, if the subtask is determined to be a synchronous task based on the interface parameter information, since the synchronous task takes a short time to execute, the resource service system can directly feed back the execution end message to the orchestration system after completing the synchronous task. It should also be noted that the synchronous task does not need to be monitored based on the message queue monitoring mechanism.
[0096] S703: If the execution result of the subtask is completion, the status of the subtask in the task stack is updated to a completion status.
[0097] In some embodiments, the execution result is execution completion, indicating that the subtask has been successfully executed, so the status of the subtask can be updated to a completion status.
[0098] In some embodiments, after executing any subtask, it is also possible to determine whether there are any unexecuted subtasks in the task stack based on the status of each subtask in the task stack; if so, the unexecuted subtasks are submitted to the thread pool according to the topological sorting of the vertex activity network to execute the unexecuted subtasks; if not, the last executed subtask is recorded as the end task of the task stack.
[0099] In some embodiments, still refer to Figure 6 As shown, the task stack is stored in the database, so the database can be queried to see if there are any unexecuted subtasks in the task stack. At the same time, the orchestration engine can set an event notification mechanism to record the end of the task stack. In addition to recording the end of the task stack, a corresponding notification message can be generated before each subtask is executed and after each subtask is executed. The notification message generated before the subtask is executed can be used as a pre-notification message, and the notification message generated after the subtask is executed can be called a post-notification message.
[0100] By recording information such as pre-notification messages, post-notification messages, and task stack end tasks, the developer's requirements for resource operations can be met. For example, it can be functional requirements such as recording operation logs.
[0101] In one implementation scenario, the task stack may be used as the total task. If the subtask that is finally executed is completed, it means that the total task is completed, and the orchestration caller may be notified at this time.
[0102] S704: If the execution result of the subtask is execution failure, an inverse task stack of an inverse topological sort corresponding to the vertex activity network topological sort is generated according to the rollback interface template.
[0103] In some embodiments, reference Figure 6As shown, the orchestration engine can also set an exception handling mechanism to handle the failed subtasks accordingly. The subtask execution failure can be determined not only by monitoring the message queue, but also by the failure of the http request execution or the failure of the return result corresponding to the http request.
[0104] In some embodiments, subtask execution failure may include two situations: subtask execution failure exception and timeout exception when the orchestration system executes the API. In one implementation scenario, if the subtask execution fails abnormally, the resource service system can feedback the execution result of the execution failure to the orchestration caller through the asynchronous MQ mechanism, and the orchestration caller is the orchestration system of this application.
[0105] In another implementation scenario, if a timeout exception occurs when the orchestration system executes the API, the API can be executed repeatedly through a retry mechanism, and if the number of repetitions exceeds a preset threshold, the execution result of the execution failure can also be fed back to the orchestration caller. The execution result can also include the reason for the execution failure.
[0106] In some embodiments, the database also includes a rollback interface template. Specifically, the rollback interface template can be stored in a persistent SQL database. When a subtask fails to execute, a rollback operation can be performed to maintain the atomicity of the task. In one implementation scenario, if the subtask of the present application is used to create a resource, the created resource may need to be rolled back to complete the destruction of the resource.
[0107] In some embodiments, if the database does not contain a rollback interface template, that is, the orchestration system has not performed a rollback configuration, then if the subtask execution fails, the subsequent subtasks may be stopped.
[0108] S705: The inverse task stack is stored in the database, and the subtasks included in the inverse task stack are submitted to the thread pool according to the inverse topological sorting, so as to send a rollback request to the corresponding resource service system, and the resource service system executes the subtasks.
[0109] In some embodiments, the subtasks contained in the inverse task stack are submitted to the thread pool according to the inverse topological sorting, so that the thread executing the subtask obtains the corresponding interface parameter information from the interface template, and then generates a resource request according to the interface parameter information, and determines the corresponding resource service system according to the platform template to send the resource request to the resource service system. The resource service system executes the subtask to achieve rollback. The specific implementation principle can refer to the above-mentioned embodiment, the process of executing the subtask in the task stack of AOV topological sorting, and this application will not repeat it here.
[0110] S706: Receive the rollback result fed back by the resource service system.
[0111] In some embodiments, after the resource service system completes executing the subtasks included in the inverse task stack, it can generate a corresponding rollback result and feed back the rollback result to the orchestration system based on the message queue so that the user can obtain the rollback information in a timely manner.
[0112] In summary, the inverse task stack of inverse topology sorting can be obtained through the configured rollback interface template, so that the resource service system can execute the subtasks contained in the inverse task stack to implement the rollback operation, and the atomicity of the task is effectively maintained according to the inverse topology sorting interface.
[0113] Figure 8 The present invention provides a schematic diagram of an application programming interface arrangement device, which can be applied to an arrangement engine of an arrangement system. The arrangement system also includes a database, which stores arrangement templates, interface templates, and platform templates. Figure 8 As shown, an embodiment of the present application provides an application programming interface arrangement device 800, which may include a receiving module 801, a processing module 802 and a sending module 803.
[0114] The receiving module 801 is used to receive an arrangement request input by a user;
[0115] Processing module 802 is used to parse the orchestration template based on the orchestration request, generate a task stack of vertex activity network topology sorting, and store the task stack in a database, where the task stack includes multiple subtasks;
[0116] The processing module 802 is further used to submit the subtasks in the task stack to the thread pool according to the topological sorting of the vertex activity network, so that the thread executing the subtask obtains the interface parameter information corresponding to the subtask from the interface template;
[0117] The processing module 802 is further used to generate a corresponding resource request according to the interface parameter information of the subtask, and determine the resource service system corresponding to the interface parameter information according to the platform template;
[0118] The sending module 803 is used to send the resource request to the resource service system so that the resource service system executes the subtask.
[0119] The device of this embodiment can be used to execute the above method embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.
[0120] Fig. 9 A schematic diagram of an electronic device provided in an embodiment of the present application. Fig. 9 As shown, an embodiment of the present application provides an electronic device 900 including a processor 901 and a memory 902 communicatively connected to the processor 901;
[0121] Memory 902 stores computer executable instructions;
[0122] The processor 901 executes the computer-executable instructions stored in the memory 902 to implement the method of the above method embodiment.
[0123] The specific implementation process of the processor 901 can be found in the above method embodiment, and its implementation principle and technical effect are similar, so this embodiment will not be repeated here.
[0124] In the above Fig. 9 In the illustrated embodiment, it should be understood that the processor 901 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the invention may be directly implemented as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.
[0125] The memory 902 may include a high-speed RAM memory, and may also include a non-volatile storage NVM, such as at least one disk storage.
[0126] The processor 901 and the memory 902 are connected via a bus 903. The bus 903 may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus. The bus 903 may be an address bus, a data bus, a control bus, etc. For ease of representation, the bus 903 in the drawings of the present application is not limited to only one bus or one type of bus.
[0127] An embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the method of the above method embodiment.
[0128] The computer-readable storage medium mentioned above can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The readable storage medium can be any available medium that can be accessed by a general or special-purpose computer.
[0129] An exemplary readable storage medium is coupled to a processor so that the processor can read information from the readable storage medium and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can be located in an application specific integrated circuit (Application Specific Integrated Circuits, referred to as: ASIC). Of course, the processor and the readable storage medium can also exist in the device as discrete components.
[0130] An embodiment of the present application provides a computer program product, including a computer program. When the computer program is executed by a processor, the method provided in any embodiment of the present application is implemented.
[0131] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present application.
[0132] It should be further noted that, although the various steps in the flowchart are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowchart may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
[0133] It should be understood that the above-mentioned device embodiments are only illustrative, and the device of the present application can also be implemented in other ways. For example, the division of units / modules in the above-mentioned embodiments is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units, modules or components can be combined, or can be integrated into another system, or some features can be ignored or not executed.
[0134] In addition, unless otherwise specified, each functional unit / module in each embodiment of the present application may be integrated into one unit / module, each unit / module may exist physically separately, or two or more units / modules may be integrated together. The above-mentioned integrated unit / module may be implemented in the form of hardware or in the form of a software program module.
[0135] If the integrated unit / module is implemented in the form of hardware, the hardware may be a digital circuit, an analog circuit, etc. The physical implementation of the hardware structure includes but is not limited to transistors, memristors, etc. If not specifically stated, the processor may be any appropriate hardware processor, such as a CPU, a GPU, an FPGA, a DSP, an ASIC, etc. If not specifically stated, the storage unit may be any appropriate magnetic storage medium or magneto-optical storage medium, such as a resistive random access memory RRAM (Resistive Random Access Memory), a dynamic random access memory DRAM (Dynamic Random Access Memory), a static random access memory SRAM (Static Random-Access Memory), an enhanced dynamic random access memory EDRAM (Enhanced Dynamic Random Access Memory), a high-bandwidth memory HBM (High-Bandwidth Memory), a hybrid memory cube HMC (Hybrid Memory Cube), etc.
[0136] If the integrated unit / module is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or all or part of the technical solution, can be embodied in the form of a software product, which is stored in a memory and includes several instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.
[0137] In the above embodiments, the description of each embodiment has its own emphasis. For parts not described in detail in a certain embodiment, please refer to the relevant description of other embodiments. The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, all possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0138] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any modification, use or adaptation of the present application, which follows the general principles of the present application and includes common knowledge or customary techniques in the art that are not disclosed in the present application. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present application are indicated by the following claims.
[0139] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A method for arranging an application programming interface, characterized in that: An orchestration engine applied to an orchestration system, wherein the orchestration system further comprises a database, wherein the database stores an orchestration template, an interface template, and a platform template; including: receiving an arrangement request input by a user; Based on the orchestration request, the orchestration template is parsed to generate a task stack with a topological sort of a vertex activity network, and the task stack is stored in the database, wherein the task stack includes a plurality of subtasks; Submitting the subtasks in the task stack to the thread pool according to the topological sorting of the vertex activity network, so that the thread executing the subtask obtains the interface parameter information corresponding to the subtask from the interface template; Generate a corresponding resource request according to the interface parameter information of the subtask, determine the resource service system corresponding to the interface parameter information according to the platform template, and send the resource request to the resource service system so that the resource service system executes the subtask.
2. The method according to claim 1, characterized in that The task stack also includes dependencies between subtasks and the status of each subtask; Submitting the subtasks in the task stack to the thread pool according to the vertex activity network topology sorting includes: Submitting subtasks that do not depend on any subtask to the thread pool according to the topological sorting of the vertex activity network to execute multiple subtasks concurrently; For a subtask that depends on any subtask, if the state of the dependent subtask is completed, the subtask that depends on the dependent subtask is submitted to the thread pool to execute the subtask and the dependent subtask serially.
3. The method according to claim 2, characterized in that The sending the resource request to the resource service system comprises: Based on a message queue or a hypertext transfer protocol, the resource request is sent to the resource service system.
4. The method according to claim 3, characterized in that: The method further comprises: Determine whether the subtask is an asynchronous task according to the interface parameter information; If the subtask is an asynchronous task, based on a message queue monitoring mechanism, obtaining a subtask execution message returned by the resource service system through the message queue, wherein the subtask execution message includes an execution end message, and the execution end message includes an execution result of the subtask; If the execution result of the subtask is completion, the state of the subtask in the task stack is updated to a completion state.
5. The method according to claim 4, characterized in that The database also includes a rollback interface template; the method also includes: If the execution result of the subtask is execution failure, generating an inverse task stack of the inverse topological sorting corresponding to the vertex activity network topological sorting according to the rollback interface template; The inverse task stack is stored in a database, and the subtasks included in the inverse task stack are submitted to a thread pool according to the inverse topological sorting, so as to send a rollback request to a corresponding resource service system, and the resource service system executes the subtasks; Receive the rollback result fed back by the resource service system.
6. The method according to claim 4, characterized in that The subtask execution message further includes an execution notification message; and the method further includes: If the subtask is an asynchronous task, an execution notification message returned by the resource service system through the message queue is received, and the state of the subtask in the task stack is updated to an execution state.
7. The method according to any one of claims 2 to 6, characterized in that: The method further comprises: Determine whether there is any unexecuted subtask in the task stack according to the status of each subtask in the task stack; If so, submitting the unexecuted subtasks to the thread pool according to the topological sorting of the vertex activity network to execute the unexecuted subtasks; If not, the subtask that is finally executed is recorded as the task stack end task.
8. An application programming interface arrangement device, characterized in that: An orchestration engine applied to an orchestration system, wherein the orchestration system further comprises a database, wherein the database stores an orchestration template, an interface template, and a platform template; including: A receiving module, used for receiving an arrangement request input by a user; A processing module, configured to parse the orchestration template based on the orchestration request, generate a task stack of vertex activity network topology sorting, and store the task stack in the database, wherein the task stack includes a plurality of subtasks; The processing module is further used to submit the subtasks in the task stack to the thread pool according to the topological sorting of the vertex activity network, so that the thread executing the subtask obtains the interface parameter information corresponding to the subtask from the interface template; The processing module is further used to generate a corresponding resource request according to the interface parameter information of the subtask, and determine the resource service system corresponding to the interface parameter information according to the platform template; The sending module is used to send the resource request to the resource service system so that the resource service system executes the subtask.
9. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 7 when executed by a processor.