Interface fusing method, interface fusing device and computer readable storage medium

Through the interface fuse method, combining meta information and fuse configuration parameters, counting and determining the number of interface calls and errors, the fuse processing of the abnormal interface is realized, solving the problem of high failure rate of interface calls and improving the success rate of business processing.

CN118916074AActive Publication Date: 2024-11-08HANGZHOU PINGPONG INTELLIGENT TECH CO LTD

Patent Information

Application Number
CN202411401204.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-09
Publication Date
2024-11-08
Estimated Expiration
2044-10-09

AI Technical Summary

Technical Problem

In the prior art, the upstream business system fails to effectively handle the response exception when the interface is called by the downstream business system or the third-party business system, resulting in a high failure rate of interface calls.

Method used

Using the interface fuse method, by obtaining the interface meta information and fuse configuration parameters, we can determine whether the call conditions are met, and count the number of calls and errors when the call fails. We can decide whether to perform fuse processing based on the statistical results in the preset sliding time window. , avoid frequent calls to exception interfaces.

Benefits of technology

It effectively reduces the failure rate of interface calls, prevents frequent calls from business interfaces that fail to respond, and improves the success rate of business processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118916074A_ABST
    Figure CN118916074A_ABST
Patent Text Reader

Abstract

The invention relates to an interface fusing method, an interface fusing device and a computer readable storage medium, and the interface fusing method comprises the steps: determining whether a target method meets a calling condition or not according to a fusing configuration parameter and a current state of a circuit breaker; judging whether the target method is successfully called; if yes, executing a pre-configured fusing rule according to the meta-information of the target method; if the execution result of the fusing rule is true, counting the calling times and the calling error times; if the calling of the target method fails, according to the calling times and the calling error times in a preset sliding time window, in combination with the fusing configuration parameters, judging whether fusing processing is executed on the target method or not; and if yes, fusing the target method. According to the method, fusing judgment of the target method can be achieved through the AOP aspect, fusing processing is conducted on the target method meeting the fusing triggering condition in time, and therefore the situation that a high failure rate occurs due to the fact that service interfaces which fail in response are frequently called is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to an interface fusing method, an interface fusing device and a computer-readable storage medium. Background Art

[0002] In the data interaction scenario between the upstream business system and the downstream business system, or in the data interaction scenario between the upstream business system and the third-party business system, the upstream business system often needs to call the business interface of the downstream business system or the third-party business system to implement business processing. Among them, when the downstream business system or the third-party business interface responds abnormally, for example, when there is a business failure response such as missing required fields or insufficient balance, the current upstream business system often does not set up corresponding business logic processing for the call failure of the corresponding business interface, which causes the upstream business system to continuously call abnormal business interfaces, resulting in a high failure rate in the business processing of the upstream business system.

[0003] Therefore, there is still a problem of a high failure rate for interface calls in the current related technologies. Summary of the invention

[0004] In this embodiment, an interface fusing method, an interface fusing device and a computer-readable storage medium are provided to solve the problem of a high failure rate of interface calls in related technologies.

[0005] In a first aspect, an interface fusing method is provided in this embodiment, including: Based on the target pre-notification, obtain the meta information and fuse configuration parameters of the target method of the interface, and confirm whether the target method meets the calling conditions according to the fuse configuration parameters and the current state of the circuit breaker; if so, call the target method; wherein the target pre-notification is the pre-notification of the AOP aspect pre-configured for the target method; Based on the target post-notification, determine whether the target method is successfully called; if so, execute the pre-configured fuse rule according to the meta-information of the target method; if the execution result of the fuse rule is true, count the number of calls and the number of call errors; wherein the target post-notification is the post-notification of the AOP aspect pre-configured for the target method; If the target method fails to be called, the number of calls and the number of call errors are counted according to the fuse configuration parameters; According to the number of calls and the number of call errors within the preset sliding time window, combined with the fuse configuration parameters, it is determined whether to perform fuse processing on the target method; if so, the target method is subjected to fuse processing.

[0006] In some embodiments, confirming whether the target method meets the calling condition according to the fuse configuration parameter and the current state of the circuit breaker includes: When the fuse configuration parameter is not empty and the current state of the circuit breaker is closed, confirm that the target method meets the calling condition.

[0007] In some embodiments, confirming whether the target method meets the calling condition according to the fuse configuration parameter and the current state of the circuit breaker includes: When the fuse configuration parameter is not empty and the current state of the circuit breaker is open, determine whether the current timestamp is greater than or equal to the next retry timestamp; if so, set the current state of the circuit breaker to half-open, and confirm that the target method meets the calling conditions; wherein the next retry timestamp is determined according to the fuse duration specified by the fuse configuration parameter and the timestamp corresponding to the last fuse processing of the target method; Otherwise, it is confirmed that the target method does not meet the calling conditions and the preset fuse degradation strategy is executed.

[0008] In some embodiments, confirming whether the target method meets the calling condition according to the fuse configuration parameter and the current state of the circuit breaker includes: When the circuit breaker configuration parameter is not empty and the current state of the circuit breaker is half-open, it is confirmed that the target method does not meet the calling conditions and the preset circuit breaker downgrade strategy is executed.

[0009] In some embodiments, the method further comprises: When the fuse configuration parameter is empty, confirm that the target method meets the calling condition.

[0010] In some of the embodiments, when the target method fails to be called, the number of calls and the number of call errors are counted according to the fuse configuration parameters, including: When the target method fails to be called, obtaining the call exception type that caused the target method to fail to be called; Determine whether the call exception type is consistent with the preset exception type specified in the fuse configuration parameter; if so, count the number of method calls and the number of method call errors within the current sliding time window.

[0011] In some of the embodiments, judging whether to perform a fuse process on the target method according to the number of calls and the number of call errors within a preset sliding time window in combination with the fuse configuration parameters includes: When the fuse judgment condition specified by the fuse configuration parameter is the number of exceptions, the number of calls is greater than or equal to the minimum number of requests specified by the fuse configuration parameter, and the number of call errors is greater than or equal to the number threshold specified by the fuse configuration parameter, confirm that the target method is subjected to fuse processing, set the current state of the circuit breaker to open, and set the next retry timestamp according to the specified fuse duration; When the fuse judgment condition is the abnormal ratio, the number of calls is greater than or equal to the minimum number of requests, and the call error ratio is greater than or equal to the ratio threshold specified by the fuse configuration parameter, confirm that the fuse processing is performed on the target method, set the current state of the circuit breaker to open, and set the next retry timestamp according to the fuse duration; the call error ratio is the ratio of the number of call errors to the number of calls.

[0012] In some of the embodiments, the duration of the sliding time window is set according to the fuse statistical duration specified by the fuse configuration parameters; the sliding time window includes a plurality of sub-time window intervals.

[0013] In a second aspect, an interface fusing device is provided in this embodiment, including: an acquisition module, a judgment module, a counting module and a fusing processing module; wherein: The acquisition module is used to obtain the meta information and fuse configuration parameters of the target method of the interface based on the target pre-notification, and confirm whether the target method meets the calling conditions according to the fuse configuration parameters and the current state of the circuit breaker; if so, call the target method; wherein the target pre-notification is the pre-notification of the AOP aspect pre-configured for the target method; The judgment module is used to judge whether the target method is successfully called based on the target post-notification; if so, execute the pre-configured fuse rule according to the meta-information of the target method; if the execution result of the fuse rule is true, count the number of calls and the number of call errors; wherein the target post-notification is the post-notification of the AOP aspect pre-configured for the target method; The counting module is used to count the number of calls and the number of call errors according to the fuse configuration parameters if the target method fails to be called; The fuse processing module is used to determine whether to perform fuse processing on the target method based on the number of calls and the number of call errors within a preset sliding time window, combined with the fuse configuration parameters; if so, perform fuse processing on the target method.

[0014] In a third aspect, a storage medium is provided in this embodiment, on which a computer program is stored, and when the program is executed by a processor, the interface fusing method described in the first aspect is implemented.

[0015] Compared with the related art, the present embodiment provides an interface fusing method, an interface fusing device and a computer-readable storage medium. The interface fusing method obtains the meta information and fusing configuration parameters of the target method of the interface based on the target pre-notification, and confirms whether the target method meets the calling conditions according to the fusing configuration parameters and the current state of the circuit breaker; if so, the target method is called; wherein the target pre-notification is the pre-notification of the AOP aspect pre-configured for the target method; based on the target post-notification, it is judged whether the target method is successfully called; if so, the pre-configured fusing rules are executed according to the meta-information of the target method; if the fusing rule execution result is true, the number of calls and the number of call errors are counted; wherein the target post-notification is the post-notification of the AOP aspect pre-configured for the target method; if the target method fails to call, the number of calls and the number of call errors are counted according to the fusing configuration parameters; according to the number of calls and the number of call errors in the preset sliding time window, combined with the fusing configuration parameters, it is judged whether to perform fusing processing on the target method; if so, the target method is fusing processed. It can implement fuse judgment on the target method through AOP aspects, and perform fuse processing in time for the target method that meets the fuse trigger conditions, thereby avoiding frequent calls to business interfaces with failed responses and resulting in a high failure rate.

[0016] Details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings: Figure 1 is a hardware structure block diagram of a terminal of the interface fusing method of this embodiment; Figure 2 is a flow chart of the interface fusing method of this embodiment; Figure 3 is a flowchart of a method for configuring fuse configuration parameters in some of the embodiments; Figure 4 is a flow chart of an interface fusing method in some embodiments; Figure 5 It is a structural block diagram of the interface fuse device of this embodiment. DETAILED DESCRIPTION

[0018] In order to more clearly understand the purpose, technical solutions and advantages of the present application, the present application is described and illustrated below in conjunction with the accompanying drawings and embodiments.

[0019] Unless otherwise defined, the technical terms or scientific terms involved in this application shall have the general meaning understood by people with general skills in the technical field to which this application belongs. The words "one", "a", "the", "these" and the like in this application do not indicate a quantitative limitation, and they may be singular or plural. The terms "include", "comprise", "have" and any variants thereof involved in this application are intended to cover non-exclusive inclusions; for example, a process, method and system, product or device comprising a series of steps or modules (units) is not limited to the listed steps or modules (units), but may include unlisted steps or modules (units), or may include other steps or modules (units) inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there may be three relationships, for example, "A and / or B" may mean: A exists alone, A and B exist at the same time, and B exists alone. Generally, the character " / " indicates that the objects associated with each other are in an "or" relationship. The terms "first", "second", "third", etc. in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.

[0020] The method embodiment provided in this embodiment can be executed in a terminal, a computer or a similar computing device. For example, running on a terminal, Figure 1 FIG. 1 is a hardware structure diagram of a terminal of the interface fusing method of this embodiment. Figure 1 As shown, the terminal may include one or more ( Figure 1 Only one is shown in the figure) a processor 102 and a memory 104 for storing data, wherein the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA. The above terminal may also include a transmission device 106 and an input and output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown.

[0021] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the interface fuse method in this embodiment. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0022] The transmission device 106 is used to receive or send data via a network. The above network includes a wireless network provided by a communication provider of the terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (Radio Frequency, referred to as RF) module, which is used to communicate with the Internet wirelessly.

[0023] In this embodiment, an interface fusing method is provided. Figure 2 is a flow chart of the interface fusing method of this embodiment, such as Figure 2 As shown, the process includes the following steps: Step S210, based on the target pre-notification, obtain the metadata and fuse configuration parameters of the target method of the interface, and confirm whether the target method meets the calling conditions according to the fuse configuration parameters and the current state of the circuit breaker; if so, call the target method; wherein the target pre-notification is the pre-notification of the AOP aspect pre-configured for the target method.

[0024] Among them, the target method is a method that needs to enable the fuse function. The target method of the interface can be marked as a method that needs to enable the fuse function by adding a preset annotation to the target method. At the same time, the AOP aspect that pre-adds the fuse to the target method can also be set with pre-notification and post-notification to provide an execution entry point for the subsequent fuse rule judgment and the logic switch judgment of the circuit breaker used for the fuse. The above annotation is a special mark applied to elements such as classes, methods, parameters, variables, constructors and packages in computer programming languages. These marks can be read during compilation, loading and runtime, and corresponding processing can be performed. The annotation information can be read at runtime or compile time through the annotation processor or reflection mechanism to perform specific processing. The above AOP aspect is a technology of JAVA aspect-oriented programming, which is fully called aspect-oriented programming (Aspect Oriented Programming). It can execute extended code before and after the execution of the target method, thereby improving the extensibility of the code while reducing the coupling of the code. The above circuit breaker is a state machine of the fuse logic switch, including three modes: open, closed and half-open.

[0025] It can be understood that the above target pre-notification is the pre-processing logic of the AOP aspect set in advance for the target method, and the target pre-notification will be triggered before the target method is called. The meta information of the target method may include the application Internet Protocol (IP) address of the system application that executes the interface fuse method, the name of the class to which the method belongs, the method name, the name of the input and output parameters of the method, and the name of the return value of the method. The above fuse configuration parameters are the fuse rule data configured in advance for the target method on the associated background management system, which may include fuse strategies, such as whether to judge whether to fuse based on the number of exceptions or to judge whether to fuse based on the abnormal proportion, and may also include proportion threshold, number of abnormal thresholds, fuse duration (unit can be milliseconds), minimum number of requests, statistical duration (unit can be milliseconds), fuse rules (specifically MVEL expressions), fuse degradation strategies, specified exception class names, whether captured exceptions are included in the judgment strategy of fuse, and other configuration parameters. Set the fuse configuration parameters to the target method that needs to be fused. For methods that have not been configured for fuse, the corresponding fuse configuration parameters are empty. The current state of the above circuit breaker is one of open, half-open and closed. Among them, MVEL expression is a lightweight expression language used for reflection optimization and script execution. MVEL expression is based on Java syntax and is suitable for scenarios that require dynamic calculation and logic processing.

[0026] When the system application is started (for example, it can be an application of the upstream business system that needs to make an interface call), the annotation scanner will scan all the meta information of the methods marked with preset annotations for the need to enable the fuse function, and send the meta information of all the methods marked with annotations and the corresponding fuse configuration parameters to the data storage center (for example, Nacos) through a network request for storage. When the background management application is started, the background management application will read the target methods of all interfaces from the data storage center, and display the meta information and the previously configured fuse configuration parameters in a visual form on the corresponding display interface.

[0027] The above-mentioned fuse configuration parameters can be configured based on the display interface. Specifically, the configuration entry of the above-mentioned fuse configuration parameters can be provided on the display interface associated with the background management application. The user adds or modifies the value of the corresponding fuse configuration parameter and saves it to the data storage center. After saving, the data storage center will send a network request to all application machines in the system and push the latest fuse configuration parameters to the machine node of each application machine. After the machine node receives the latest fuse configuration parameters, it will classify and organize the fuse configuration parameters and metadata and save them to the machine memory for subsequent use in fuse judgment during the interface call process. In addition, the counters corresponding to the number of calls and the number of call errors used for fuse statistics can also be initialized to 0.

[0028] Before the target method is called, the pre-processing logic of the AOP aspect will be executed based on the set target pre-notification. In the pre-processing logic, the corresponding fuse configuration parameters will be obtained from the data storage center based on the meta information of the target method. After that, in the pre-processing logic, it is confirmed whether the target method meets the calling conditions based on the fuse configuration parameters and the current state of the circuit breaker. After determining that the calling conditions are met, the specific logic of calling the target method will be executed, that is, the processing logic in the target method will be executed.

[0029] The calling condition is a preset setting, which is used to determine whether the target method has been previously executed with the circuit breaker downgrade strategy. A method that has already executed the circuit breaker downgrade strategy will not meet the calling condition; while a method that has not executed the circuit breaker downgrade strategy will meet the calling condition.

[0030] Step S220, based on the target post-notification, determine whether the target method is called successfully; if so, execute the pre-configured MVEL expression according to the meta-information of the target method; if the execution result of the MVEL expression is true, count the number of calls and the number of call errors; wherein, the target post-notification is the post-notification of the AOP aspect pre-configured for the target method.

[0031] After the target method is called, the post-notification of the AOP aspect will be triggered, that is, the post-processing logic. In the post-processing logic, it will be determined whether the target method is called successfully. That is, whether the target method is executed successfully. The fuse configuration parameters are obtained according to the meta-information of the target method, and then the fuse processing is determined according to the calling situation. Among them, when the target method is called successfully, the pre-configured fuse rules are executed again. The fuse rule is an MVEL expression. Specifically, the input and output parameter information of the target method is substituted into the pre-configured MVEL expression, and according to the execution result of the MVEL expression, it is determined again whether the fuse needs to be blown. The input and output parameter information is the input parameters and output information of the target method. Using MVEL expressions, a section of Java-like code is executed according to the rules, in which the input parameter group (that is, the array of input parameters) of the target method and the output parameters of the target method are judged. For example, if the MVEL expression is "param[0]==123456&&result == 'Failed'", the corresponding meaning is that if the first parameter of the input parameter group of the parsed target method is equal to "123456" and the output parameter of the target method is the "Failed" string, the execution result of the MVEL expression is true. This indicates that the execution result of the target method meets the business scenario that requires circuit breaking. For example, if a field of the interface response contains insufficient funds, the number of calls and the number of call errors will be counted.

[0032] In addition, if the execution result of the MVEL expression is false, the current state of the circuit breaker is determined. If the current state is open, no operation is performed; if the current state of the circuit breaker is half-open, the half-open state of the circuit breaker needs to be changed to closed; if the current state of the circuit breaker is closed, no operation is performed.

[0033] Step S230: If the target method fails to be called, the number of calls and the number of call errors are counted according to the fuse configuration parameters.

[0034] When the target method fails to be called, it is necessary to determine whether the call error needs to be counted according to the fuse configuration parameters. For example, if the exception thrown by the target method call failure is the same as the exception class name specified by the fuse configuration parameters, then the method call meets the exception condition that requires fuse, and the call error count and call count are counted, and the count is increased by 1.

[0035] Step S240, based on the number of calls and the number of call errors within the preset sliding time window, combined with the fuse configuration parameters, determine whether to perform fuse processing on the target method; if so, perform fuse processing on the target method.

[0036] Specifically, the total number of calls and call errors within the sliding time window are counted to determine whether the target method needs to be fused. After determining that the target method needs to be fused, the fused degradation strategy will be executed on the target method, such as throwing a preset exception. In addition, the current state of the circuit breaker is set to open, and the timestamp of the next fused recovery is set according to the timestamp of the current system and the fused duration, so as to control that the target method will not be called within the above fused duration.

[0037] In particular, the sliding time window can be, within a fixed time interval, a time interval is divided into smaller sub-intervals. Each time the statistics are counted, N sub-intervals are slid forward according to the current time, and the count values ​​of all sub-intervals are accumulated. Therefore, flexible and accurate statistical counting can be achieved over time.

[0038] In the above steps S210 to S240, based on the target pre-notification, the meta-information and fuse configuration parameters of the target method of the interface are obtained, and according to the fuse configuration parameters and the current state of the circuit breaker, whether the target method meets the calling conditions is confirmed; if so, the target method is called; wherein, the target pre-notification is the pre-notification of the AOP aspect pre-configured for the target method; based on the target post-notification, it is determined whether the target method is called successfully; if so, the pre-configured fuse rules are executed according to the meta-information of the target method; if the execution result of the fuse rule is true, the number of calls and the number of call errors are counted; wherein, the target post-notification is the post-notification of the AOP aspect pre-configured for the target method; if the target method fails to call, the number of calls and the number of call errors are counted according to the fuse configuration parameters; according to the number of calls and the number of call errors within the preset sliding time window, combined with the fuse configuration parameters, it is determined whether to perform fuse processing on the target method; if so, the target method is subjected to fuse processing. It can implement fuse judgment on the target method through AOP aspects, and perform fuse processing in time for the target method that meets the fuse trigger conditions, thereby avoiding frequent calls to business interfaces with failed responses and resulting in a high failure rate.

[0039] In one embodiment, based on the above step S210, according to the fuse configuration parameters and the current state of the circuit breaker, confirming whether the target method meets the calling condition may specifically include: When the circuit breaker configuration parameters are not empty and the circuit breaker is currently closed, confirm that the target method meets the calling conditions.

[0040] Among them, in the pre-processing logic of the AOP aspect configured for the target method, it will be determined whether the fuse configuration parameter is empty. If it is not empty, it is necessary to obtain the current state of the circuit breaker corresponding to the target method. If the current state of the circuit breaker is closed, it means that the target method has not been subjected to fuse processing before, so the target method can be called directly.

[0041] In this embodiment, by combining the fuse configuration parameters with the circuit breaker status to confirm whether to call the target method, calling the method that fails to respond can be avoided, thereby avoiding a high business execution failure rate caused by frequent calls to the method that fails to respond.

[0042] Additionally, in one embodiment, based on the above step S210, according to the fuse configuration parameters and the current state of the circuit breaker, confirming whether the target method meets the calling condition may specifically include: When the circuit breaker configuration parameter is not empty and the current state of the circuit breaker is open, determine whether the current timestamp information is greater than or equal to the next retry timestamp; if so, set the current state of the circuit breaker to half-open, and confirm that the target method meets the calling conditions; the next retry timestamp is determined according to the circuit breaker duration specified by the circuit breaker configuration parameter and the timestamp corresponding to the last circuit breaker processing of the target method; otherwise, confirm that the target method does not meet the calling conditions, and execute the preset circuit breaker degradation strategy.

[0043] When the current state of the circuit breaker is open, it means that the target method has been previously subjected to a circuit breaker process. Therefore, it is necessary to determine whether the circuit breaker process set for the target method has exceeded the preset circuit breaker duration. If so, it is necessary to determine whether the call restriction on the target method can be lifted this time.

[0044] Specifically, determine whether the current timestamp is greater than or equal to the next retry timestamp. If so, it indicates that the fuse processing of the target method has exceeded the fuse duration, and the call request to the target method can be released to complete the call to the target method. In other words, this call request can be used as a sniffing request for fuse recovery, so as to determine whether the normal call of the target method can be restored in the post-processing logic of the AOP aspect. In addition, the current state of the circuit breaker can also be set to half-open. The above-mentioned next retry timestamp can be determined by the sum of the timestamp corresponding to the most recent fuse processing of the target method and the preset fuse duration.

[0045] If the current timestamp is still less than the next retry timestamp, it means that the duration of the circuit breaker set for the target method has not exceeded the circuit breaker duration, so the circuit breaker needs to continue to be executed to prevent the call to the target method this time. You can execute the preset circuit breaker degradation strategy, such as throwing a specific exception.

[0046] In this embodiment, by determining whether to release or continue to restrict calls to the target method based on timestamp information when the circuit breaker is turned on, accurate and flexible circuit breaker processing can be achieved, thereby avoiding excessive call restrictions on methods that can be called normally, and erroneous calls to methods that cannot respond normally.

[0047] Additionally, in one embodiment, based on the above step S210, confirming whether the target method meets the calling condition according to the fuse configuration parameters and the current state of the circuit breaker may include: If the circuit breaker configuration parameter is not empty and the current state of the circuit breaker is half-open, confirm that the target method does not meet the call conditions and execute the preset circuit breaker downgrade strategy. That is, if the current state of the circuit breaker is half-open, the circuit breaker downgrade process still needs to be executed to prevent the call to the target method this time.

[0048] In addition, the interface fusing method may further include: when the fusing configuration parameter is empty, confirming that the target method meets the calling condition. If the fusing configuration parameter is empty, it indicates that the target method has not been fusing configured and can be called directly.

[0049] In addition, in one embodiment, when the target method fails to be called, the number of calls and the number of call errors are counted according to the fuse configuration parameters, which may include: When the target method call fails, obtain the call exception type that caused the target method call failure; determine whether the call exception type is consistent with the preset exception type specified in the fuse configuration parameters; if so, count the number of method calls and method call errors within the current sliding time window.

[0050] That is, after the target method call is completed, the post-processing logic of the AOP aspect will be entered. In the post-processing logic, the fuse configuration parameters are obtained according to the meta information of the target method. If the target method call is abnormal, for example, network timeout or system exception, the corresponding interface will throw a corresponding business exception. After the AOP aspect captures the business exception, it will first obtain the statistical counters under the current sliding time window according to the meta information of the target method, including the total method call counter and the method call error counter, and determine whether the currently thrown business exception is included in the exception type specified by the fuse configuration parameter according to the exception type configured in the background (the type can be reflected in the form of a specific exception class name). If the exception thrown at this time is the same as the specified exception type, then the target method meets the exception corresponding to the fuse at this time, then the total method call counter is increased by 1, and the method call error counter is increased by 1. Exemplarily, some exception classes of the Java language can be selected as the specified exception type for fuse processing, or all exception classes of the Java language can be selected as the specified exception type for fuse processing.

[0051] In this embodiment, whether it is necessary to count the calling errors of the target method is determined based on the exception type, so that accurate exception screening can be achieved.

[0052] In addition, in one embodiment, based on the above step S240, according to the number of calls and the number of call errors in the preset sliding time window, combined with the fuse configuration parameters, it is determined whether to perform fuse processing on the target method, which may specifically include: When the fuse judgment condition specified by the fuse configuration parameter is the number of exceptions, the number of calls is greater than or equal to the minimum number of requests specified by the fuse configuration parameter, and the number of call errors is greater than or equal to the number threshold specified by the fuse configuration parameter, confirm that the target method is broken, set the current state of the circuit breaker to open, and set the next retry timestamp according to the specified fuse duration; when the fuse judgment condition is the exception ratio, the number of calls is greater than or equal to the minimum number of requests, and the call error ratio is greater than or equal to the ratio threshold specified by the fuse configuration parameter, confirm that the target method is broken, set the current state of the circuit breaker to open, and set the next retry timestamp according to the fuse duration; the call error ratio is the ratio of the number of call errors to the number of calls.

[0053] The current state of the circuit breaker can be first determined. If it is open, no operation is performed; if it is half-open, it is necessary to change half-open to open; if it is closed, it is necessary to set it according to the configured fuse judgment condition. Specifically, if the fuse judgment is an abnormal number, it indicates that the number of failed calls is used as the basis for whether to perform the fuse processing. Therefore, it is necessary to determine whether the total number of requests (that is, the number of calls) for calling the target method within the current sliding time window is greater than or equal to the pre-configured minimum number of requests. If less than, the call request to the target method is released. Otherwise, determine whether the number of call errors is greater than or equal to the pre-configured number threshold. If less than, the call request to the target method is released; if greater than, the current state of the circuit breaker is set to open, and at the same time, according to the sum of the current timestamp and the fuse duration, the next retry timestamp is set to indicate the fuse recovery time, forming a logical closed loop with the call condition judgment in the pre-processing logic.

[0054] In addition, if the circuit breaker judgment condition is the abnormal ratio, then determine whether the total number of requests (number of calls) in the current sliding time window is greater than or equal to the configured minimum number of requests; if less than, release the call request to the target method; if greater than or equal to, calculate the error ratio at this time, which is the ratio of the number of call errors to the number of calls; if the error ratio is greater than or equal to the configured ratio threshold, set the current state of the circuit breaker to open, and set the timestamp of the next circuit breaker recovery (next retry timestamp) according to the current timestamp and circuit breaker duration; if the error ratio is less than the ratio threshold, release the request.

[0055] In this embodiment, based on the number of exceptions or the abnormal proportion, the judgment of fuse processing is performed on the statistically obtained call error frequency, thereby achieving accurate and timely fuse processing of abnormal call interfaces.

[0056] In particular, in one embodiment, the duration of the sliding time window is set according to the fuse statistics duration specified by the fuse configuration parameters; the sliding time window includes several sub-time window intervals. In this embodiment, the length of the sliding time window is set according to the fuse statistics duration specified in the fuse configuration parameters, and each time the fuse statistics are performed, the current sliding time window will be determined based on the current time combined with the fuse statistics duration. Therefore, the time window of this embodiment is a flexible and dynamically changing window. Furthermore, the sliding time window is divided into multiple smaller sub-time window intervals, and the corresponding number of calls and number of call errors can be counted for each sub-time window interval.

[0057] Based on this, compared to the fixed time window, when dealing with a traffic surge during the transition period between two windows, inaccurate exception counts will occur, resulting in the inability to accurately blow the fuse. This embodiment can flexibly and accurately blow the call exceptions generated at different times, thereby further improving the timeliness and accuracy of interface blowing processing.

[0058] Figure 3 FIG. 1 is a flow chart of a method for configuring fuse configuration parameters in some embodiments, and the configuration method is executed after the application of the system is started. Figure 3 As shown, the configuration method of the fuse configuration parameters includes the following steps: Step S301, after the system application is started, it scans the target method with the annotation mark added, and registers the corresponding meta information to the data storage center.

[0059] Step S302, start the background management application, the background management application reads the method meta information registered in the data storage center, and adds the fuse configuration parameters of the meta information to save it in the data storage center.

[0060] Step S303: the data storage center sends the fuse configuration parameters to each foreground application node; wherein the foreground application node is the above-mentioned machine node.

[0061] Step S304: the foreground application node sets fuse configuration parameters according to the metadata groups of the multiple target methods.

[0062] Step S305 : the foreground application node initializes the current state of the circuit breaker to closed, initializes the total call counter to 0, and initializes the call error counter to 0.

[0063] Figure 4is a flow chart of an interface fusing method in some of the embodiments, such as Figure 4 As shown, the interface fusing method includes the following steps: Step S401, execute the pre-processing logic of the target method to determine whether the circuit breaker is closed; if so, execute step S405; otherwise, execute step S402; wherein, before the target method is called, the pre-processing logic of the configured AOP aspect is used to determine whether the current state of the circuit breaker is closed.

[0064] Step S402, determine whether the circuit breaker is turned on; if so, execute step S403; otherwise, execute step S413.

[0065] Step S403, determine whether the retry time has been reached; if so, execute step S404; otherwise, execute step S413; wherein, determine whether the retry time has been reached based on the size relationship between the current timestamp and the next retry timestamp.

[0066] Step S404, determining whether the circuit breaker is switched from open to half-open successfully; if so, executing step S405; otherwise, executing step S413.

[0067] Step S405, calling the target method.

[0068] Step S406, determine whether the target method is called abnormally; if so, execute step S407; otherwise, execute step S414.

[0069] Step S407: add 1 to the total call counter and the call error counter in the current sliding time window respectively.

[0070] Step S408, determine whether the circuit breaker is turned on; if so, end the process; otherwise, execute step S409.

[0071] Step S409, determine whether the circuit breaker is half-open; if so, execute step S415; otherwise, execute step S410.

[0072] Step S410, determine whether the total number of requests under the current sliding time window is greater than or equal to the minimum number of requests; if so, execute step S411; otherwise, end the process.

[0073] Step S411, determine whether the current abnormal ratio is greater than or equal to the preset ratio threshold, or the current abnormal number is greater than or equal to the preset number threshold; if so, execute step S412; otherwise, end the process. The current abnormal ratio is the ratio between the number of call errors and the number of calls. The number of abnormalities is the number of call errors.

[0074] Step S412, turn on the circuit breaker; end the process.

[0075] Step S413, execute the circuit breaker downgrade strategy; end the process. The circuit breaker downgrade strategy can throw a preset exception.

[0076] Step S414, determine whether the target method input and output parameters satisfy the MVEL expression; if so, execute step S407; otherwise, end the process.

[0077] Step S415, determine whether the exception type of the calling exception satisfies the specified exception type, or the input and output parameters satisfy the MVEL expression; if so, execute step S418; otherwise, execute step S416.

[0078] Step S416, closing the circuit breaker.

[0079] Step S417, clear various counters in the current sliding time window, including the total call counter and the call error counter, and end the process.

[0080] Step S418, turning on the circuit breaker.

[0081] Step S419: Update the next retry timestamp. End the process.

[0082] In the above steps S401 to S419, the AOP aspect intercepts and captures the input and output parameters of the target method, and executes the MVEL expression on the input and output parameters through the dynamically configured MVEL expression. If the execution result of the MVEL expression is satisfied and the result is true, the current call is recorded as an abnormal call. Afterwards, through the configured fuse trigger condition, the switch of the fuse circuit breaker is controlled within a sliding window, so that the interface call can be fused and the degradation strategy can be executed at the next call to protect the business interface call from a high failure rate.

[0083] Next, an example is used to illustrate the interface fuse method of the above embodiment. First, the system application name A, interface class name B, and interface class target method name C can be set. After that, the full path unique identifier of the target method is determined as "A#B#C" based on the above application name, interface class name, and interface class target method name. The fuse judgment condition of the target method is configured as the number of exceptions, that is, whether to perform fuse processing is determined based on whether the number of exceptions exceeds the number threshold. Set the statistical number threshold to 1 and the minimum number of requests to 1. Set the fuse duration to 10000 milliseconds and the fuse statistics duration to 180000 milliseconds. Set the content of the MVEL expression to "param[0] == 123456&&result == 'Insufficient balance'", that is, when the input parameter of the target method is "123456" and the execution result of the target method is a string returning "Insufficient balance", the execution result of the MVEL expression is true. The flag for including exceptions in fuse statistics can be turned on; set the specified exception class name to all Java class names. Set the circuit breaker degradation strategy to only throw the preset exceptions.

[0084] That is, the above-mentioned fuse configuration is: within the statistical duration of 180,000 milliseconds, if the number of calls to the target method satisfies the minimum number of requests of 1, and if the number of call errors is 1, or the MVEL expression is true 1 time, then within the fuse duration of 10,000 milliseconds, a fuse exception is thrown and the call of the target method is continuously broken.

[0085] You can use "@Fusing" as an annotation to mark the target method that needs to enable fuse. For example, you can set the "@Fusing" annotation on the target method "test" to mark the target method as the one that needs to enable fuse judgment. The content of the target method can be as follows: "@Fusing Public String test (String reqId){ System.out.println(reqId); If(“123”.equalsIgnoreCase(reqId)){ throw new BizException("123 is an illegal number, throw an exception"); } Return "Insufficient Balance"; }” When the above target method is called, it will first output the input parameter "reqId", and then specify reqId equal to the string "123" to simulate the abnormal call of the target method. At this time, an exception of type "BizException" will be directly thrown out. If reqId is specified as the string "1234", it is used to simulate the situation where the target method returns data normally after calling. At this time, the above-constructed MVEL expression is not satisfied. If reqId is specified as the string "123456", it is used to simulate the situation where the target method returns data normally after calling. Since the method return value is fixed as "insufficient balance", the above-constructed MVEL expression is satisfied at this time. It can be understood that the execution logic of the above-mentioned target method and the specific content of the MVEL expression are only examples and do not constitute a limitation on the target method and the MVEL expression.

[0086] After the application is started, the background configuration log will be obtained, and the unique identifier of the above full path, the fuse configuration parameters, and the meta information of the target method will be obtained. When calling the above target method, if the input parameter "reqId" is "1234", the target method will respond normally and output the message "Insufficient balance". At this time, if the target method is called successfully, the MVEL expression will be executed to capture the input and output parameters. At this time, the input parameter group param[0] is "1234", which does not meet the condition of the input parameter group "param[0]== 123456" in MVEL. Therefore, the execution result of the MVEL expression is false, and the target method can be called normally.

[0087] When calling the above target method, if the input parameter "reqId" is "123", the target method will throw an exception, and the corresponding exception information is "123 is an illegal number, and an exception is thrown". After that, when the target method is called for the second time with the same input parameter (that is, when "reqId" is "123"), since the number of exceptions specified in the above fuse configuration parameters is 1, the second call will trigger the fuse processing of the target method. At this time, the information that the service is fused will be output to the user. At this time, the state of the circuit breaker will be changed from closed to open. When calling the target method for the third time, if the input parameter is changed to "1234" (that is, simulating a normal request), it will be retried after the fuse time exceeds 10000 milliseconds. At this time, the state of the circuit breaker will be changed from half-open to open, and the target method will resume normal calling.

[0088] In addition, if the input parameter is changed to "123456" (simulating satisfying the MVEL expression condition) when calling the target method, since the return value of the target method is "insufficient balance", the MVEL expression result of "param[0] ==123456&&result == 'insufficient balance'" for the method input and output parameters is true. At this time, the circuit breaker is changed from closed to open. In the second call, the input parameter is still "123456". Since the circuit breaker is already open, the fuse is triggered and an exception will be thrown. In the third call, the input parameter is changed to "1234" (simulating a normal request). After the fuse duration exceeds 10,000 milliseconds, try again. At this time, the circuit breaker changes from half-open to closed. The target method will resume normal calling.

[0089] In this embodiment, an interface fuse device is also provided, and the interface fuse device is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. The terms "module", "unit", "subunit", etc. used below can implement a combination of software and / or hardware for a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0090] Figure 5 is a structural block diagram of the interface fuse device 50 of this embodiment, as shown in Figure 5 As shown, the interface fuse device 50 includes: an acquisition module 52, a judgment module 54, a counting module 56 and a fuse processing module 58; wherein: An acquisition module 52 is used to acquire the meta-information and fuse configuration parameters of the target method of the interface based on the target pre-notification, and confirm whether the target method meets the calling conditions according to the fuse configuration parameters and the current state of the circuit breaker; if so, the target method is called; wherein the target pre-notification is the pre-notification of the AOP aspect pre-configured for the target method; a judgment module 54 is used to judge whether the target method is called successfully based on the target post-notification; if so, the pre-configured fuse rule is executed according to the meta-information of the target method; if the execution result of the fuse rule is true, the number of calls and the number of call errors are counted; wherein the target post-notification is the post-notification of the AOP aspect pre-configured for the target method; a counting module 56 is used to count the number of calls and the number of call errors according to the fuse configuration parameters if the target method fails to be called; a fuse processing module 58 is used to judge whether to perform fuse processing on the target method according to the number of calls and the number of call errors within a preset sliding time window, combined with the fuse configuration parameters; if so, the target method is subjected to fuse processing.

[0091] It should be noted that the above modules can be functional modules or program modules, and can be implemented by software or hardware. For modules implemented by hardware, the above modules can be located in the same processor; or the above modules can be located in different processors in any combination.

[0092] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementation modes, and will not be repeated in this embodiment.

[0093] In addition, in combination with the interface fusing method provided in the above embodiments, a storage medium may be provided in this embodiment to implement the interface fusing method. The storage medium stores a computer program, and when the computer program is executed by a processor, any one of the interface fusing methods in the above embodiments is implemented.

[0094] It should be understood that the specific embodiments described herein are only used to explain the application, rather than to limit it. Based on the embodiments provided in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the protection scope of this application.

[0095] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.

[0096] Obviously, the drawings are only some examples or embodiments of the present application. For ordinary technicians in the field, the present application can also be applied to other similar situations based on these drawings without creative work. In addition, it is understandable that although the work done in this development process may be complicated and lengthy, for ordinary technicians in the field, certain changes in design, manufacturing or production based on the technical content disclosed in this application are only conventional technical means and should not be regarded as insufficient content disclosed in this application.

[0097] The term "embodiment" in this application refers to a specific feature, structure or characteristic described in conjunction with the embodiment that can be included in at least one embodiment of the present application. The appearance of this phrase in various locations in the specification does not necessarily mean the same embodiment, nor does it mean that it is mutually exclusive with other embodiments and is independent or optional. It is clearly or implicitly understood by those of ordinary skill in the art that the embodiments described in this application can be combined with other embodiments without conflict.

[0098] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of patent protection. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the scope of protection of the present application. Therefore, the scope of protection of the present application shall be subject to the attached claims.

Claims

1. An interface fusing method, characterized in that: include: Based on the target pre-notification, obtain the meta information and fuse configuration parameters of the target method of the interface, and confirm whether the target method meets the calling conditions according to the fuse configuration parameters and the current state of the circuit breaker; If yes, then call the target method; wherein the target pre-notification is a pre-notification of the AOP aspect pre-configured for the target method; Based on the target post-notification, determine whether the target method is successfully called; if so, execute the pre-configured fuse rule according to the meta-information of the target method; if the execution result of the fuse rule is true, count the number of calls and the number of call errors; wherein the target post-notification is the post-notification of the AOP aspect pre-configured for the target method; If the target method fails to be called, the number of calls and the number of call errors are counted according to the fuse configuration parameters; According to the number of calls and the number of call errors within the preset sliding time window, combined with the fuse configuration parameters, it is determined whether to perform fuse processing on the target method; if so, the target method is subjected to fuse processing.

2. The interface fusing method according to claim 1, characterized in that: According to the fuse configuration parameters and the current state of the circuit breaker, confirming whether the target method meets the calling conditions includes: When the fuse configuration parameter is not empty and the current state of the circuit breaker is closed, confirm that the target method meets the calling condition.

3. The interface fusing method according to claim 1, characterized in that: According to the fuse configuration parameters and the current state of the circuit breaker, confirming whether the target method meets the calling conditions includes: When the fuse configuration parameter is not empty and the current state of the circuit breaker is open, determine whether the current timestamp is greater than or equal to the next retry timestamp; if so, set the current state of the circuit breaker to half-open, and confirm that the target method meets the calling conditions; wherein the next retry timestamp is determined according to the fuse duration specified by the fuse configuration parameter and the timestamp corresponding to the last fuse processing of the target method; Otherwise, it is confirmed that the target method does not meet the calling conditions and the preset fuse degradation strategy is executed.

4. The interface fusing method according to claim 1, characterized in that: According to the fuse configuration parameters and the current state of the circuit breaker, confirming whether the target method meets the calling conditions includes: When the circuit breaker configuration parameter is not empty and the current state of the circuit breaker is half-open, it is confirmed that the target method does not meet the calling conditions and the preset circuit breaker downgrade strategy is executed.

5. The interface fusing method according to claim 1, characterized in that: The method further comprises: When the fuse configuration parameter is empty, confirm that the target method meets the calling condition.

6. The interface fusing method according to claim 1, characterized in that: When the target method fails to be called, the number of calls and the number of call errors are counted according to the fuse configuration parameters, including: When the target method fails to be called, obtaining the call exception type that caused the target method to fail to be called; Determine whether the call exception type is consistent with the preset exception type specified in the fuse configuration parameter; if so, count the number of method calls and the number of method call errors within the current sliding time window.

7. The interface fusing method according to claim 1, characterized in that: According to the number of calls and the number of call errors within a preset sliding time window, combined with the fuse configuration parameters, determining whether to perform fuse processing on the target method includes: When the fuse judgment condition specified by the fuse configuration parameter is the number of exceptions, the number of calls is greater than or equal to the minimum number of requests specified by the fuse configuration parameter, and the number of call errors is greater than or equal to the number threshold specified by the fuse configuration parameter, confirm that the target method is subjected to fuse processing, set the current state of the circuit breaker to open, and set the next retry timestamp according to the specified fuse duration; When the fuse judgment condition is the abnormal ratio, the number of calls is greater than or equal to the minimum number of requests, and the call error ratio is greater than or equal to the ratio threshold specified by the fuse configuration parameter, confirm that the fuse processing is performed on the target method, set the current state of the circuit breaker to open, and set the next retry timestamp according to the fuse duration; the call error ratio is the ratio of the number of call errors to the number of calls.

8. The interface fusing method according to any one of claims 1 to 7, characterized in that: The duration of the sliding time window is set according to the fuse statistical duration specified by the fuse configuration parameter; the sliding time window includes a plurality of sub-time window intervals.

9. An interface fuse device, characterized in that: include: Acquisition module, judgment module, counting module and fuse processing module; wherein: The acquisition module is used to obtain the meta information and fuse configuration parameters of the target method of the interface based on the target pre-notification, and confirm whether the target method meets the calling conditions according to the fuse configuration parameters and the current state of the circuit breaker; if so, call the target method; wherein the target pre-notification is the pre-notification of the AOP aspect pre-configured for the target method; The judgment module is used to judge whether the target method is successfully called based on the target post-notification; if so, execute the pre-configured fuse rule according to the meta-information of the target method; if the execution result of the fuse rule is true, count the number of calls and the number of call errors; wherein the target post-notification is the post-notification of the AOP aspect pre-configured for the target method; The counting module is used to count the number of calls and the number of call errors according to the fuse configuration parameters if the target method fails to be called; The fuse processing module is used to determine whether to perform fuse processing on the target method based on the number of calls and the number of call errors within a preset sliding time window, combined with the fuse configuration parameters; if so, perform fuse processing on the target method.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the interface fusing method according to any one of claims 1 to 8 are implemented.

Citation Information

Patent Citations

  • API fusing degradation implementation method and system based on back-end error code

    CN115065588A

  • Interface fusing method and device, server and computer readable storage medium

    CN115686912A

  • Global exception handling method and platform in large-scale micro-service cluster scenario

    WO2023125773A1

Cited By

  • Service fusing method and device and electronic equipment

    CN121387965A

  • Interface fusing method, interface fusing device and computer-readable storage medium

    WO2026076836A1