Abnormality tolerant processing method and apparatus, storage medium, and electronic device
By configuring the exception tolerance module, comparing the execution speed of API asynchronous functions with standard asynchronous functions, and terminating timeout calls, the page crash issue of the front-end anti-crawler middleware when asynchronously calling the Redis database was resolved, achieving normal page display and code simplification.
Patent Information
- Application Number
- CN202210583415.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-25
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2042-05-25
AI Technical Summary
The front-end anti-scraping middleware did not perform fault tolerance when asynchronously calling the Redis database, causing the page to crash with a 500 status, which increased development and testing costs.
By configuring the exception tolerance module, the execution speed of API asynchronous functions and standard asynchronous functions is compared, timed-out call operations are terminated, and Redis asynchronous exceptions in the front-end server layer are handled uniformly for compatibility.
This ensures that even if an asynchronous operation fails, the page will still display normally, reducing code redundancy and improving controllability.
Smart Images

Figure CN114968640B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of Redis database technology, and in particular to an anomaly tolerance processing method, apparatus, storage medium, and electronic device. Background Technology
[0002] Currently, most front-end anti-scraping architectures are implemented using middleware. This means that all user requests are intercepted by the middleware before accessing the page. The purpose of interception is to determine whether the request is legitimate. This requires recording user access data, such as the frequency of access, and the recording results need to be stored in a database.
[0003] Currently, front-end anti-scraping middleware commonly uses Redis relational database to store anti-scraping records. Specifically, Redis databases are usually introduced as third-party plugins and used on the Node.js side (currently, front-end servers generally use Node.js as the server). The front-end calls the Redis database asynchronously, but currently, there is no exception compatibility handling for the front-end's calls to various Redis read and write APIs.
[0004] Currently, the front-end uses an SSR (Server-side Rendering) architecture. Specifically, the front-end server uses Node.js as the server, integrating the entire HTML and delivering it to the browser in one go. If any step in this HTML integration process fails, the integrated HTML cannot be delivered to the browser, and the user will not see the correct page, resulting in a 500 status code error. Since front-end anti-scraping operations on Redis are asynchronous, and these operations occur within the environment of the HTML integration process, current anti-scraping technologies do not provide fault tolerance. Therefore, due to Redis server instability, the front-end webpage may crash and display a 500 status code error.
[0005] To address this issue, adding compatibility handling code to each Redis read / write API call on the front-end server wastes development resources and increases testing and regression costs. Therefore, a technical solution is needed. Summary of the Invention
[0006] To overcome the shortcomings of the existing technology, the present invention aims to provide an exception fault tolerance processing method, device, storage medium and electronic device, which unifies the handling of Redis asynchronous exceptions in the front-end middleware so that even if an asynchronous operation fails, it will not affect the normal display of the page.
[0007] To achieve the above objectives, the present invention provides an anomaly tolerance processing method, comprising the following steps:
[0008] An exception tolerance module is defined, which is used to compare the execution speed of the API asynchronous function with that of a preset standard asynchronous function, determine whether the API call operation corresponding to the API asynchronous function has timed out based on the comparison result, and terminate the timed-out API call operation.
[0009] The exception tolerance module is applied to each API of the front-end server layer.
[0010] Optionally, the step of determining the fault-tolerant function module includes:
[0011] Configure standard asynchronous functions;
[0012] Configure asynchronous API functions;
[0013] Simultaneously execute both standard asynchronous functions and API asynchronous functions, and obtain the asynchronous function that finishes executing first;
[0014] Based on the obtained asynchronous function, determine whether the API call operation corresponding to the asynchronous API function has timed out.
[0015] Optionally, the execution time of the standard asynchronous function is configured to be the timeout limit of the API call operation.
[0016] Optionally, in the step of simultaneously executing the standard asynchronous function and the API asynchronous function and obtaining the asynchronous function that finishes first, the standard asynchronous function and the API asynchronous function are passed to a pre-encapsulated Promise function, and the standard asynchronous function and the API asynchronous function are executed simultaneously through the Promise function, and the asynchronous function that finishes first is obtained.
[0017] Optionally, in the exception tolerance module applied to each API of the front-end server layer, for each native API that operates asynchronously on the database, it is passed to the API asynchronous function to obtain the API asynchronous function that wraps the native database API, and the standard exception function and the API asynchronous function that wraps the native database API are passed to the Promise function to obtain the asynchronous function that finishes execution first.
[0018] Optionally, if the first asynchronous function to finish execution is the standard asynchronous function, then the execution of the API asynchronous function is abandoned; if the first asynchronous function to finish execution is the API asynchronous function, then the execution result of the API asynchronous function is obtained.
[0019] To achieve the above objectives, the present invention also provides an anomaly-tolerant processing device, comprising:
[0020] An exception tolerance function module determination module is used to determine the exception tolerance function module. The exception tolerance function module is used to compare the execution speed of the API asynchronous function with that of the standard asynchronous function, determine whether the API call operation corresponding to the API asynchronous function has timed out based on the comparison result, and terminate the timed-out API call operation.
[0021] The fault tolerance module is used to apply the exception tolerance function module to various APIs of the front-end server layer.
[0022] To achieve the above objectives, the present invention also provides a storage medium storing a computer program thereon, wherein the computer program, when executed by a processor, implements the steps of the above-described fault tolerance processing method.
[0023] To achieve the above objectives, the present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the steps of the above-described fault tolerance processing method when executing the computer program.
[0024] Compared with existing technologies, the present invention provides an exception fault tolerance processing method, device, storage medium, and electronic device. By designing an exception fault tolerance function module, configuring and comparing the execution speed of standard asynchronous functions and API asynchronous functions to limit the timeout of API call operations, and executing the exception fault tolerance function module on all APIs on the global Redis instance in the front-end node layer, the present invention can achieve the purpose of handling Redis asynchronous exceptions. The present invention ensures compatibility with Redis asynchronous exceptions by uniformly handling middleware Redis, so that even if an asynchronous operation fails, it will not affect the normal display of the page.
[0025] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. Attached Figure Description
[0026] The above and other objects, features, and advantages of the present invention will become more apparent from the more detailed description of the embodiments of the invention in conjunction with the accompanying drawings. The drawings are provided to further illustrate the embodiments of the invention and form part of the specification. They are used together with the embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings, the same reference numerals generally represent the same parts or steps.
[0027] Figure 1 This is a flowchart illustrating an exemplary embodiment of the present invention for a fault-tolerant handling method.
[0028] Figure 2 This is a schematic diagram of the structure of an anomaly-tolerant fault-handling device provided by an exemplary embodiment of the present invention.
[0029] Figure 3 This is the structure of an electronic device provided in an exemplary embodiment of the present invention. Detailed Implementation
[0030] Hereinafter, exemplary embodiments according to the present invention will be described in detail with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of the present invention, and not all embodiments of the present invention. It should be understood that the present invention is not limited to the exemplary embodiments described herein.
[0031] It should be noted that, unless otherwise specifically stated, the relative arrangement, numerical expressions, and values of the components and steps described in these embodiments do not limit the scope of the invention.
[0032] Those skilled in the art will understand that the terms "first," "second," etc., in the embodiments of the present invention are only used to distinguish different steps, devices, or modules, and do not represent any specific technical meaning, nor do they indicate a necessary logical order between them.
[0033] It should also be understood that in the embodiments of the present invention, "multiple" can refer to two or more, and "at least one" can refer to one, two or more.
[0034] It should also be understood that any component, data or structure mentioned in the embodiments of the present invention can generally be understood as one or more unless explicitly defined or given contrary instructions in the context.
[0035] Furthermore, the term "and / or" in this invention is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this invention generally indicates that the preceding and following related objects have an "or" relationship.
[0036] It should also be understood that the description of the various embodiments in this invention emphasizes the differences between the various embodiments, and the similarities or similarities can be referred to each other. For the sake of brevity, they will not be described in detail.
[0037] At the same time, it should be understood that, for ease of description, the dimensions of the various parts shown in the accompanying drawings are not drawn according to actual scale.
[0038] The following description of at least one exemplary embodiment is merely illustrative and is in no way intended to limit the invention or its application or use.
[0039] Techniques, methods, and equipment known to those skilled in the art may not be discussed in detail, but where appropriate, they should be considered part of the specification.
[0040] It should be noted that similar labels and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be discussed further in subsequent figures.
[0041] The embodiments of this invention can be applied to electronic devices such as terminal devices, computer systems, and servers, and can operate together with a wide range of other general-purpose or special-purpose computing system environments or configurations. Well-known examples of terminal devices, computing systems, environments, and / or configurations suitable for use with electronic devices such as terminal devices, computer systems, and servers include, but are not limited to: personal computer systems, server computer systems, thin clients, thick clients, handheld or laptop devices, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputer systems, mainframe computer systems, and distributed cloud computing environments including any of the above systems, etc.
[0042] Electronic devices such as terminal devices, computer systems, and servers can be described in the general context of computer system executable instructions (such as program modules) executed by a computer system. Typically, program modules can include routines, programs, object programs, components, logic, data structures, etc., which perform specific tasks or implement specific abstract data types. Computer systems / servers can be implemented in distributed cloud computing environments, where tasks are executed by remote processing devices linked through communication networks. In distributed cloud computing environments, program modules can reside on local or remote computing system storage media, including storage devices.
[0043] With the advent of the big data era, web crawlers will play an increasingly important role in the internet. The internet contains massive amounts of data, and how to automatically and efficiently obtain information of interest from the internet and use it for our benefit is a crucial issue. Web crawler technology was created to solve these problems. Simply put, a web crawler is a tool that allows a computer to automatically interact with a server to obtain data. At its most basic level, it retrieves the source code of a webpage. Going deeper, it involves interacting with the webpage via POST requests to obtain the data returned by the server after receiving the POST request.
[0044] However, excessive web scraping can put pressure on a website. Therefore, websites typically implement anti-scraping mechanisms. These mechanisms typically detect whether a request is a legitimate browser request or a request sent by machine code. If it's the latter, the request will not be processed, preventing the crawler from accessing the website's pages.
[0045] The entire architecture of front-end anti-scraping is mostly implemented in the form of middleware. That is, all user requests are intercepted by the middleware before accessing the page. The purpose of interception is to determine whether the request is legitimate. This requires recording user access, such as the frequency of user access, and the recording results need to be stored in a database.
[0046] Redis is one of the most popular NoSQL databases. It is an open-source, in-memory, key-value store written in ANSI C that includes various data structures, supports networking, and offers optional persistence. Currently, Redis relational databases are commonly used by front-end anti-scraping middleware to store anti-scraping records. Redis databases are usually introduced as third-party plugins, and the front-end server layer calls the Redis database asynchronously. The following embodiment of the invention is used for handling exception compatibility issues when the front-end asynchronously calls the Redis read and write APIs.
[0047] Exemplary methods
[0048] Figure 1 This is a schematic flowchart illustrating an anomaly tolerance processing method provided by an exemplary embodiment of the present invention. This embodiment can be applied to electronic devices, such as... Figure 1 As shown, the present invention provides an anomaly tolerance processing method, comprising the following steps:
[0049] Step 101: Determine the exception tolerance function module. The exception tolerance function module is used to compare the execution speed of the API asynchronous function with the preset standard asynchronous function, determine whether the API call operation corresponding to the API asynchronous function has timed out based on the comparison result, and terminate the timed-out API call operation.
[0050] Specifically, step 101 includes:
[0051] Step 101-1: Configure standard asynchronous functions to limit the timeout period for API call operations.
[0052] Asynchronous functions, as opposed to synchronous functions, refer to functions that can be executed without waiting for the synchronous function to complete before other functions can be executed. In this embodiment of the invention, configuring a standard asynchronous function is mainly for comparison with an API asynchronous function. For example, when the Redis native API is passed to an API asynchronous function and both the standard asynchronous function and the API asynchronous function are executed simultaneously, if the standard asynchronous function executes faster than the API asynchronous function that wraps the Redis native API, it means that the Redis API asynchronous call has exceeded the timeout limit of the API call operation. During the front-end server integration with HTML, the call to the native API interface is abandoned, and the subsequent HTML integration process continues.
[0053] In this embodiment of the invention, a standard asynchronous function with a configurable time is configured. The timeout limit for API call operations can be configured according to the actual situation. For example, a standard asynchronous function with a default time of 10ms is defined. The function of this 10ms standard asynchronous function is to execute and return the result after 10ms.
[0054] Generally, adding the `async` keyword before a regular function definition turns it into an asynchronous function. Of course, the way asynchronous functions are defined in this invention is not limited to this. Since defining asynchronous functions is a common technique, it will not be elaborated here.
[0055] Step 101-2: Configure the API asynchronous function.
[0056] In this embodiment of the invention, configuring the API asynchronous function is mainly used to pass in the native Redis API to wrap the native Redis API. By executing the standard asynchronous function and the API asynchronous function that wraps the native Redis API simultaneously, the execution speed of the standard asynchronous function and the API asynchronous function that wraps the native Redis API is used to determine whether the API call operation corresponding to the API asynchronous function has timed out, so as to terminate the timed-out API call operation.
[0057] Step 101-3: Execute both the standard asynchronous function and the API asynchronous function simultaneously, and obtain the asynchronous function that finishes execution first.
[0058] In this embodiment of the invention, a Promise function is used to encapsulate a function for determining which function among multiple functions executes fastest. Standard asynchronous functions and API asynchronous functions are passed into the pre-encapsulated Promise function, and the Promise function executes the standard asynchronous function and the API asynchronous function simultaneously, returning the asynchronous function that finishes executing first.
[0059] Step 101-4: Based on the obtained asynchronous function, determine whether the API call operation corresponding to the API asynchronous function has timed out.
[0060] Specifically, if the first asynchronous function to finish executing is a standard asynchronous function, it means that the API call operation corresponding to the API asynchronous function has exceeded the timeout limit. Therefore, we will no longer wait for the API call operation and abandon the execution of the API asynchronous function. If the first asynchronous function to finish executing is an API asynchronous function, it means that the API call operation has not timed out. We will obtain the execution result of the API asynchronous function and continue with subsequent operations.
[0061] For example, when this fault tolerance module is applied to the API interface of a Redis instance, the native Redis API passes an asynchronous API function, which is an asynchronous function that wraps the Redis asynchronous operation. If the first asynchronous function to complete is a standard asynchronous function, it means that the Redis asynchronous operation of the native API has exceeded the timeout limit, so the wait for the Redis asynchronous operation of the API is stopped, and the front-end server continues to integrate the HTML process. If the fastest asynchronous function to complete is the API asynchronous function that wraps the Redis asynchronous operation, it means that the Redis asynchronous operation has not exceeded the timeout limit, so the call result is obtained by calling the API interface, and the HTML process continues to be integrated.
[0062] Step 102: Apply the exception tolerance function module to each API of the front-end server layer.
[0063] In this embodiment of the invention, similar to the prior art, the Redis database is introduced as a third-party plugin and used on the front-end server, i.e., the node side. All its read and write operations are performed by calling the API asynchronously.
[0064] Specifically, the exception handling module is executed on all APIs of the global Redis instance in the front-end server layer. For each native Redis API, it is passed to an API asynchronous function to obtain a wrapper for the native Redis API. Then, the standard asynchronous function and the wrapper are passed to a Promise function, which returns the first asynchronous function to complete. If the first completed asynchronous function is the standard asynchronous function, it means the Redis asynchronous operation on the current native API has exceeded the time limit, and the front-end server stops waiting for the current API's Redis asynchronous operation and continues integrating the HTML process. If the first completed asynchronous function is the wrapper for the native Redis API, it means the Redis asynchronous operation on the current native API has not exceeded the Redis asynchronous time limit, and the execution result of calling that native API is obtained, and the HTML process continues to integrate.
[0065] As can be seen, this invention designs an exception tolerance module, configures and compares the execution speed of standard asynchronous functions and API asynchronous functions to limit the timeout of API call operations, and executes this exception tolerance module on all APIs on the global Redis instance in the front-end node layer. This achieves the purpose of handling Redis asynchronous exceptions. This invention unifies the handling of Redis asynchronous exception compatibility in the middleware, so that even if an asynchronous operation fails, it will not affect the normal display of the page. This invention unifies the handling of asynchronous exceptions at the node level, reduces code redundancy, and has the advantage of high controllability.
[0066] Exemplary device
[0067] Figure 2 This is a schematic diagram of the structure of an anomaly tolerance processing device provided in an exemplary embodiment of the present invention. Figure 2 As shown in the figure, this embodiment of an anomaly fault-tolerant processing device includes:
[0068] The exception tolerance function module determination module 201 is used to determine the exception tolerance function module. The exception tolerance function module is used to compare the execution speed of the API asynchronous function with the preset standard asynchronous function, determine whether the API call operation corresponding to the API asynchronous function has timed out based on the comparison result, and terminate the timed-out API call operation.
[0069] Specifically, the fault tolerance function module determination module 201 includes:
[0070] The standard asynchronous function configuration unit is used to configure standard asynchronous functions to limit the timeout period for API call operations.
[0071] Asynchronous functions, as opposed to synchronous functions, refer to functions that can be executed without waiting for the synchronous function to complete before other functions can be executed. In this embodiment of the invention, configuring a standard asynchronous function is mainly for comparison with an API asynchronous function. For example, when the Redis native API is passed to an API asynchronous function and both the standard asynchronous function and the API asynchronous function are executed simultaneously, if the standard asynchronous function executes faster than the API asynchronous function that wraps the Redis native API, it means that the Redis API asynchronous call has exceeded the timeout limit of the API call operation. During the front-end server integration with HTML, the call to the native API interface is abandoned, and the subsequent HTML integration process continues.
[0072] In this embodiment of the invention, a standard asynchronous function with a configurable time is configured. The timeout limit for API call operations can be configured according to the actual situation. For example, a standard asynchronous function with a default time of 10ms is defined. The function of this 10ms standard asynchronous function is to execute and return the result after 10ms.
[0073] Generally, adding the `async` keyword before a regular function definition turns it into an asynchronous function. Of course, the way asynchronous functions are defined in this invention is not limited to this. Since defining asynchronous functions is a common technique, it will not be elaborated here.
[0074] The API asynchronous function configuration unit is used to configure API asynchronous functions.
[0075] In this embodiment of the invention, configuring the API asynchronous function is mainly used to pass in the native Redis API to wrap the native Redis API. By executing the standard asynchronous function and the API asynchronous function that wraps the native Redis API simultaneously, the execution speed of the standard asynchronous function and the API asynchronous function that wraps the native Redis API is used to determine whether the API call operation corresponding to the API asynchronous function has timed out, so as to terminate the timed-out API call operation.
[0076] The synchronous execution unit is used to execute both standard asynchronous functions and API asynchronous functions simultaneously, and to retrieve the asynchronous function that finishes execution first.
[0077] In this embodiment of the invention, a Promise function is used to encapsulate a function for determining which function among multiple functions executes fastest. Standard asynchronous functions and API asynchronous functions are passed into the pre-encapsulated Promise function, and the Promise function executes the standard asynchronous function and the API asynchronous function simultaneously, returning the asynchronous function that finishes executing first.
[0078] The execution result judgment unit is used to determine whether the API call operation corresponding to the asynchronous function of the API has timed out based on the obtained asynchronous function.
[0079] Specifically, if the first asynchronous function to finish executing is a standard asynchronous function, it means that the API call operation corresponding to the API asynchronous function has exceeded the timeout limit. Therefore, we will no longer wait for the API call operation and abandon the execution of the API asynchronous function. If the first asynchronous function to finish executing is an API asynchronous function, it means that the API call operation has not timed out. We will obtain the execution result of the API asynchronous function and continue with subsequent operations.
[0080] For example, when this fault tolerance module is applied to the API interface of a Redis instance, the native Redis API passes an asynchronous API function, which is an asynchronous function that wraps the Redis asynchronous operation. If the first asynchronous function to complete is a standard asynchronous function, it means that the Redis asynchronous operation of the native API has exceeded the timeout limit, so the wait for the Redis asynchronous operation of the API is stopped, and the front-end server continues to integrate the HTML process. If the fastest asynchronous function to complete is the API asynchronous function that wraps the Redis asynchronous operation, it means that the Redis asynchronous operation has not exceeded the timeout limit, so the call result is obtained by calling the API interface, and the HTML process continues to be integrated.
[0081] The fault tolerance module 202 is used to apply the exception fault tolerance function module to various APIs of the front-end server layer.
[0082] Specifically, the fault tolerance module 202 executes the exception fault tolerance function module on all APIs of the global Redis instance in the front-end server layer. That is, for each native Redis API, it passes it to the API asynchronous function to obtain the API asynchronous function that wraps the native Redis API. Then, the standard asynchronous function and the API asynchronous function that wraps the native Redis API are passed to the Promise function, and the asynchronous function that finishes executing first is returned. If the asynchronous function that finishes executing first is the standard asynchronous function, it means that the Redis asynchronous operation on the current native API has exceeded the time limit, so it will no longer wait for the Redis asynchronous operation on the current API, and the front-end server will continue to integrate the HTML process. If the asynchronous function that finishes executing first is the API asynchronous function that wraps the native Redis API, it means that the Redis asynchronous operation on the current native API has not exceeded the Redis asynchronous time limit, so it will obtain the execution result of calling the native API and continue to integrate the HTML process.
[0083] Exemplary electronic devices
[0084] Figure 3 This is the structure of an electronic device provided in an exemplary embodiment of the present invention. The electronic device may be either or both of a first device and a second device, or a standalone device independent of them, which may communicate with the first device and the second device to receive acquired input signals from them. Figure 3 A block diagram of an electronic device according to an embodiment of the present disclosure is shown. Figure 3 As shown, the electronic device includes one or more processors 31 and memory 32.
[0085] The processor 31 may be a central processing unit (CPU) or other form of processing unit with data processing and / or instruction execution capabilities, and may control other components in the electronic device to perform desired functions.
[0086] The memory 32 may include one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and / or cache memory. The non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 31 may execute the program instructions to implement the fault-tolerant processing methods of the software programs in the various embodiments of this disclosure described above, and / or other desired functions. In one example, the electronic device may further include an input device 33 and an output device 34, these components being interconnected via a bus system and / or other forms of connection mechanisms (not shown).
[0087] In addition, the input device 33 may also include, for example, a keyboard, a mouse, etc.
[0088] The output device 34 can output various information to the outside. The output device 34 may include, for example, a display, a speaker, a printer, and a communication network and its connected remote output devices, etc.
[0089] Of course, for the sake of simplicity, Figure 3 Only some of the components of the electronic device relevant to this disclosure are shown, omitting components such as buses, input / output interfaces, etc. In addition, the electronic device may include any other suitable components depending on the specific application.
[0090] Exemplary computer program products and computer-readable storage media
[0091] In addition to the methods and apparatus described above, embodiments of this disclosure may also be computer program products comprising computer program instructions that, when executed by a processor, cause the processor to perform the steps in the fault-tolerant handling methods according to various embodiments of this disclosure as described in the "Exemplary Methods" section of this specification.
[0092] The computer program product can be written in any combination of one or more programming languages to perform the operations of the embodiments of this disclosure. The programming languages include object-oriented programming languages such as Java and C++, as well as conventional procedural programming languages such as C or similar languages. The program code can be executed entirely on a user's computing device, partially on a user's computing device, as a standalone software package, partially on a user's computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0093] Furthermore, embodiments of this disclosure may also be computer-readable storage media storing computer program instructions that, when executed by a processor, cause the processor to perform the steps in the fault-tolerant processing methods according to various embodiments of this disclosure described in the "Exemplary Methods" section of this specification.
[0094] The computer-readable storage medium may be any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may, for example, include, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatuses, or devices, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0095] The basic principles of this disclosure have been described above with reference to specific embodiments. However, it should be noted that the advantages, benefits, and effects mentioned in this disclosure are merely examples and not limitations, and should not be considered as essential features of each embodiment of this disclosure. Furthermore, the specific details disclosed above are for illustrative and facilitative purposes only, and are not limitations. These details do not limit the scope of this disclosure to the necessity of employing the aforementioned specific details for implementation.
[0096] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For system embodiments, since they largely correspond to method embodiments, the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.
[0097] The block diagrams of devices, apparatuses, devices, and systems disclosed herein are merely illustrative examples and are not intended to require or imply that they must be connected, arranged, or configured in the manner shown in the block diagrams. As those skilled in the art will recognize, these devices, apparatuses, devices, and systems can be connected, arranged, and configured in any manner. Words such as “comprising,” “including,” “having,” etc., are open-ended terms meaning “including but not limited to,” and are used interchangeably with them. The terms “or” and “and” as used herein refer to the terms “and / or,” and are used interchangeably with them unless the context clearly indicates otherwise. The term “such as” as used herein refers to the phrase “such as but not limited to,” and is used interchangeably with it.
[0098] The methods and apparatus of this disclosure may be implemented in many ways. For example, they may be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware. The above-described order of steps for the methods is for illustrative purposes only, and the steps of the methods of this disclosure are not limited to the order specifically described above unless otherwise specifically stated. Furthermore, in some embodiments, this disclosure may also be implemented as a program recorded on a recording medium, the program including machine-readable instructions for implementing the methods according to this disclosure. Thus, this disclosure also covers recording media storing programs for performing the methods according to this disclosure.
[0099] It should also be noted that in the apparatus, devices, and methods of this disclosure, the components or steps are decomposable and / or recombinable. Such decomposition and / or recombination should be considered equivalent to the present disclosure. The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use this disclosure. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein can be applied to other aspects without departing from the scope of this disclosure. Therefore, this disclosure is not intended to be limited to the aspects shown herein, but rather to be carried out within the widest scope consistent with the principles and novel features disclosed herein.
[0100] The above description has been given for purposes of illustration and description. Furthermore, this description is not intended to limit the embodiments of this disclosure to the forms disclosed herein. Although numerous exemplary aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, alterations, additions, and sub-combinations therein.
Claims
1. An abnormality fault-tolerant processing method, comprising the steps of: determining an abnormality fault-tolerant function module, comprising: configuring a standard asynchronous function; configuring an API asynchronous function; simultaneously executing the standard asynchronous function and the API asynchronous function, wherein the abnormality fault-tolerant function module is configured to compare execution speeds of the API asynchronous function and the standard asynchronous function, determine whether a calling API operation corresponding to the API asynchronous function is timed out according to a comparison result, and terminate the calling API operation that is timed out; applying the abnormality fault-tolerant function module to each API of a front-end server layer.
2. The fault-tolerant processing method as described in claim 1, characterized in that, The standard asynchronous function is configured to be executed within a timeout limit time of an API calling operation.
3. The method of claim 1, wherein: In the step of simultaneously executing the standard asynchronous function and the API asynchronous function to obtain an asynchronous function that is executed first, the standard asynchronous function and the API asynchronous function are input into a pre-encapsulated Promise function, the standard asynchronous function and the API asynchronous function are simultaneously executed by the Promise function, and the asynchronous function that is executed first is obtained.
4. The method of claim 3, wherein: In the step of applying the abnormality fault-tolerant function module to each API of the front-end server layer, for each native API of an asynchronous operation database, the native API is input into the API asynchronous function to obtain an API asynchronous function that wraps the native API of the database, and the standard asynchronous function and the API asynchronous function that wraps the native API of the database are input into the Promise function to obtain the asynchronous function that is executed first.
5. The method of claim 4, wherein: When the asynchronous function that is obtained and executed first is the standard asynchronous function, execution of the API asynchronous function is abandoned; and when the asynchronous function that is obtained and executed first is the API asynchronous function, an execution result of the API asynchronous function is obtained.
6. An abnormality fault-tolerant processing apparatus, comprising: an abnormality fault-tolerant function module determination module configured to determine an abnormality fault-tolerant function module, comprising: configuring a standard asynchronous function; configuring an API asynchronous function; simultaneously executing the standard asynchronous function and the API asynchronous function, wherein the abnormality fault-tolerant function module is configured to compare execution speeds of the API asynchronous function and the standard asynchronous function, determine whether a calling API operation corresponding to the API asynchronous function is timed out according to a comparison result, and terminate the calling API operation that is timed out; a fault-tolerant processing module configured to apply the abnormality fault-tolerant function module to each API of a front-end server layer.
7. A storage medium having stored thereon a computer program, characterized in that The computer program is executed by the processor to implement the steps of the abnormality fault-tolerant processing method according to any one of claims 1 to 5.
8. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor executes the computer program to implement the steps of the abnormality fault-tolerant processing method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Application level asynchronous task scheduling system and method
CN101882161A
API interface generation method and device, computer equipment and storage medium
CN112685021A