Method, device, equipment and storage medium for performing asynchronous request response operation
By forming an asynchronous request definition object to send requests in parallel, and judging the response status in real time, and performing operations in response order, the delay and server stuck caused by synchronous requests in Node.js is solved, and the response efficiency and user experience are improved.
Patent Information
- Application Number
- CN202110376668.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-08
- Publication Date
- 2024-12-17
- Estimated Expiration
- 2041-04-08
AI Technical Summary
In the prior art, when Node.js sends multiple HTTP requests, the request time is too long due to the synchronous request method, which causes the front-end page to respond slowly, and the concurrent asynchronous request method has uncertain response order, confusing code execution and server stuck. risk.
By receiving the asynchronous request definition information input by the user, the execution order of the response operation and the operation information completed by all responses, an asynchronous request definition object is formed, multiple asynchronous requests are sent in parallel, the response status is judged in real time, and the response is executed in sequence according to the execution order of the response operation. Operation to avoid using timed loop tasks to detect response status.
Real-time and sequential execution of response operations is realized, program reliability is improved, delay is reduced, server jamming is avoided, service response efficiency and front-end page response speed are improved.
Smart Images

Figure CN113094618B_ABST
Abstract
Description
Technical Field
[0001] The present invention particularly relates to a method, device, equipment and storage medium for performing asynchronous request response operations. It should be noted that the method, device, equipment and storage medium for performing asynchronous request response operations provided by the present invention can be used in the field of Internet of Things technology, and can also be used in any field other than the field of Internet of Things. The present invention does not limit the application field of the method, device, equipment and storage medium for performing asynchronous request response operations. Background Art
[0002] In recent years, with the enrichment of front-end multi-client scenarios, Internet products pay more and more attention to the front-end user interface and user experience. The front-end differentiation is getting bigger and bigger. The mobile terminal also has higher requirements for the number of access connections and data volume. The general API layer on the back-end service boundary has become difficult to maintain. In order to solve the problem of frequent changes in back-end services caused by the differentiation of front-end multi-clients, the back-end for front-end services (BFF) came into being. The BFF layer (mainly used for interface aggregation and interface data clipping, etc.) is generally based on Node.js (Node.js is a JavaScript runtime environment based on the Chrome V8 engine. It can be used as a Web server to provide services and as an HTTP client to send requests). It is an intermediate layer between the front-end page and multiple back-end servers. It is mainly responsible for receiving front-end HTTP requests, sending multiple requests to the back-end server to obtain response data, and combining or clipping the data and returning it to the front-end page.
[0003] Node.js sends multiple HTTP requests to the backend server. All requests must be responded to before the data can be trimmed and combined. That is, the responses between the requests must be completed before the subsequent operations can be performed, or the responses to the requests have a logical order and must be executed in sequence. At this time, developers generally use synchronous request mode to implement it, sending the next request after the previous request is responded to, and then sending the remaining requests in sequence after the responses to the requests are received. When the number of requests is large, this will cause the request time to be too long, which in turn causes the front-end page to respond slowly, seriously affecting the user experience.
[0004] Concurrent asynchronous requests can reduce the waiting time between synchronous requests, but:
[0005] The code for sending requests is written in sequence, but the responses are not returned in sequence, which makes it impossible to determine the order of responses, resulting in code execution confusion and logical errors, and the purpose of sequential execution cannot be achieved;
[0006] The response status of all completion depends on the detection of the timed loop task completion, which results in the actual completion time not being detected in real time, indirectly causing the request time to be extended. Moreover, if the developer fails to properly close the timed loop task, there may be a risk of causing the Node.js service to freeze. Summary of the invention
[0007] The embodiment of the present invention provides a method for executing concurrent asynchronous request response operations to solve the technical problems of long delay, high code error rate and server freezing in the prior art. The method includes:
[0008] Receive asynchronous request definition information entered by the user, the execution order of the response operation, and all response completed operation information;
[0009] forming an asynchronous request definition object according to the asynchronous request definition information and the execution order of the response operation;
[0010] Send multiple asynchronous requests in parallel according to the asynchronous request definition object;
[0011] For each asynchronous request to which a response is received, when it is determined according to the execution order of the response operations in the asynchronous request definition object that all asynchronous requests sequenced before the asynchronous request have been responded to, the response operation of the asynchronous request is executed; when it is determined according to the execution order of the response operations in the asynchronous request definition object that all asynchronous requests have been responded to, operations are performed according to the operation information completed by all responses;
[0012] The asynchronous request definition information includes the incoming request URL and request parameters, the execution order of the response operation includes the asynchronous request identification information and the sequence identification, and the operation information of all responses completed includes the operation type and operation method required after all responses are completed;
[0013] Sending multiple asynchronous requests in parallel according to the asynchronous request definition object includes:
[0014] Send multiple asynchronous requests in parallel, set the asynchronous requests to the executing state, and receive responses to each asynchronous request;
[0015] Perform operations based on all responses, including:
[0016] According to the execution order of the response operation, the response data of each asynchronous request is used as a parameter, and the operation is performed according to the operation information completed by all responses.
[0017] The embodiment of the present invention also provides a device for performing concurrent asynchronous request response operations to solve the technical problems of long delay, high code error rate and server freezing in the prior art. The device includes:
[0018] An information receiving module is used to receive the asynchronous request definition information input by the user, the execution order of the response operation and the operation information of all the response completions;
[0019] A request registration module, used for forming an asynchronous request definition object according to the asynchronous request definition information and the execution order of the response operation;
[0020] A request sending module, used for sending multiple asynchronous requests in parallel according to the asynchronous request definition object;
[0021] a response status monitoring module, for each asynchronous request to which a response is received, when it is determined according to the execution order of the response operations in the asynchronous request definition object that all asynchronous requests sequenced before the asynchronous request have been responded to, sending a first trigger message to the response operation execution module; and when it is determined according to the execution order of the response operations in the asynchronous request definition object that all asynchronous requests have been responded to, sending a second trigger message to the response operation execution module;
[0022] The response operation execution module is used to execute the response operation of the asynchronous request based on the first trigger information, and to operate according to the operation information of all responses completed based on the second trigger information;
[0023] The asynchronous request definition information includes the incoming request URL and request parameters, the execution order of the response operation includes the asynchronous request identification information and the sequence identification, and the operation information of all responses completed includes the operation type and operation method required after all responses are completed;
[0024] The request sending module is specifically used for:
[0025] Send multiple asynchronous requests in parallel, set the asynchronous requests to the executing state, and receive responses to each asynchronous request;
[0026] The response operation execution module is also used to:
[0027] According to the execution order of the response operation, the response data of each asynchronous request is used as a parameter, and the operation is performed according to the operation information completed by all responses.
[0028] An embodiment of the present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, any of the above-mentioned methods for executing concurrent asynchronous request response operations is implemented to solve the technical problems of long delay, high code error rate, and server freezing existing in the prior art.
[0029] An embodiment of the present invention also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements any of the above-mentioned methods for executing concurrent asynchronous request response operations to solve the technical problems of long delay, high code error rate, and server jamming existing in the prior art.
[0030] In an embodiment of the present invention, it is proposed that after receiving asynchronous request definition information, the execution order of response operations and the operation information of all response completions input by the user, an asynchronous request definition object is formed based on the asynchronous request definition information and the execution order of response operations, and then multiple asynchronous requests are sent in parallel. When a response is received, for each asynchronous request to which a response is received, it is determined in real time according to the execution order of response operations in the asynchronous request definition object whether all asynchronous requests sorted before the asynchronous request have been responded to. If so, the response operation of the asynchronous request is directly executed; when it is determined according to the execution order of response operations in the asynchronous request definition object that all asynchronous requests have been responded to (that is, when the responses of all asynchronous requests are completed), the asynchronous request definition object is executed according to the execution order of all responses. The completed operation information is operated, and the real-time response status based on the asynchronous request is realized. The response operations of each asynchronous request are executed in sequence according to the execution order of the response operations. Compared with the prior art, the problems such as code execution confusion and logical errors can be avoided, and the purpose of sequential execution of response operations is achieved, which is beneficial to improving program reliability. At the same time, the response status of the asynchronous request is based on real-time detection of response reception, thereby realizing real-time and sequential execution of response operations. Compared with the prior art, the response status is detected by avoiding the use of timed loop tasks, which is beneficial to reducing delays, avoiding the problems of timed loop tasks being dead loops and causing server jams, and thus improving service response efficiency, improving the front-end page response speed and user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] The drawings described herein are used to provide a further understanding of the present invention, constitute a part of the present application, and do not constitute a limitation of the present invention. In the drawings:
[0032] Figure 1 is a flow chart of a method for performing an asynchronous request response operation provided by an embodiment of the present invention;
[0033] Figure 2 It is a principle architecture diagram of a method for implementing the above-mentioned asynchronous request response operation provided by an embodiment of the present invention;
[0034] Figure 3 is a structural block diagram of a computer device provided by an embodiment of the present invention;
[0035] Figure 4 It is a structural block diagram of a device for performing asynchronous request response operations provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0036] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the embodiments and the accompanying drawings. Here, the illustrative embodiments of the present invention and their descriptions are used to explain the present invention, but are not intended to limit the present invention.
[0037] In an embodiment of the present invention, a method for performing an asynchronous request response operation is provided, such as Figure 1 As shown, the method includes:
[0038] Step 102: receiving asynchronous request definition information input by the user, the execution order of the response operation and all response completed operation information;
[0039] Step 104: forming an asynchronous request definition object according to the asynchronous request definition information and the execution order of the response operation;
[0040] Step 106: Send multiple asynchronous requests in parallel according to the asynchronous request definition object;
[0041] Step 108: For each asynchronous request that receives a response, when it is determined according to the execution order of the response operations in the asynchronous request definition object that all asynchronous requests that are ordered before the asynchronous request have been responded to, the response operation of the asynchronous request is executed; when it is determined according to the execution order of the response operations in the asynchronous request definition object that all asynchronous requests have been responded to, operations are performed based on the operation information of all responses completed.
[0042] Depend on Figure 1As can be seen from the process shown, in the embodiment of the present invention, it is proposed that after receiving the asynchronous request definition information, the execution order of the response operation and the operation information of all response completions input by the user, an asynchronous request definition object is formed based on the asynchronous request definition information and the execution order of the response operation, and then multiple asynchronous requests are sent in parallel. When a response is received, for each asynchronous request to which a response is received, it is determined in real time according to the execution order of the response operation in the asynchronous request definition object whether all asynchronous requests sorted before the asynchronous request have been responded to. If so, the response operation of the asynchronous request is directly executed; when it is determined according to the execution order of the response operation in the asynchronous request definition object that all asynchronous requests have been responded to (that is, when the responses of all asynchronous requests are completed), Operations are performed according to the operation information of all response completions, realizing real-time response status based on asynchronous requests, and executing the response operations of each asynchronous request in sequence according to the execution order of the response operations. Compared with the prior art, problems such as code execution confusion and logical errors can be avoided, the purpose of sequential execution is achieved, and it is beneficial to improve program reliability; at the same time, the response status of the asynchronous request is based on real-time detection of response reception, thereby realizing real-time and sequential execution of response operations. Compared with the prior art, avoiding the use of timed loop tasks to detect the response status is beneficial to reducing delays, avoiding problems such as timed loop tasks being dead loops and causing server jams, and thus helping to improve service response efficiency, improve the front-end page response speed and user experience.
[0043] During specific implementation, the above asynchronous request definition information, the execution order of response operations and all response completed operation information can be defined and input by developers according to specific requirements.
[0044] Specifically, the asynchronous request definition information may include the incoming request URL, request parameters, and other related information for defining the asynchronous request. The execution order of the response operation may include information such as the asynchronous request identification information and the sequence identification information. The operation information of all responses completed may include information such as the operation type and operation method required after all responses are completed.
[0045] In the specific implementation, in order to realize the definition of asynchronous request, in this embodiment, after receiving the asynchronous request definition information input by the user, the execution order of the response operation and the operation information of all completed responses, the asynchronous request can be encapsulated as a Promise object through the HTTP module of Node.js, and then the asynchronous request definition object is formed according to the asynchronous request definition information and the execution order of the response operation. Specifically, the asynchronous request definition object can be stored. Among them, Promise is used to represent the object of the final completion (or failure) of an asynchronous operation and its result value. There are three states: Pending (in execution), Fulfilled (success), and Rejected (failure). It belongs to the ES6 syntax specification, which is directly available in Node.js, but cannot be used by IE or other types of low-version browsers.
[0046] In specific implementation, after generating the asynchronous request definition object, multiple asynchronous requests can be sent in parallel, and the asynchronous requests can be automatically set to the executing state, and then the responses of each asynchronous request can be received, for example, multiple asynchronous requests can be sent to the backend server in parallel. Specifically, compared with synchronous requests, after executing the code for sending the HTTP request, the subsequent code continues to execute, and will not wait for the request to get a response and execute the callback function before executing the subsequent code like synchronous requests.
[0047] In specific implementation, after receiving a response, the asynchronous request corresponding to the response can be determined based on the relevant information in the response data, and the response status of each asynchronous request can be detected and monitored in real time. The response data of the response can be stored according to the order of the asynchronous request corresponding to the response in the execution order of the response operation, and the response status of the asynchronous request corresponding to the response can be set to a completed status. At this point, the monitoring of the asynchronous request response status is completed based on the received response.
[0048] For example, Figure 2 As shown, the browser sends a request A. After receiving request A, the Node.js server sends three asynchronous requests numbered 1, 2, and 3. The execution order of the response operations is 2, 3, and 1. After the three asynchronous requests are sent to the back-end server in parallel, the received responses are stored in the execution order of the response operations, that is, the response data is stored in the order of response 2, response 3, and response 1.
[0049] In specific implementation, in order to achieve the purpose of sequential execution based on the response status in real time according to the execution order of the response operations, in this embodiment, for each asynchronous request that receives a response, when it is determined according to the execution order of the response operations in the asynchronous request definition object that all asynchronous requests sorted before the asynchronous request have been responded to (that is, it is determined that the response operation of the asynchronous request has no dependency as mentioned above), the response operation of the asynchronous request is directly executed; when it is determined according to the execution order of the response operations in the asynchronous request definition object that all asynchronous requests have been responded to, operations are performed according to the operation information of all responses completed.
[0050] In specific implementation, when it is determined, based on the execution order of the response operations in the asynchronous request definition object, that an asynchronous request that is ordered before the asynchronous request has not been responded to (that is, it is determined that the response operation of the asynchronous request has a dependency as mentioned above), the response operation of the asynchronous request will not be executed, and the response status will continue to be monitored until all the asynchronous requests before the asynchronous request have been responded to, and then the response operation of the asynchronous request will be executed, and the response operation status of the asynchronous request will be set to completed.
[0051] Specifically, for example, Figure 2 As shown, there are three asynchronous requests numbered 1, 2, and 3, and the execution order of the response operation is 2, 3, and 1. After the three asynchronous requests are sent to the back-end server in parallel, when the response to asynchronous request 3 is received, the response status of asynchronous request 3 is monitored to be completed. At this time, it is judged in real time according to the execution order of the response operation whether the asynchronous request 2 ranked before the asynchronous request 3 has been responded (if so, that is, there is no dependency as mentioned above, if not, that is, there is dependency as mentioned above). If so, it is judged that there is no dependency as mentioned above, and the response operation of asynchronous request 3 is directly executed. If not, it is judged that there is dependency as mentioned above, and the response operation of asynchronous request 3 is not executed temporarily, and the response status is continued to be monitored. During this period, when other asynchronous requests are responded to and there is no dependency as mentioned above, the response operations of other asynchronous requests are executed in real time. For example, during this period, a response to asynchronous request 1 is received, and the response operation of asynchronous request 1 is executed in real time. The response status is continued to be monitored until the asynchronous request 2 ranked before the asynchronous request 3 has been responded, and the response operation of asynchronous request 3 is executed in real time. When the last response in the execution order of the response operation is received, it is judged that all asynchronous requests have been responded. At this time, operations are performed in real time according to the operation information of all responses completed.
[0052] In specific implementation, in the process of performing operations according to the operation information of all responses completed, the response data of each asynchronous request can be used as a parameter according to the execution order of the response operation, and the operation can be performed according to the operation information of all responses completed.
[0053] In specific implementation, the above method for performing asynchronous request response operations can be implemented in the BFF layer based on Node.js, and can also be used in modern browsers that can parse Promise syntax (for example, Edge or other types of high-version browsers).
[0054] In this embodiment, the method for executing the asynchronous request response operation based on Node.js is taken as an example. Figure 2 As shown, this can be achieved by following the steps below:
[0055] Step 1): Use the HTTP module of Node.js to encapsulate the asynchronous request into a Promise object based on the asynchronous request definition information entered by the developer, the execution order of the response operation, and the operation information of all completed responses. The function of this step can be implemented by the asynchronous request registrar;
[0056] Step 2): The asynchronous request registrar forms an asynchronous request definition object based on the incoming request URL, request parameters, response execution order and other data provided by the developer;
[0057] Step 3): request the memory to store the asynchronous request definition object, analyze the execution order of the response operation of each asynchronous request, and register the execution order of the response operation of each asynchronous request in the response status listener;
[0058] Step 4): The request sender reads all asynchronous requests from the request storage, sends each asynchronous request to the backend server in parallel, and automatically sets the asynchronous request to the executing state;
[0059] Step 5): When the request receiver receives a response, the order of the asynchronous request corresponding to the response in the execution order of the response operation is determined according to the asynchronous request definition object stored in the request memory, and then the response data of the response is automatically saved to the response data recorder according to the execution order of the response operation, the asynchronous request is automatically set to the completion state, and the response state of the asynchronous request is sent to the response state listener in real time;
[0060] Step 6): The response status listener analyzes the dependencies of the response operation of the asynchronous request according to the execution order of the response operation: if there is no dependency, the response operation executor is triggered to directly execute the response operation of the asynchronous request, and the response operation status is set to completed; if there is a dependency, continue to wait for the next response status notification until the response operation of the asynchronous request is the one without dependency, then the response operation executor is triggered to directly execute the response operation of the asynchronous request;
[0061] Step 7): When the response status listener receives the last response status notification (that is, when all asynchronous requests have been responded to), the response data of each asynchronous request is passed as a parameter to all response completion operations defined by the developer in real time according to the execution order of the response operations. The developer can obtain the records of each response and execute subsequent logic, such as data trimming / aggregation, and feed back the final data after data trimming / aggregation to the Node.js server.
[0062] The above method for executing asynchronous request response operations only requires the developer to provide three parameters: asynchronous request definition information, execution order of response operations and operation information of all response completions. The asynchronous requests can be sent in parallel, and the asynchronous request definition can be parsed to monitor the response status of each asynchronous request in real time according to the execution order of the response operations. Each response operation is executed in real time in sequence according to the response status of each asynchronous request and the execution order of the response operations. After all requests are responded to, the operation logic after the request is completed is executed in real time, so as to achieve the purpose of quickly aggregating response data of the front-end request on the Node.js side, thereby improving the service response efficiency of the BFF layer, and improving the front-end page response speed and user experience.
[0063] In this embodiment, a computer device is provided, such as Figure 3 As shown, it includes a memory 302, a processor 304 and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, any of the above-mentioned methods for executing asynchronous request response operations is implemented.
[0064] Specifically, the computer device may be a computer terminal, a server or a similar computing device.
[0065] In this embodiment, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program for executing any of the above-mentioned methods for executing asynchronous request response operations.
[0066] Specifically, computer-readable storage media include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer-readable storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable storage media does not include temporary computer-readable media (transitory media), such as modulated data signals and carrier waves.
[0067] Based on the same inventive concept, an apparatus for performing asynchronous request response operations is also provided in an embodiment of the present invention, as described in the following embodiments. Since the principle of solving the problem by the apparatus for performing asynchronous request response operations is similar to that of the method for performing asynchronous request response operations, the implementation of the apparatus for performing asynchronous request response operations can refer to the implementation of the method for performing asynchronous request response operations, and the repeated parts will not be repeated. As used below, the term "unit" or "module" can be a combination of software and / or hardware that implements predetermined functions. Although the apparatus described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0068] Figure 4 is a structural block diagram of an apparatus for performing asynchronous request response operations according to an embodiment of the present invention. Figure 4 As shown, the device comprises:
[0069] The information receiving module 402 is used to receive the asynchronous request definition information input by the user, the execution order of the response operation and the operation information of all the response completions;
[0070] A request registration module 404, configured to form an asynchronous request definition object according to the asynchronous request definition information and the execution order of the response operation;
[0071] A request sending module 406, configured to send multiple asynchronous requests in parallel according to the asynchronous request definition object;
[0072] The response status monitoring module 408 is used for sending, for each asynchronous request to which a response is received, first trigger information to the response operation execution module when it is determined according to the execution order of the response operations in the asynchronous request definition object that all asynchronous requests sequenced before the asynchronous request have been responded to, and sending second trigger information to the response operation execution module when it is determined according to the execution order of the response operations in the asynchronous request definition object that all asynchronous requests have been responded to;
[0073] The response operation execution module 410 is used to execute the response operation of the asynchronous request based on the first trigger information, and to perform operations according to the operation information of all response completions based on the second trigger information.
[0074] In one embodiment, it further includes:
[0075] The response receiving module is used to store the response data of the response according to the ranking of the asynchronous request corresponding to the response in the execution order of the response operation when receiving the response, and set the response status of the asynchronous request corresponding to the response to the completion status, and send the response status of the asynchronous request corresponding to the response to the response status monitoring module.
[0076] In one embodiment, the response status monitoring module is further used for not sending the first trigger information to the response operation execution module when it is determined that the asynchronous request sequenced before the asynchronous request has not been responded to according to the execution order of the response operation in the asynchronous request definition object, until all the asynchronous requests sequenced before the asynchronous request have been responded to, and then sending the first trigger information to the response operation execution module;
[0077] The response operation execution module is further configured to set the response operation status of the asynchronous request to completed after executing the response operation of the asynchronous request based on the first trigger information.
[0078] In one embodiment, the response operation execution module is further used to use the response data of each asynchronous request as a parameter according to the execution order of the response operation, and perform operations according to the operation information of all responses completed.
[0079] The embodiment of the present invention achieves the following technical effects: after receiving asynchronous request definition information, the execution order of response operations and the operation information of all response completions input by the user, an asynchronous request definition object is formed based on the asynchronous request definition information and the execution order of the response operations, and then multiple asynchronous requests are sent in parallel. When a response is received, for each asynchronous request to which a response is received, it is determined in real time according to the execution order of the response operations in the asynchronous request definition object whether all asynchronous requests sequenced before the asynchronous request have been responded to. If so, the response operation of the asynchronous request is directly executed; when it is determined according to the execution order of the response operations in the asynchronous request definition object that all asynchronous requests have been responded to (that is, when the responses of all asynchronous requests are completed), Operations are performed according to the operation information of all response completions, realizing real-time response status based on asynchronous requests, and executing the response operations of each asynchronous request in sequence according to the execution order of the response operations. Compared with the prior art, problems such as code execution confusion and logical errors can be avoided, the purpose of sequential execution is achieved, and it is beneficial to improve program reliability; at the same time, the response status of the asynchronous request is based on real-time detection of response reception, thereby realizing real-time and sequential execution of response operations. Compared with the prior art, avoiding the use of timed loop tasks to detect the response status is beneficial to reducing delays, avoiding problems such as timed loop tasks being dead loops and causing server jams, and thus helping to improve service response efficiency, improve the front-end page response speed and user experience.
[0080] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0081] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0082] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0083] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0084] The specific embodiments described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for performing an asynchronous request response operation, characterized in that: include: Receive asynchronous request definition information entered by the user, the execution order of the response operation, and all response completed operation information; forming an asynchronous request definition object according to the asynchronous request definition information and the execution order of the response operation; Send multiple asynchronous requests in parallel according to the asynchronous request definition object; For each asynchronous request to which a response is received, when it is determined according to the execution order of the response operations in the asynchronous request definition object that all asynchronous requests sequenced before the asynchronous request have been responded to, the response operation of the asynchronous request is executed; when it is determined according to the execution order of the response operations in the asynchronous request definition object that all asynchronous requests have been responded to, operations are performed according to the operation information completed by all responses; The asynchronous request definition information includes the incoming request URL and request parameters, the execution order of the response operation includes the asynchronous request identification information and the sequence identification, and the operation information of all responses completed includes the operation type and operation method required after all responses are completed; Sending multiple asynchronous requests in parallel according to the asynchronous request definition object includes: Send multiple asynchronous requests in parallel, set the asynchronous requests to the executing state, and receive responses to each asynchronous request; Perform operations based on all responses, including: According to the execution order of the response operation, the response data of each asynchronous request is used as a parameter, and the operation is performed according to the operation information completed by all responses.
2. The method for performing an asynchronous request response operation according to claim 1, wherein: Also includes: When a response is received, the response data of the response is stored according to the order of the asynchronous request corresponding to the response in the execution order of the response operation, and the response state of the asynchronous request corresponding to the response is set to the completion state.
3. The method for performing an asynchronous request response operation according to claim 1, wherein: Also includes: When it is determined, based on the execution order of the response operations in the asynchronous request definition object, that an asynchronous request that is ordered before the asynchronous request has not been responded to, the response operation of the asynchronous request is not executed until all the asynchronous requests that are ordered before the asynchronous request have been responded to, and then the response operation of the asynchronous request is executed, and the response operation status of the asynchronous request is set to completed.
4. A device for performing asynchronous request response operations, characterized in that: include: An information receiving module is used to receive the asynchronous request definition information input by the user, the execution order of the response operation and the operation information of all response completions; A request registration module, used for forming an asynchronous request definition object according to the asynchronous request definition information and the execution order of the response operation; A request sending module, used for sending multiple asynchronous requests in parallel according to the asynchronous request definition object; a response status monitoring module, for each asynchronous request to which a response is received, when it is determined according to the execution order of the response operations in the asynchronous request definition object that all asynchronous requests sequenced before the asynchronous request have been responded to, sending a first trigger message to the response operation execution module; and when it is determined according to the execution order of the response operations in the asynchronous request definition object that all asynchronous requests have been responded to, sending a second trigger message to the response operation execution module; The response operation execution module is used to execute the response operation of the asynchronous request based on the first trigger information, and to operate according to the operation information of all responses completed based on the second trigger information; The asynchronous request definition information includes the incoming request URL and request parameters, the execution order of the response operation includes the asynchronous request identification information and the sequence identification, and the operation information of all responses completed includes the operation type and operation method required after all responses are completed; The request sending module is specifically used for: Send multiple asynchronous requests in parallel, set the asynchronous requests to the executing state, and receive responses to each asynchronous request; The response operation execution module is also used to: According to the execution order of the response operation, the response data of each asynchronous request is used as a parameter, and the operation is performed according to the operation information completed by all responses.
5. The apparatus for performing an asynchronous request response operation as claimed in claim 4, characterized in that: Also includes: The response receiving module is used to store the response data of the response according to the order of the asynchronous request corresponding to the response in the execution order of the response operation when receiving the response, and set the response status of the asynchronous request corresponding to the response to the completion status, and send the response status of the asynchronous request corresponding to the response to the response status monitoring module.
6. The apparatus for performing asynchronous request response operations according to claim 4, characterized in that: The response status monitoring module is further configured to, when it is determined according to the execution order of the response operations in the asynchronous request definition object that an asynchronous request sequenced before the asynchronous request has not been responded to, not send the first trigger information to the response operation execution module, until all asynchronous requests sequenced before the asynchronous request have been responded to, and then send the first trigger information to the response operation execution module; The response operation execution module is further configured to set the response operation status of the asynchronous request to completed after executing the response operation of the asynchronous request based on the first trigger information.
7. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method for performing an asynchronous request response operation according to any one of claims 1 to 3 is implemented.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method for performing an asynchronous request response operation according to any one of claims 1 to 3 is implemented.
