Early warning method and device for interface call, server and storage medium
By adding an early warning function to the API call request to control the number of API calls and push early warning information when the threshold is reached, the problem of slow response speed and increased load caused by failed external API calls is solved, ensuring the stability of the open platform.
Patent Information
- Application Number
- CN202110361986.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-02
- Publication Date
- 2025-12-16
- Estimated Expiration
- 2041-04-02
AI Technical Summary
In existing technologies, when external interface calls fail, the continuous retries to consume multiple messages cause the open platform to slow down its response speed, increase its load, and even crash.
By adding an alert function to the API call request, the number of API calls can be limited and an alert message can be pushed when the threshold is reached, thus avoiding retries.
This effectively avoids slow response times, increased load, and system crashes caused by retries, ensuring the stability and response speed of the open platform.
Smart Images

Figure CN113760505B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data processing, and in particular to an interface calling early warning method and device, a server and a storage medium. BACKGROUND
[0002] With the rise and continuous development of technology, when an open platform interfaces with different institutions for business, the open platform needs to call the external interface of the institution to be connected to synchronize data or respond. The open platform often uses the form of consuming messages to process the business logic of the business request of the institution, obtain the calling result of the external interface, and return it to the institution.
[0003] Currently, when the open platform calls an institution through an external interface, the external call may fail due to network reasons or external business processing problems. At this time, in order to avoid stopping the processing of the request due to an error in one call, thereby causing data loss, the form of consuming multiple messages can be used for continuous call retries.
[0004] In the process of implementing the present application, the inventors have found that the existing technology has at least the following problems: With continuous call retries of consuming multiple messages, the response speed of the open platform may slow down, the load may increase, and even the phenomenon of freezing may occur. SUMMARY
[0005] The present application provides an interface calling early warning method and device, a server and a storage medium to solve the problem of continuous retries of consuming messages when the external call fails, which leads to slow response speed, high load and freezing of the open platform.
[0006] In a first aspect, the present application provides an interface calling early warning method, comprising:
[0007] Obtaining an interface calling request, the interface calling request comprising: an identifier of a to-be-called object and a target calling method;
[0008] According to the annotation information of the target calling method, determining whether the interface calling request accepts early warning function control;
[0009] When the interface calling request accepts early warning function control, calling an early warning control device to control and warn the number of interface calls of the to-be-called object.
[0010] In a possible design of the first aspect, the step of determining whether the interface calling request accepts early warning function control according to the annotation information of the target calling method comprises:
[0011] According to the annotation information of the target calling method, obtaining the calling parameters of the interface calling request, the calling parameters comprising: a calling switch;
[0012] According to the opening and closing of the calling switch, it is determined whether the interface calling request accepts early warning function management and control.
[0013] In a first aspect, in another possible design, the calling early warning management and control device performs management and early warning of the interface calling times of the to-be-called object, including:
[0014] According to the annotation information of the target calling method, a parameter position where a preset configuration parameter is located is determined, the preset configuration parameter including: calling information of the to-be-called object and a unique identifier of the interface calling request, the calling information including: a called class object, a target calling method, and a calling parameter.
[0015] According to the to-be-called object identifier, the preset configuration parameter is obtained from the parameter position where the preset configuration parameter is located.
[0016] The calling information of the to-be-called object and the unique identifier of the interface calling request are encapsulated to obtain a unique request value of the interface calling request.
[0017] According to the unique request value and a preset early warning threshold, management and early warning of the interface calling times of the to-be-called object are performed.
[0018] In this possible design, according to the unique request value and the preset early warning threshold, management and early warning of the interface calling times of the to-be-called object are performed, including:
[0019] According to the unique request value, a current calling time in the cache is obtained.
[0020] According to the to-be-called object identifier, a calling early warning threshold of the to-be-called object is obtained from the parameter position where the preset configuration parameter is located.
[0021] If the current calling time reaches the calling early warning threshold, first early warning information is pushed and a standard result of the interface calling is obtained.
[0022] The standard result is output.
[0023] Optionally, before the step of pushing the first early warning information if the current calling time reaches the calling early warning threshold, the method further includes:
[0024] If the current calling time is greater than or equal to half of the calling early warning threshold, second early warning information is pushed.
[0025] Based on a preset interface calling logic, the interface calling request is continuously executed.
[0026] In the possible design, before the acquiring the current calling times in the cache according to the unique request value, the method further includes:
[0027] determining, according to the unique request value, whether the calling times key exists in the cache;
[0028] when the calling times key does not exist in the cache, creating the calling times key in the cache and assigning the value of 1 to the key;
[0029] the acquiring the current calling times in the cache according to the unique request value includes:
[0030] when the calling times key exists in the cache, determining the value of the key as the current calling times.
[0031] In a second aspect, an embodiment of the present application provides a pre-warning device for interface calling, which includes an acquiring module, a determining module and a processing module.
[0032] The acquiring module is configured to acquire an interface calling request, and the interface calling request includes an identifier of a to-be-called object and a target calling method.
[0033] The determining module is configured to determine, according to the annotation information of the target calling method, whether the interface calling request accepts pre-warning function control.
[0034] The processing module is configured to, when the interface calling request accepts pre-warning function control, call a pre-warning control device to control and pre-warn the interface calling times of the to-be-called object.
[0035] In a possible design of the second aspect, the determining module is specifically configured to:
[0036] acquire, according to the annotation information of the target calling method, a calling parameter of the interface calling request, and the calling parameter includes a calling switch.
[0037] determine, according to the opening and closing of the calling switch, whether the interface calling request accepts pre-warning function control.
[0038] In another possible design of the second aspect, the processing module is specifically configured to:
[0039] determine, according to the annotation information of the target calling method, a parameter position of a preset configuration parameter, and the preset configuration parameter includes calling information of the to-be-called object and a unique identifier of the interface calling request, and the calling information includes a called class object, a target calling method and a calling parameter.
[0040] According to the to-be-called object identifier, the preset configuration parameter is obtained from a parameter position where the preset configuration parameter is located;
[0041] The unique request value of the interface call request is obtained by encapsulating the calling information of the to-be-called object and the unique identifier of the interface call request.
[0042] According to the unique request value and a preset warning threshold, the interface call times of the to-be-called object are controlled and warned.
[0043] In this possible design, the processing module is configured to control and warn the interface call times of the to-be-called object according to the unique request value and a preset warning threshold, specifically as follows:
[0044] The processing module is specifically configured to:
[0045] According to the unique request value, the current call times in the cache are obtained.
[0046] According to the to-be-called object identifier, the calling warning threshold of the to-be-called object is obtained from a parameter position where the preset configuration parameter is located.
[0047] If the current call times reach the calling warning threshold, first warning information is pushed and a standard result for interface call is obtained.
[0048] The standard result is output.
[0049] Optionally, the processing module is further configured to, before pushing the first warning information if the current call times reach the calling warning threshold, execute:
[0050] If the current call times are greater than or equal to half of the calling warning threshold, second warning information is pushed.
[0051] Based on a preset interface call logic, the interface call request is continuously executed.
[0052] In this possible design, the processing module is further configured to, before obtaining the current call times in the cache according to the unique request value, execute:
[0053] According to the unique request value, it is determined whether a call times keyword exists in the cache.
[0054] When the call times keyword does not exist in the cache, the call times keyword is created in the cache, and the keyword is assigned a value of 1.
[0055] The unique request value, the current call times in the cache are obtained according to the unique request value, specifically as follows:
[0056] When the keyword of the number of invocations exists in the cache, the value of the keyword is determined as the current number of invocations.
[0057] In a third aspect, an embodiment of the present application provides a server, comprising: a processor, a memory, a display, and a transceiver.
[0058] The memory stores computer execution instructions.
[0059] The processor implements the pre-warning method of the interface call provided in the first aspect and each possible design when executing the computer program instructions.
[0060] In a fourth aspect, an embodiment of the present application provides a computer readable storage medium, wherein the computer readable storage medium stores computer program instructions, and the computer program instructions are used for implementing the pre-warning method of the interface call provided in the first aspect and each possible design when executed by a processor.
[0061] In a fifth aspect, an embodiment of the present application provides a computer program product, comprising a computer program, and the computer program is used for implementing the pre-warning method of the interface call provided in the first aspect and each possible design when executed by a processor.
[0062] The pre-warning method, device, computer, and storage medium of the interface call provided in the embodiments of the present application, in the method, an interface call request is acquired, and the interface call request comprises an identifier of a to-be-called object and a target calling method. Then, according to annotation information of the target calling method, it is determined whether the interface call request accepts pre-warning function control. When the interface call request accepts the pre-warning function control, a pre-warning control device is called to control and pre-warn the number of interface calls of the to-be-called object. In the scheme, by adding the pre-warning function control to the interface call request, it is avoided that with the consumption of multiple messages, continuous calling retries are performed, which may cause the response speed of an open platform to become slow, the load to increase, and even the phenomenon of death. BRIEF DESCRIPTION OF DRAWINGS
[0063] Figure 1 A principle diagram of pre-warning of the interface call provided in the embodiments of the present application is shown;
[0064] Figure 2 A flowchart of the pre-warning method of the interface call provided in the embodiments of the present application is shown;
[0065] Figure 3 A flowchart of the pre-warning method of the interface call provided in the embodiments of the present application is shown;
[0066] Figure 4 A flowchart of the pre-warning method of the interface call provided in the embodiments of the present application is shown;
[0067] Figure 5 A flowchart of the pre-warning method for interface calling provided by the embodiment of the present application;
[0068] Figure 6 A structural schematic diagram of the pre-warning device for interface calling provided by the embodiment of the present application;
[0069] Figure 7 A structural schematic diagram of the server provided by the embodiment of the present application. DETAILED DESCRIPTION
[0070] To make the objectives, technical solutions, and advantages of the embodiments of the present application clearer, the following will be combined with the accompanying drawings for the embodiments of the present application to make a clear and complete description of the technical solutions in the embodiments of the present application. Obviously, the described embodiments are some but not all of the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the protection scope of the present application.
[0071] Before introducing the embodiments of the present application, first, the professional terms and background technologies of the present application are explained and described.
[0072] The Spring framework is an open source Java 2 Platform Enterprise Edition (J2EE) application framework to solve the complexity of enterprise application development.
[0073] Aspect Orient Programming (AOP): a technology for unified maintenance of program functions through pre-compilation and dynamic proxy during running. By using AOP, the coupling degree between the parts of business logic can be reduced, the reusability of the program can be improved, and the development efficiency can be improved.
[0074] With the development of science and technology, when an open platform interfaces with a third party, the external interface of the open platform needs to call the third party to be connected for data synchronization or response. The open platform often adopts the form of consuming messages to process the business logic of the business request of the third party, obtain the calling result of the external interface, and return to the third party.
[0075] In actual connection between an open platform and a third party, the open platform calls the third party through an external interface. When the external interface returns an error result (which may be caused by network reasons or external business processing problems), the interface calling request needs to be constantly retried to avoid stopping the connection due to this error, thereby causing data loss.
[0076] However, the way of constantly retrying the interface call request can easily cause the response speed of the open platform to decrease, and further, when the number of interface call requests is constantly increasing, it can cause the load to increase and even cause the phenomenon of death.
[0077] On the basis of the problems in the prior art, Figure 1 The principle diagram of the interface call early warning provided by the embodiment of the present application is used to solve the above technical problems. As Figure 1 As shown in the figure, the principle diagram includes a consumption processing center 10, a third-party institution 11, and an open platform 12.
[0078] The open platform 12 includes a pre-warning control device 120.
[0079] In a possible implementation, when the open platform 12 obtains a business processing request sent by the consumption processing center 10, the open platform 12 calls the third-party institution 11 through an interface call request to obtain data of the third-party institution 11. At this time, the open platform 12 judges whether the interface call request needs pre-warning function control. If the pre-warning function control is needed, the pre-warning control device 120 in the open platform 12 controls and pre-warns the number of interface calls of the to-be-called object. If the pre-warning function control of the pre-warning function device 120 is not needed, the normal business logic is directly performed.
[0080] For the above technical problems, the technical concept process of the inventor is as follows: the inventor finds that the operation of adding pre-warning for the interface call request can be added, that is, the number of retries of the interface call request is set to control and alarm, so that the technical personnel can timely handle it to avoid the constant retry of the interface call request and the influence of a large number of interface call requests on the response of the open platform.
[0081] The technical solutions of the present application will be described in detail below with reference to the principle diagram shown in Figure 1 It should be noted that the following specific embodiments can be combined with each other, and the same or similar concepts or processes can not be described in detail in some embodiments. The embodiments of the present application will be described below with reference to the accompanying drawings.
[0082] Figure 2 The flowchart of the interface call early warning method embodiment one provided by the embodiment of the present application.
[0083] As shown in the figure, the interface call early warning method can include the following steps: Figure 2
[0084] Step 21, obtaining an interface call request.
[0085] In the scheme, the embodiment takes the connection between the Ares open platform and the third-party institution as an example. When the consumption processing center sends a business processing request to the open platform, the open platform calls the external interface according to the interface calling request to obtain corresponding data in the third-party institution.
[0086] Optionally, the open platform can be implemented in the form of a server.
[0087] In this step, the interface calling request, i.e., the business processing request sent by the consumption processing center to the open platform, is obtained. The open platform sends the interface calling request according to the business processing request.
[0088] Optionally, the interface calling request can include the identifier of the calling object and the target calling method.
[0089] Specifically, the identifier of the calling object can be used to indicate that the open platform calls the third-party institution corresponding to the business processing request according to the business processing request sent by the consumption processing center, i.e., the calling object can be the third-party institution; different interface calling requests can have different target calling methods.
[0090] Step 22, determining whether the interface calling request accepts the early warning function control according to the annotation information of the target calling method.
[0091] In the application, the Spring-AOP technology can be used to add annotation information to the target calling method of the interface calling request, i.e., the annotation information is used to indicate whether the interface calling request needs to accept the early warning function control. When the interface calling request accepts the early warning function control, it can be intercepted by the Spring container and processed subsequently.
[0092] In this step, the annotation information of the target calling method can be parsed, and then the calling parameters corresponding to the interface calling request can be obtained in the parsed information. Whether the interface calling request accepts the early warning function control can be determined from the calling parameters.
[0093] Step 23, when the interface calling request accepts the early warning function control, calling the early warning control device to control and warn the interface calling times of the calling object.
[0094] In this step, according to the annotation information of the target calling method in the above steps, when the interface calling request accepts the early warning function control, the early warning control device is called to control the interface calling times of the calling object, and according to the interface calling times, the corresponding early warning is performed.
[0095] In a possible implementation, an object identifier of a requested object to be invoked can be obtained through an interface call request, the number of invocations of the object to be invoked is obtained, and the number of invocations is compared with a preset warning threshold in the open platform to determine whether the interface call request needs to be controlled and warned.
[0096] The method for warning of the interface call provided in the embodiments of the present application can determine whether the interface call request accepts the control and warning of the warning function according to the annotation information of the target invocation method by obtaining the interface call request. When the interface call request accepts the control and warning of the warning function, the warning control device is invoked to control and warn the number of invocations of the object to be invoked. In this scheme, the warning function is added to the interface call request to avoid the phenomenon that the response speed of the open platform becomes slow, the load increases, and even the open platform is deadlocked due to the continuous invocation retry of the plurality of messages.
[0097] On the basis of Figure 2 , Figure 3 The flowchart of the second embodiment of the method for warning of the interface call provided in the embodiments of the present application is shown in FIG. 2. As shown in FIG. 2, the step 22 can be implemented by the following steps. Figure 3
[0098] Step 31: Obtain the invocation parameter of the interface call request according to the annotation information of the target invocation method.
[0099] In this step, the annotation information of the target invocation method can be parsed, and the invocation parameter corresponding to the interface call request is extracted from the parsed information.
[0100] Optionally, the invocation parameter includes a call switch. The call switch is used to determine whether the interface call request needs to accept the control of the warning function.
[0101] Optionally, in the prior art, the interface call is constantly retried in the form of a plurality of messages, and if the number of retries is too large, the response speed of the open platform becomes slow, the load increases, and the like, therefore, the call switch can be used as a condition for determining whether the interface call request needs to accept the control of the warning function.
[0102] Step 32: Determine whether the interface call request accepts the control of the warning function according to the opening and closing of the call switch.
[0103] In this step, when the call switch is opened, it can be indicated that the open platform accepts the control and warning of the warning function when invoking the external interface, and when the call switch is closed, it can be indicated that the open platform does not need to accept the control and warning of the warning function when invoking the external interface.
[0104] The interface calling early warning method provided by the embodiments of the present application comprises the following steps: obtaining calling parameters of an interface calling request according to annotation information of a target calling method; and determining whether the interface calling request accepts early warning function control based on opening and closing of a calling switch in the calling parameters. In the scheme, whether the interface calling request needs to accept early warning function control is determined through judgment of the state of the calling switch, thereby providing a basis for subsequent management and control of the number of interface calls to a calling object and early warning.
[0105] On the basis of the above embodiments, Figure 4 The flowchart of the third embodiment of the interface calling early warning method provided by the embodiments of the present application is shown in FIG. 4. Figure 4 As shown in FIG. 4, the step 23 can be implemented through the following steps.
[0106] Step 41: determining a parameter position of preset configuration parameters according to annotation information of a target calling method.
[0107] The preset configuration parameters comprise calling information of a calling object and a unique identifier of an interface calling request, and the calling information comprises a called class object, a target calling method and calling parameters.
[0108] In this step, the parameter position of the preset configuration parameters can be a configuration platform or a configuration file. Different target calling methods have different annotation information, and the annotation information can be used to determine the parameter position of the calling information of the calling object and the unique identifier of the interface calling request corresponding to the target calling method.
[0109] Optionally, the configuration platform can be a parameter position of preset configuration parameters independent of an open platform, and is used to configure dynamically adjustable parameters; and the configuration file can be a parameter position of preset configuration parameters cached in the open platform.
[0110] In a possible implementation, if the number of external calls of the target calling method is configured in the configuration platform, the number of external calls of the target calling method can be obtained in the configuration platform according to the annotation information.
[0111] In another possible implementation, if the number of external calls of the target calling method is not configured in the configuration platform, a default global calling number can be obtained in the configuration file.
[0112] Step 42: obtaining preset configuration parameters from the parameter position of the preset configuration parameters according to an identifier of a calling object.
[0113] In this step, the parameter position of the preset configuration parameters stores key values (English: Key) of different calling objects, that is, the key values of different calling objects are different. The key values represent calling information of a calling object and a unique identifier of an interface calling request corresponding to the calling object.
[0114] Specifically, according to the key value of different calling objects, the parameter positions of different objects are determined, that is, the preset configuration parameter information of the to-be-called object is obtained.
[0115] In a possible design, according to the to-be-called object identifier, the calling information of the to-be-called object and the unique identifier of the interface calling request are obtained in the configuration platform or the configuration file.
[0116] Step 43, the calling information of the to-be-called object and the unique identifier of the interface calling request are encapsulated to obtain a unique request value of the interface calling request.
[0117] In this step, the class object to be called and the target calling method are encapsulated, and the encapsulation result is used for subsequent judgment of the uniqueness of the request. The unique identifier of the interface calling request, for example, an order number, is obtained, and then a unique request value of the interface calling request is generated through a certain method, and the unique request value is used as the key value of the cache.
[0118] In a possible implementation, the unique request value can be the result of encapsulation of the class object name, the target calling method name and the unique identifier, and the result is stored in the redisKey in the cache.
[0119] Step 44, according to the unique request value and the preset warning threshold, the interface calling times of the to-be-called object are controlled and warned.
[0120] In this step, according to the unique request value, the current calling times of the interface can be determined, and the current calling times are compared with the preset warning threshold to realize the control and warning of the interface calling request.
[0121] Optionally, the warning threshold can be the warning times of the third-party institution according to different calling businesses.
[0122] Optionally, this step can be implemented in the following way:
[0123] Step 1, according to the unique request value, the current calling times in the cache are obtained.
[0124] Specifically, the unique request value is used as the key value of the cache, and when the cache contains the key of the calling times, the value of the key is determined as the current calling times.
[0125] Optionally, before this, according to the unique request value, it is determined whether the cache contains the key of the calling times.
[0126] Specifically, if the cache does not contain the key of the calling times, the key of the calling times is created in the cache, and the value of the key is assigned as 1, and with the increase of the external calling times, the value of the key also increases accordingly.
[0127] Step 2, according to the object to be called identification, from the parameter position where the preset configuration parameter is located, the calling warning threshold of the object to be called is obtained.
[0128] Specifically, according to the object to be called identification, the calling warning threshold of the object to be called is obtained at the configuration platform. If the configuration platform does not exist, the default global calling number in the configuration file is obtained as the calling warning threshold.
[0129] Optionally, the size of the warning threshold can be configured by a technician, or can be configured by default by the open platform according to the influence degree of the interface calling request retry on the open platform.
[0130] Step 3, if the current calling number reaches the calling warning threshold, the first warning information and the standard result for obtaining the interface are pushed, and then the standard result is output.
[0131] Specifically, when the current calling number is greater than or equal to the calling warning threshold, the first warning information can be sent to the terminal of the technician to remind the technician, and an alarm can be reported on the open platform with display or / and voice function to remind the technician. That is, the technician is reminded to handle the event as soon as possible, and the standard result corresponding to the interface calling request is obtained from the unique request value, and then the standard result is output.
[0132] Optionally, before that, if the current calling number is greater than or equal to half of the calling warning threshold, the second warning information is pushed. Specifically, the second warning information can be sent to the terminal of the technician, or an alarm can be reported on the open platform with display or / and voice function to remind the technician, so as to make the technician pay attention to the event, and continue to execute the interface calling request based on the preset interface calling logic, without affecting the normal business processing flow.
[0133] Among them, the preset interface calling logic can be a normal business processing flow based on the interface calling request.
[0134] The interface calling early warning method provided by the embodiments of the present application comprises the following steps: determining a parameter position of a preset configuration parameter according to annotation information of a target calling method; obtaining calling information of a to-be-called object and a unique identifier of an interface calling request from the parameter position of the preset configuration parameter according to a to-be-called object identifier; encapsulating the calling information of the to-be-called object and the unique identifier of the interface calling request to obtain a unique request value of the interface calling request; and performing control and early warning on the number of times of interface calling of the to-be-called object according to the unique request value and a preset early warning threshold. In the scheme, the unique request value of the interface calling request is determined, the control and early warning on the number of times of interface calling are realized, and a technical personnel can quickly avoid possible adverse conditions of an open platform.
[0135] On the basis of the above embodiments, Figure 5 The flow chart of the fourth embodiment of the interface calling early warning method provided by the embodiments of the present application is shown in FIG. 6. The technical scheme related to the embodiments of the present application is simply summarized, and the implementation principle is not described herein. As shown in FIG. 6, the total flow chart comprises the following steps: Figure 5
[0136] Step 1: Start;
[0137] Step 2: An open platform obtains an interface calling request and calls a third-party institution externally;
[0138] Step 3: When the interface calling request accepts early warning function control, a warning control device is called;
[0139] Specifically, the calling parameters of the interface calling request are obtained, including a calling switch. If the calling switch is turned on, it indicates that the interface calling request accepts early warning function control, and the warning control device needs to be called. If the calling switch is turned off, it indicates that the interface calling request does not accept early warning function control, and the warning control device does not need to be called;
[0140] Step 4: It is judged whether the calling switch is turned on. If yes, step 5 is executed; if no, step 12 is executed;
[0141] Step 5: An early warning threshold is obtained. Specifically, the early warning threshold can be obtained through a configuration platform or a configuration file;
[0142] Step 6: The current number of times of calling of the interface calling request is obtained;
[0143] Step 7: It is judged whether the current number of times of calling reaches the early warning threshold. If yes, step 11 is executed; if no, step 8 is executed;
[0144] Step 8: It is judged whether the current number of times of calling reaches half of the early warning threshold. If yes, step 9 is executed; if no, step 10 is executed;
[0145] Step 9, push the second early warning information;
[0146] Step 10, continue to execute the interface calling logic, and execute Step 13;
[0147] Step 11, push the first early warning information;
[0148] Step 12, obtain the standard result;
[0149] Step 13, end.
[0150] The early warning method for interface calling provided by the embodiment of the application obtains an interface calling request through an open platform, calls a third-party institution, judges whether the interface calling request accepts early warning function control, if the interface calling request accepts early warning function control, controls and early warns the interface calling request through an early warning control device, and further judges the size of the current calling number of the interface calling request and the early warning threshold value to determine whether to push early warning information. In the scheme, the early warning function control is added to the interface calling request, which avoids the phenomenon that the response speed of the open platform becomes slow, the load increases, and even the open platform is dead due to the calling retry of multiple messages.
[0151] On the basis of the early warning method for interface calling, Figure 6 The structure diagram of the early warning device for interface calling provided by the embodiment of the application is shown in FIG. 1. Figure 6 As shown in the figure, the device includes an obtaining module 61, a determining module 62 and a processing module 63.
[0152] The obtaining module 61 is configured to obtain an interface calling request, and the interface calling request includes an identifier of a to-be-called object and a target calling method.
[0153] The determining module 62 is configured to determine, according to the annotation information of the target calling method, whether the interface calling request accepts early warning function control.
[0154] The processing module 63 is configured to, when the interface calling request accepts early warning function control, control and early warn the interface calling number of the to-be-called object through an early warning control device.
[0155] In a possible design of the embodiment of the application, the determining module 62 is specifically configured to:
[0156] According to the annotation information of the target calling method, obtain a calling parameter of the interface calling request, and the calling parameter includes a calling switch.
[0157] According to the opening and closing of the calling switch, determine whether the interface calling request accepts early warning function control.
[0158] In another possible design of the embodiment of the application, the processing module 63 is specifically configured to:
[0159] According to the annotation information of the target calling method, a parameter position where the preset configuration parameter is located is determined, and the preset configuration parameter includes calling information of a to-be-called object and a unique identifier of an interface calling request, and the calling information includes a called class object, a target calling method, and a calling parameter;
[0160] According to the to-be-called object identifier, the preset configuration parameter is obtained from the parameter position where the preset configuration parameter is located;
[0161] The calling information of the to-be-called object and the unique identifier of the interface calling request are encapsulated to obtain a unique request value of the interface calling request;
[0162] According to the unique request value and a preset warning threshold, the interface calling times of the to-be-called object are controlled and warned.
[0163] In this possible design, the processing module 63 is configured to control and warn the interface calling times of the to-be-called object according to the unique request value and a preset warning threshold, and specifically:
[0164] The processing module 63 is specifically configured to:
[0165] According to the unique request value, a current calling time in the cache is obtained;
[0166] According to the to-be-called object identifier, a calling warning threshold of the to-be-called object is obtained from the parameter position where the preset configuration parameter is located;
[0167] If the current calling time reaches the calling warning threshold, a first warning information is pushed and a standard result of the calling is obtained;
[0168] The standard result is output.
[0169] Optionally, the processing module 63 is further configured to, before pushing the first warning information if the current calling time reaches the calling warning threshold, execute:
[0170] If the current calling time is greater than or equal to half of the calling warning threshold, a second warning information is pushed;
[0171] Based on a preset interface calling logic, the interface calling request is continuously executed.
[0172] In this possible design, the processing module 63 is further configured to, before obtaining the current calling time in the cache according to the unique request value, execute:
[0173] According to the unique request value, it is determined whether a calling time keyword exists in the cache;
[0174] When the keyword of the calling times does not exist in the cache, the keyword of the calling times is created in the cache, and the keyword is assigned a value of 1;
[0175] According to the unique request value, the current calling times in the cache are acquired, including:
[0176] When the keyword of the calling times exists in the cache, the value of the keyword is determined as the current calling times.
[0177] The interface calling pre-warning device provided by the embodiments of the present application can be used to execute the interface calling pre-warning technical solution in the above embodiments, and has similar implementation principles and technical effects, which will not be described here.
[0178] It should be noted that the division of each module of the above device is only a logical function division, and all or part of the actual implementation can be integrated into one physical entity, or can be physically separated. And these modules can all be implemented in the form of software called by a processing element; all can be implemented in the form of hardware; some modules can be implemented in the form of software called by a processing element, and some modules can be implemented in the form of hardware. For example, the determination module 62 can be a separate processing element, or can be integrated in a chip of the above device, in addition, it can also be stored in the memory of the above device in the form of program code, and the function of the above determination module is called and executed by a processing element of the above device. The implementation of other modules is similar. In addition, all or part of these modules can be integrated together, or can be independently implemented. The processing element here can be an integrated circuit with signal processing capability. In the implementation process, each step of the above method or each module can be completed by the integrated logic circuit of hardware or the instruction of software in the processing element.
[0179] Figure 7 The structure schematic diagram of the server provided by the embodiments of the present application is shown in the figure. Figure 7 As shown in the figure, the server can include a processor 71, a memory 72, a transceiver 73 and a display 74.
[0180] The processor 71 executes the computer execution instructions stored in the memory, so that the processor 71 executes the scheme in the above embodiments. The processor 71 can be a general-purpose processor, including a central processing unit CPU, a network processor NP, etc.; it can also be a digital signal processor DSP, an application-specific integrated circuit ASIC, a field programmable gate array FPGA or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.
[0181] The memory 72 and the transceiver 73 are connected with the processor 71 through a system bus and complete communication with each other, and the memory 72 is used for storing computer program instructions.
[0182] The transceiver 73 is used for communication with other computers. Optionally, in the hardware implementation, the above-mentioned Figure 6 The acquisition module 61 in the embodiment shown corresponds to the transceiver 73 in the embodiment, and the transceiver 73 constitutes a communication interface.
[0183] The display 74 can be a user interface for displaying the management and early warning of the interface call times. The user interface can include graphics, text, icons, videos and any combination thereof.
[0184] The system bus can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The system bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is shown in the figure, but it does not mean that there is only one bus or one type of bus. The transceiver is used to realize the communication between the database access device and other computers (such as clients, read-write libraries and read-only libraries). The memory can include random access memory (RAM) and can also include non-volatile memory such as at least one disk memory.
[0185] The server provided by the embodiment of the application can be used to execute the early warning of the interface call in the above-mentioned embodiment, and the implementation principle and technical effects are similar, which will not be described here.
[0186] The embodiment of the application further provides a chip for executing the early warning of the interface call in the above-mentioned embodiment.
[0187] The embodiment of the application further provides a computer readable storage medium, which stores computer instructions, and when the computer instructions are executed on a computer, the computer executes the early warning of the interface call in the above-mentioned embodiment.
[0188] The embodiment of the application further provides a computer program product, which includes a computer program stored in a computer readable storage medium, at least one processor can read the computer program from the computer readable storage medium, and when the at least one processor executes the computer program, the early warning of the interface call in the above-mentioned embodiment can be realized.
[0189] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, and are not intended to limit the present application; although the present application has been described in detail with reference to the above embodiments, those skilled in the art should understand that the technical solutions recorded in the above embodiments can still be modified, or some or all of the technical features can be replaced by equivalents; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for early warning of an interface call, characterized in that, The method comprises the following steps: An interface calling request is acquired, and the interface calling request comprises an identifier of an object to be called and a target calling method; It is determined, according to annotation information of the target calling method, whether the number of times of calling the object to be called by the interface calling request is subjected to pre-warning function control; When the number of times of calling the object to be called by the interface calling request is subjected to pre-warning function control, a current number of times of calling the interface calling request in a cache is acquired; if the current number of times of calling is greater than or equal to half of a preset calling pre-warning threshold, second pre-warning information is pushed, and the interface calling request is continuously executed based on a preset interface calling logic; the second pre-warning information is used to indicate that attention is paid to a current situation; If the current number of times of calling reaches the preset calling pre-warning threshold, first pre-warning information is pushed, a standard result corresponding to the interface calling request is acquired, and the standard result is output; the first pre-warning information is used to indicate that the current situation is processed.
2. The method of claim 1, wherein, The method further comprises the following steps: According to the annotation information of the target calling method, a calling parameter of the interface calling request is acquired, and the calling parameter comprises a calling switch; According to the opening and closing of the calling switch, it is determined whether the number of times of calling the object to be called by the interface calling request is subjected to pre-warning function control.
3. The method according to claim 1 or 2, characterized in that, Before the step of acquiring the current number of times of calling the interface calling request in the cache, the method further comprises the following steps: According to the annotation information of the target calling method, a parameter position of a preset configuration parameter is determined, the preset configuration parameter comprises calling information of the object to be called and a unique identifier of the interface calling request, and the calling information comprises a called class object, the target calling method and a calling parameter; According to the identifier of the object to be called, the preset configuration parameter is acquired from the parameter position of the preset configuration parameter; The calling information of the object to be called and the unique identifier of the interface calling request are encapsulated to obtain a unique request value of the interface calling request.
4. The method of claim 3, wherein, The step of acquiring the current number of times of calling the interface calling request in the cache comprises the following steps: According to the unique request value, the current number of times of calling in the cache is acquired. The method further comprises the following steps: According to the identifier of the object to be called, a calling pre-warning threshold of the object to be called is acquired from the parameter position of the preset configuration parameter.
5. The method of claim 4, wherein, Before the step of acquiring the current number of times of calling in the cache according to the unique request value, the method further comprises the following steps: According to the unique request value, it is determined whether a keyword of the number of times of calling exists in the cache; When the keyword of the number of times of calling does not exist in the cache, the keyword of the number of times of calling is created in the cache, and the keyword is assigned a value of 1; The step of acquiring the current number of times of calling in the cache according to the unique request value comprises the following steps: When the keyword of the number of times of calling exists in the cache, the value of the keyword is determined as the current number of times of calling.
6. A pre-warning device for interface call, characterized in that, The method comprises the following steps: An acquisition module, a determination module and a processing module are provided. The acquisition module is configured to acquire an interface calling request, the interface calling request comprising an identifier of a to-be-called object and a target calling method; The determination module is configured to determine, according to the annotation information of the target calling method, whether the number of times of calling the to-be-called object by the interface calling request is subject to pre-warning function control; The processing module is configured to, when the number of times of calling the to-be-called object by the interface calling request is subject to pre-warning function control, acquire a current number of times of calling in the cache of the interface calling request; if the current number of times of calling is greater than or equal to half of a preset calling pre-warning threshold, push second pre-warning information and continue to execute the interface calling request based on a preset interface calling logic; the second pre-warning information is used to indicate that attention is drawn to a current situation; if the current number of times of calling reaches the preset calling pre-warning threshold, push first pre-warning information and acquire a standard result corresponding to the interface calling request, and output the standard result; the first pre-warning information is used to indicate that the current situation is processed.
7. The apparatus of claim 6, wherein, The determination module is specifically configured to: acquire, according to the annotation information of the target calling method, a calling parameter of the interface calling request, the calling parameter comprising a calling switch; determine, according to the opening and closing of the calling switch, whether the number of times of calling the to-be-called object by the interface calling request is subject to pre-warning function control.
8. The apparatus of claim 6 or 7, wherein, Before the processing module acquires the current number of times of calling in the cache of the interface calling request, the processing module is further configured to: determine, according to the annotation information of the target calling method, a parameter position of a preset configuration parameter, the preset configuration parameter comprising calling information of the to-be-called object and a unique identifier of the interface calling request, the calling information comprising a called class object, the target calling method and a calling parameter; acquire, according to the to-be-called object identifier, the preset configuration parameter from the parameter position of the preset configuration parameter; encapsulate the calling information of the to-be-called object and the unique identifier of the interface calling request to obtain a unique request value of the interface calling request.
9. The apparatus of claim 8, wherein when the processing module acquires the current number of times of calling in the cache, the processing module is specifically configured to: acquire, according to the unique request value, the current number of times of calling in the cache; the processing module is further configured to acquire, according to the to-be-called object identifier, a calling pre-warning threshold of the to-be-called object from the parameter position of the preset configuration parameter.
10. The apparatus of claim 9, wherein, the processing module is further configured to, before acquiring, according to the unique request value, the current number of times of calling in the cache, perform: determine, according to the unique request value, whether a calling times keyword exists in the cache; when the calling times keyword does not exist in the cache, create the calling times keyword in the cache and assign a value of 1 to the keyword; the acquiring, according to the unique request value, of the current number of times of calling in the cache comprises: when the calling times keyword exists in the cache, determine a value of the keyword as the current number of times of calling.
11. A server, characterized by The computer readable storage medium stores computer-executable instructions, which, when executed by a processor, implement the pre-warning method of interface call according to any one of claims 1-5.
12. A computer-readable storage medium, characterized in that, The computer program, when executed by a processor, implements the pre-warning method of interface call according to any one of claims 1-5.
13. A computer program product comprising a computer program, characterized in that, The computer program, when executed by a processor, implements the pre-warning method of interface call according to any one of claims 1-5.
Citation Information
Patent Citations
Data processing method and device, electronic equipment and storage medium
CN112181541A
Data management method, device and equipment and storage medium
CN112487454A