Interface call control method, device, equipment and storage medium

By monitoring the execution results of the interface call task and determining the re-execution time according to the preset frequency, the task is inserted into the queue, which solves the problem of repeated attempts with different frequency rhythms in different application scenarios, and realizes automatic interface call task retry, improving development efficiency.

CN114356610BActive Publication Date: 2025-03-28PING AN TECH (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210031785.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-12
Publication Date
2025-03-28
Estimated Expiration
2042-01-12

AI Technical Summary

Technical Problem

In different application scenarios, when implementing repeated attempts with different frequency rhythms, developers need to manually write corresponding code, which consumes a lot of time and energy and affects the efficiency of rapid iterative development.

Method used

By monitoring the execution result of the interface calling task, when the task fails, the re-execution time is determined based on the preset frequency of repetition attempts, the task is inserted into the interface calling task queue, and the task is read from the queue and executed according to the re-execution time.

Benefits of technology

It realizes automatic repeated execution of interface call tasks, reducing the workload of developers and improving the efficiency of rapid iterative development.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114356610B_ABST
    Figure CN114356610B_ABST
Patent Text Reader

Abstract

The present application belongs to the field of data communication, and proposes a control method, device, equipment and storage medium for interface calls. The method includes: monitoring the execution result of the interface call task; when the execution result of the interface call task is a call failure, determining the re-execution time of the interface call task according to a preset re-attempt frequency; inserting the interface call task into the interface call task queue according to the determined re-execution time; reading and executing the interface call task from the interface call task queue according to the re-execution time. For different application scenarios, when the interface call task is repeatedly attempted at different frequency rhythms, only the re-attempt frequency needs to be input to automatically repeat the execution of the interface call task, which is conducive to reducing the workload of developers and improving the efficiency of rapid iterative development.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data communications, and in particular to a control method, device, equipment and storage medium for interface calls. Background Art

[0002] With the advancement of software technology, our systems are now usually divided into distributed SOA (service-oriented framework in Chinese) or microservices. That is, a system contains multiple subsystem services, and the subsystem services often call each other through interfaces. Exceptions may occur during the execution of interface call tasks, resulting in service call failures. As microservices now have higher and higher requirements for business function stability, when a function of a background service triggers a call to another interface service and fails, multiple attempts may be required at the required frequency rhythm.

[0003] When implementing repeated attempts at different frequency rhythms in different application scenarios, developers are usually required to expend labor to develop corresponding codes. In addition, in the fast-paced iterative development process, writing corresponding codes for different frequency rhythms consumes a lot of time and energy, which is not conducive to improving the efficiency of rapid iterative development. Summary of the invention

[0004] In view of this, the embodiments of the present application provide a control method, device and equipment for interface calls to solve the problem in the prior art that when repeatedly attempting to implement different frequency rhythms in different application scenarios, it is necessary to write corresponding codes for different frequency rhythms, which consumes a lot of time and energy and is not conducive to improving the efficiency of rapid iterative development.

[0005] A first aspect of an embodiment of the present application provides a method for controlling an interface call, the method comprising:

[0006] Monitor the execution results of the interface call tasks;

[0007] When the execution result of the interface call task is a call failure, determining the re-execution time of the interface call task according to a preset retry frequency;

[0008] Inserting the interface call task into the interface call task queue according to the determined re-execution time;

[0009] The interface call task is read from the interface call task queue and executed according to the re-execution time.

[0010] In combination with the first aspect, in a first possible implementation manner of the first aspect, determining the re-execution time of the interface call task according to a preset repetition attempt frequency includes:

[0011] Determining a repetitive execution interval of the interface call task according to a preset repetitive attempt frequency;

[0012] The re-execution time of the interface call task is determined according to the time when the interface call fails and the repeated execution interval.

[0013] In combination with the first possible implementation manner of the first aspect, in a second possible implementation manner of the first aspect, before determining the repetition execution interval of the interface call task according to the repetition attempt frequency, the method further includes:

[0014] When the usage rate of the processor of the callee is greater than a first predetermined value, reducing the repetition frequency according to an increase in the usage rate of the processor;

[0015] When the usage rate of the processor of the callee is less than a second predetermined value, increasing the retry frequency according to the decrease in the usage rate of the processor;

[0016] When the usage rate of the processor of the called party is greater than a second predetermined value and less than a first predetermined value, the retry frequency is determined to be a fixed value, wherein the first predetermined value is greater than the second predetermined value.

[0017] In combination with the first aspect, in a third possible implementation manner of the first aspect, inserting the interface call task into the interface call task queue according to the determined re-execution time includes:

[0018] Compare the re-execution time with the execution time of the interface call task in the interface call task queue;

[0019] According to the comparison result between the re-execution time and the execution time of the interface call task in the interface call task queue, the position of the re-executed interface call task in the interface call task queue is determined.

[0020] In combination with the third possible implementation manner of the first aspect, in a fourth possible implementation manner of the first aspect, the interface call task queue is a list of a binary heap structure, and determining a position of the interface call task to be executed again in the interface call task queue according to a comparison result of the re-execution time with the execution time of the interface call task in the interface call task queue includes:

[0021] Inserting the re-executed interface call task into the end of the leaf node of the queue of the binary heap;

[0022] Compare the re-execution time with the execution time of the interface call task of the leaf node, and if the re-execution time is earlier than the execution time of the interface call task of the leaf node, swap the position of the re-executed interface call task and the leaf node;

[0023] Compare the execution time of the re-executed interface call task with the execution time of the interface call task of the current parent node of the re-executed task; if the re-execution time is earlier than the execution time of the interface call task of the parent node of the re-executed interface call task, swap the positions of the re-executed interface call task and the parent node of the re-executed interface call task until the re-execution time is later than the execution time of the interface call task of the parent node of the re-executed interface call task, or until the execution time of the interface call task is later than the execution time of the interface call task of the leaf node.

[0024] In combination with the fourth possible implementation manner of the first aspect, in a fifth possible implementation manner of the first aspect, reading and executing the interface call task from the interface call task queue according to the re-execution time includes:

[0025] Execute the interface call task of the root node according to the pre-recorded execution time of the interface call task of the root node, and select a leaf node of the current binary heap to move to the position of the root node;

[0026] Compare the execution time of the interface call task of the selected leaf node with the interface call task of the child node at the current position of the leaf node. If the execution time of the interface call task of the selected leaf node is later than the execution time of the interface call task of the child node at the current position of the leaf node, select the child node with an earlier execution time to exchange positions with the current position of the leaf node, until the execution time of the selected leaf node is earlier than the execution time of the task of the child node of the leaf node, obtain an updated binary heap list, and determine the execution time of the interface call task of the root node in the updated list;

[0027] When the determined execution time arrives, the interface calling task of the root node is executed.

[0028] In combination with the first aspect, in a sixth possible implementation manner of the first aspect, before inserting the interface call task into the interface call task queue, the method further includes:

[0029] Determining whether the number of tasks in the task queue has reached a preset queue capacity;

[0030] When the number of tasks in the task queue reaches the queue capacity, the task queue is expanded.

[0031] A second aspect of an embodiment of the present application provides a control device for interface calling, the device comprising:

[0032] A status monitoring unit, used to monitor the execution results of the interface call task;

[0033] A re-execution time determination unit, used to determine the re-execution time of the interface call task according to a preset repetition attempt frequency when the execution result of the interface call task is a call failure;

[0034] A queue updating unit, configured to insert the interface call task into an interface call task queue according to the determined re-execution time;

[0035] The task execution unit is used to read and execute the interface call task from the interface call task queue according to the re-execution time.

[0036] A third aspect of an embodiment of the present application provides an interface call control device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of any method described in the first aspect when executing the computer program.

[0037] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method described in any one of the first aspects are implemented.

[0038] Compared with the prior art, the embodiments of the present application have the following beneficial effects: the present application monitors the execution result of the interface call task, and when it is detected that the state of the interface call task is a call failure, the re-execution time of the interface call task is determined according to a preset retry frequency, the re-executed interface call task is inserted into the interface call task queue, and the interface call task is read and executed from the interface call task queue according to the re-execution time. For different application scenarios, when the interface call task is repeatedly attempted at different frequency rhythms, only the retry frequency needs to be input to automatically repeat the execution of the interface call task, which is conducive to reducing the workload of developers and improving the efficiency of rapid iterative development. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0040] Figure 1 This is a schematic diagram of an implementation scenario of a control method for interface calling provided in an embodiment of the present application;

[0041] Figure 2 This is a schematic diagram of an implementation flow of a control method for interface calling provided in an embodiment of the present application;

[0042] Figure 3 It is a schematic diagram of an implementation flow of determining the re-execution time of the interface call task provided by an embodiment of the present application;

[0043] Figure 4 It is a schematic diagram of an implementation flow of determining the position where an interface call task is inserted into a task queue provided by an embodiment of the present application;

[0044] Figure 5 It is a schematic diagram of implementing an interface call task queue inserted into an interface call task for re-execution provided by an embodiment of the present application;

[0045] Figure 6 It is a schematic diagram of an implementation process of re-executing an interface call task provided by an embodiment of the present application;

[0046] Figure 7 is a schematic diagram of a control device for interface calling provided by an embodiment of the present application;

[0047] Figure 8 It is a schematic diagram of a control device for interface calls provided in an embodiment of the present application. DETAILED DESCRIPTION

[0048] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.

[0049] In order to illustrate the technical solution described in this application, a specific embodiment is provided below for illustration.

[0050] Figure 1 The following is a schematic diagram of an implementation scenario of an interface call control method provided in an embodiment of the present application. Figure 1As shown, in this implementation scenario, a caller (or calling subsystem) and a callee (called subsystem) are included. Wherein, the caller can send a request for an interface call task to the callee, and after the callee receives the task request for the interface call, the callee performs a calculation process on the parameter according to the parameter in the task request. After the callee completes the calculation process on the parameter, the response of the interface call task can be returned to the caller. In this case, the caller successfully receives the response of the interface call task of the callee, and the execution result of the interface call task is a successful call. When the callee handles an exception, the caller may receive a response that is not returned by the callee. At this time, in different application scenarios, different waiting strategies may be required, such as the interface call task may need to be executed according to different repetition execution frequencies. For different application scenarios, developers usually need to develop corresponding codes to execute the repetition call operation, which is not conducive to improving development efficiency.

[0051] In order to solve the above problems, this application proposes a control method for interface calling, such as Figure 2 As shown, the method includes:

[0052] In S201, the execution result of the interface calling task is monitored.

[0053] When the caller initiates an interface call task to the callee, there may be exceptions in the execution of the interface call task. For example, the exceptions may include logic processing exceptions, network errors, address errors, etc. When the above exceptions occur, the callee may not be able to return the parameter calculation processing results, or may return incorrect calculation processing results.

[0054] The execution result of the interface call task may include a successful call and an abnormal failure. When it is detected that the execution result of the interface call task is a call failure, it may include that no response to the interface call task of the called party is received within the set time period, that is, no interface call data is returned. The reason for the interface call failure may be a logic processing exception, a network error, or an address error of the called interface. Alternatively, in a possible implementation, the situation of the interface call failure may also include failure to receive response data in the correct format. For example, the received response data can be compared with the type or format of the standard response data. If the data type or format is obviously inconsistent, it can be considered that the execution result of the interface call task is a call failure.

[0055] When the caller initiates an interface call, the interface call tool corresponding to the method described in the embodiment of the present application can be triggered, and the execution status of the interface call task can be monitored by running the interface call tool. When the interface call task is executed normally, the interface call tool can stop monitoring the execution result of the interface call task.

[0056] In S202, when the execution result of the interface calling task is a call failure, the re-execution time of the interface calling task is determined according to a preset retry frequency.

[0057] In the embodiment of the present application, if the execution result of the interface call task is a successful call, it means that the current interface call task is proceeding normally, and there is no need to repeat the interface call task. If the execution result of the interface call task is a call failure, if the data of the interface call is very important to the service or application, it may be necessary to repeat the interface call task at a preset rhythm frequency until the interface call task succeeds, or until the number of repeated executions of the interface call task reaches a predetermined number of times, or until the duration of repeated executions of the interface call task reaches a predetermined duration.

[0058] Before the interface call task is executed, the user's setting information for the retry frequency can be received. The setting information can be that if the interface call fails, the interface call task is repeatedly executed according to a fixed retry frequency. The retry frequency can be a fixed value, for example, the interface call task can be repeatedly executed at a frequency of 10 times / minute.

[0059] Alternatively, the retry frequency may be a variable value. The retry frequency may be determined according to the number of executions. For example, in a possible implementation, the retry frequency may be increased linearly according to a predetermined ratio. For example, the time interval of the retry after the first retry failure may be 5 seconds, the time interval of the retry after the second retry failure may be 10 seconds, and the time interval of the retry after the third retry failure may be 15 seconds.

[0060] Not limited to this, other forms of nonlinear changes may also be included, or the frequency of repeated attempts may be determined according to the task state of the callee. For example, when the usage rate of the processor of the callee is greater than a predetermined value, the frequency of repeated attempts is reduced according to the increase of the usage rate of the processor. If the usage rate of the processor of the callee is less than a predetermined value, the frequency of repeated attempts is increased according to the decrease of the usage rate of the processor. When the usage rate of the processor of the callee is greater than a second predetermined value and less than a first predetermined value, the frequency of repeated attempts is determined to be a fixed value, wherein the first predetermined value is greater than the second predetermined value. For example, the first predetermined value may be 40%, and the second predetermined value may be 60%. When the usage rate of the processor of the callee is less than 40%, the frequency of repeated attempts may be increased according to the decrease of the usage rate of the processor. When the usage rate of the processor of the callee is greater than 60%, the frequency of repeated attempts may be reduced according to the increase of the usage rate of the processor. When the usage rate of the processor of the callee is greater than 40% and less than 60%, repeated attempts may be performed according to a fixed frequency of repeated attempts, such as a frequency of repeated attempts of 6 times / minute.

[0061] When determining the re-execution time of the interface call task according to the preset retry frequency, the following can be done: Figure 3 As shown, including:

[0062] In S301, the repetition execution interval of the interface call task is determined according to a preset repetition attempt frequency.

[0063] When the repetition frequency is a fixed frequency, the repetition interval corresponding to the repetition frequency can be calculated according to the inverse relationship between the frequency and the period. For example, if the repetition frequency f = 10 times / minute, the repetition interval, i.e., the repetition period T = 1 / f = 1 / 10 minute, i.e., 6 seconds.

[0064] When the retry frequency is a variable frequency, the retry frequency can be proportional to the number of retry attempts. For example, the retry frequency can be expressed as: f=10 / x, where x represents the number of retry attempts. As the number of executions increases, the execution frequency gradually decreases. According to the determined execution frequency, the retry interval can be obtained, that is, the time interval between two executions of the interface call task.

[0065] In S302, the re-execution time of the interface call task is determined according to the time when the interface call fails and the re-execution interval.

[0066] After determining the re-execution time, the re-execution time of the interface call task can be calculated by combining the latest interface call failure time detected at the current time. That is, the re-execution time of the interface call task is obtained by adding the repeated execution interval to the interface call failure time.

[0067] For example, the time when the latest interface call failure is detected is T1, and the re-execution interval is T2. Then, the re-execution time after the latest interface call failure is detected is T1+T2.

[0068] In S203, the interface call task is inserted into an interface call task queue according to the determined re-execution time.

[0069] After determining the re-execution time of the interface call task, the interface call task can be inserted into the queue of interface call tasks that the callee needs to execute. In a possible implementation, the queue of the interface call task can also include other tasks that need to be executed, which is not limited in this application. According to the re-execution time, the position of the interface call task to be inserted into the task queue is determined, which can be specifically as follows: Figure 4 As shown, including:

[0070] In S401, the re-execution time is compared with the execution time of the interface call task in the interface call task queue.

[0071] The interface call task queue stored in the task queue may be a queue of a binary heap structure. Figure 5 A schematic diagram of inserting a re-executed interface call task into an interface call task queue provided by an embodiment of the present application, in Figure 5 In the example, each task corresponds to an execution time. In the same branch, the node corresponding to the task with an earlier execution time is located at the parent node of the node corresponding to the task with a later execution time, that is, the task with an earlier execution time is located at the parent node or above the parent node of the task with a later execution time.

[0072] In S402, the position of the re-executed interface call task in the interface call task queue is determined according to a comparison result between the re-execution time and the execution time of the interface call task in the interface call task queue.

[0073] A new re-execution time can be determined according to the frequency of repeated attempts, and a new node can be generated by the new re-executed interface call task. The interface call task corresponding to the node is the re-executed interface call task.

[0074] The process of inserting the re-executed interface call task into the interface call task queue may include:

[0075] A1, inserting the interface call task to be executed again into the end of the leaf node of the queue of the binary heap.

[0076] like Figure 5 The left figure shows the arrangement state of the current interface call task queue. When a new interface call task to be executed again is added, a node corresponding to the interface call task to be executed again can be generated, such as node 9. The leaf nodes in the current queue include nodes 1, 2, 5, 4 and 3, and the node 9 can be inserted into any leaf node, such as the end of node 5.

[0077] A2, compare the re-execution time with the execution time of the interface call task of the leaf node. If the re-execution time is earlier than the execution time of the interface call task of the leaf node, swap the position of the re-executed interface call task and the leaf node.

[0078] After the interface call task to be executed again is inserted into the end of the leaf node, or connected to the end of the leaf node, the execution time of the inserted node can be compared with the interface call task corresponding to the inserted leaf node. If the execution time of the inserted node 9 is earlier than that of the inserted leaf node 5, the positions of the leaf node 5 and the inserted node 9 are swapped. Figure 5 The schematic diagram of the binary heap structure is shown in the figure.

[0079] A3, compares the execution time of the interface call task to be executed again with the execution time of the interface call task of the current parent node of the interface call task to be executed again. If the re-execution time is earlier than the execution time of the interface call task of the parent node of the interface call task to be executed again, swaps the position of the interface call task to be executed again and the parent node of the interface call task to be executed again until the re-execution time is later than the execution time of the interface call task of the parent node of the interface call task to be executed again, or until the execution time of the interface call task is later than the execution time of the interface call task of the leaf node.

[0080] like Figure 5 As shown in the middle figure, after the inserted node 9 exchanges positions with node 5, the execution time of node 9 can be further compared with the parent node of the node at the current position, that is, node 8. If the execution time of node 9 (that is, the execution time of the interface call task of node 9) is earlier than that of node 8, node 9 is further controlled to exchange positions with node 8, and the following is obtained: Figure 5 The binary heap structure shown in the right figure. Further compare the execution time of node 9 of the interface call task to be executed again and its parent node, that is, node 10. If the execution time of node 9 is later than the execution time of node 10, the insertion of the node of the interface call task to be executed again is completed.

[0081] In a possible implementation, if the inserted node is smaller than a leaf node, there is no need to exchange the node position, and the position of the inserted node can be determined directly.

[0082] In addition, the task queue in the embodiment of the present application can be a limited queue, that is, the number of tasks in the task queue is limited. When the number of tasks in the task queue reaches a predetermined set value, that is, the maximum capacity of the task queue, then the task queue can be expanded. Wherein, the mode of the expansion process can be expanded according to a predetermined increment. For example, the capacity of 500 tasks can be set to be increased each time. Or, the capacity of the task queue can also be increased according to a predetermined multiple. For example, when the number of tasks in the task queue reaches the capacity of the task queue, the capacity is doubled, so that the task that is repeatedly executed can be added to the task queue.

[0083] In S204, the interface call task is read from the interface call task queue and executed according to the re-execution time.

[0084] In the generation Figure 5 After the binary heap structure queue is shown, as time changes, the called party or the called subsystem will pre-read the execution time of the interface call task at the top of the heap or the root node. When the system time is the same as the time of the interface call task, the interface call task at the top of the heap is extracted from the queue of the binary heap structure. At this time, since the interface call task at the top of the heap has been read out, the queue of the binary heap structure needs to be updated, which may specifically include:

[0085] B1: Execute the interface call task of the root node according to the pre-recorded execution time of the interface call task of the root node, and select a leaf node of the current binary heap to move to the position of the root node.

[0086] like Figure 6 The figure shows a schematic diagram of the implementation process of re-executing the interface call task. Insert the queue of the binary heap structure of the interface call task to be executed again. When the node 10 is called out for execution, any child node in the binary heap can be used as the heap point of the binary heap, such as Figure 5 Node 5 in is used as the top of the binary heap.

[0087] B2: Compare the execution time of the interface call task of the selected leaf node with the interface call task of the child node at the current position of the leaf node. If the execution time of the interface call task of the selected leaf node is later than the execution time of the interface call task of the child node at the current position of the leaf node, select the child node with an earlier execution time and exchange its position with the current position of the leaf node until the execution time of the selected leaf node is earlier than the execution time of the task of the child node of the leaf node, obtain the updated binary heap list, and determine the execution time of the interface call task of the root node in the updated list.

[0088] After the leaf node is used as the new top of the heap, the execution time of the selected leaf node needs to be compared with the child nodes at the top of the heap, as well as the execution time of the child nodes themselves. For example, Figure 6 As shown, the current top node 5 of the heap is compared with the child node 9 and the node 7. The execution time of node 5 is later than that of node 7, the execution time of node 5 is later than that of node 9, and the execution time of node 7 is later than that of node 9. Then, the positions of node 5 and node 9 can be swapped. After swapping positions, node 5 can be further compared with its child nodes. According to the comparison result of the execution time, the positions of node 5 and node 8 are swapped. Since the node 5 after the exchange of positions is a leaf node, the update of the binary heap is completed, the new top of the heap is determined to be node 9, and the execution time of the interface call task to be executed again of node 9 is determined.

[0089] B3: When the determined execution time arrives, execute the interface calling task of the root node.

[0090] like Figure 6 As shown, when the time for executing the interface call again corresponding to the node 9 arrives, the interface call task corresponding to the node 9 is read and executed. In some embodiments, the interface call task read for the second time may not be the interface call task to be executed again. After reading the interface call task for the second time, the binary heap can be updated to obtain a new top node of the heap, and the new top interface call task is executed according to the execution time of the new top node of the heap until the interface call task to be executed again is executed.

[0091] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0092] Figure 7 A schematic diagram of a control device for interface calling provided in an embodiment of the present application, such as Figure 7 As shown, the device comprises:

[0093] The status monitoring unit 701 is used to monitor the execution result of the interface calling task;

[0094] The re-execution time determination unit 702 is used to determine the re-execution time of the interface call task according to a preset retry frequency when the execution result of the interface call task is a call failure;

[0095] The queue updating unit 703 is used to insert the interface calling task into the interface calling task queue according to the determined re-execution time;

[0096] The task execution unit 704 is used to read and execute the interface call task from the interface call task queue according to the re-execution time.

[0097] Figure 7 The interface shown in the figure calls the control device, and Figure 2 The interface shown corresponds to the control method called.

[0098] Figure 8 Schematic diagram of a control device for interface calls provided by an embodiment of the present application. Figure 8 As shown, the interface call control device 8 of this embodiment includes: a processor 80, a memory 81, and a computer program 82 stored in the memory 81 and executable on the processor 80, such as an interface call control program. When the processor 80 executes the computer program 82, the steps in the above-mentioned control method embodiments of the interface call are implemented. Alternatively, when the processor 80 executes the computer program 82, the functions of each module / unit in the above-mentioned device embodiments are implemented.

[0099] Exemplarily, the computer program 82 may be divided into one or more modules / units, which are stored in the memory 81 and executed by the processor 80 to complete the present application. The one or more modules / units may be a series of computer program instruction segments capable of completing specific functions, which are used to describe the execution process of the computer program 82 in the control device 8 called by the interface.

[0100] The control device 8 called by the interface can be a computing device such as a desktop computer, a notebook, a PDA, and a cloud server. The control device called by the interface can include, but is not limited to, a processor 80 and a memory 81. Those skilled in the art can understand that Figure 8 It is only an example of the control device 8 called by the interface and does not constitute a limitation of the control device 8 called by the interface. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the control device called by the interface may also include input and output devices, network access devices, buses, etc.

[0101] The processor 80 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0102] The memory 81 may be an internal storage unit of the control device 8 called by the interface, such as a hard disk or memory of the control device 8 called by the interface. The memory 81 may also be an external storage device of the control device 8 called by the interface, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the control device 8 called by the interface. Further, the memory 81 may also include both an internal storage unit and an external storage device of the control device 8 called by the interface. The memory 81 is used to store the computer program and other programs and data required by the control device called by the interface. The memory 81 may also be used to temporarily store data that has been output or is to be output.

[0103] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.

[0104] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0105] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0106] In the embodiments provided in the present application, it should be understood that the disclosed devices / terminal equipment and methods can be implemented in other ways. For example, the device / terminal equipment embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0107] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0108] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0109] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the process in the above-mentioned embodiment method, and can also be completed by hardware related to computer program instructions. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.

[0110] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. A method for controlling interface calls, characterized in that: The method comprises: Monitor the execution results of the interface call tasks; When the execution result of the interface call task is a call failure, determining the re-execution time of the interface call task according to a preset retry frequency; Inserting the interface call task into the interface call task queue according to the determined re-execution time; Reading and executing the interface call task from the interface call task queue according to the re-execution time; The interface call task queue is a list of a binary heap structure, and according to the determined re-execution time, the interface call task is inserted into the interface call task queue, including: Compare the re-execution time with the execution time of the interface call task in the interface call task queue; Inserting the re-executed interface call task into the end of the leaf node of the queue of the binary heap; Compare the re-execution time with the execution time of the interface call task of the leaf node, and if the re-execution time is earlier than the execution time of the interface call task of the leaf node, swap the position of the re-executed interface call task and the leaf node; Compare the execution time of the re-executed interface call task with the execution time of the interface call task of the current parent node of the re-executed task; if the re-execution time is earlier than the execution time of the interface call task of the parent node of the re-executed interface call task, swap the positions of the re-executed interface call task and the parent node of the re-executed interface call task until the re-execution time is later than the execution time of the interface call task of the parent node of the re-executed interface call task, or until the execution time of the interface call task is later than the execution time of the interface call task of the leaf node.

2. The method according to claim 1, characterized in that Determining the re-execution time of the interface call task according to a preset repetition attempt frequency includes: Determining a repetitive execution interval of the interface call task according to a preset repetitive attempt frequency; The re-execution time of the interface call task is determined according to the time when the interface call fails and the repeated execution interval.

3. The method according to claim 2, characterized in that Before determining the repetitive execution interval of the interface call task according to the repetitive attempt frequency, the method further includes: When the usage rate of the processor of the callee is greater than a first predetermined value, reducing the repetition frequency according to an increase in the usage rate of the processor; When the usage rate of the processor of the callee is less than a second predetermined value, increasing the retry frequency according to the decrease in the usage rate of the processor; When the usage rate of the processor of the called party is greater than a second predetermined value and less than a first predetermined value, the retry frequency is determined to be a fixed value, wherein the first predetermined value is greater than the second predetermined value.

4. The method according to claim 1, characterized in that Reading and executing the interface call task from the interface call task queue according to the re-execution time includes: Execute the interface call task of the root node according to the pre-recorded execution time of the interface call task of the root node, and select a leaf node of the current binary heap to move to the position of the root node; Compare the execution time of the interface call task of the selected leaf node with the interface call task of the child node at the current position of the leaf node. If the execution time of the interface call task of the selected leaf node is later than the execution time of the interface call task of the child node at the current position of the leaf node, select the child node with an earlier execution time to exchange positions with the current position of the leaf node, until the execution time of the selected leaf node is earlier than the execution time of the task of the child node of the leaf node, obtain an updated binary heap list, and determine the execution time of the interface call task of the root node in the updated list; When the determined execution time arrives, the interface calling task of the root node is executed.

5. The method according to claim 1, characterized in that Before inserting the interface call task into the interface call task queue, the method further includes: Determining whether the number of tasks in the task queue has reached a preset queue capacity; When the number of tasks in the task queue reaches the queue capacity, the task queue is expanded.

6. A control device for interface calling, characterized in that: The device comprises: A status monitoring unit, used to monitor the execution results of the interface call task; A re-execution time determination unit, used to determine the re-execution time of the interface call task according to a preset repetition attempt frequency when the execution result of the interface call task is a call failure; A queue updating unit, configured to insert the interface call task into an interface call task queue according to the determined re-execution time; A task execution unit, configured to read and execute the interface call task from the interface call task queue according to the re-execution time; The interface call task queue is a list of a binary heap structure, and the queue update unit is used to compare the re-execution time with the execution time of the interface call task in the interface call task queue; insert the re-executed interface call task into the end of the leaf node of the queue of the binary heap; compare the re-execution time with the execution time of the interface call task of the leaf node, if the re-execution time is earlier than the execution time of the interface call task of the leaf node, then swap the position of the re-executed interface call task and the leaf node; compare the execution time of the re-executed interface call task with the execution time of the interface call task of the current parent node of the re-executed task, if the re-execution time is earlier than the execution time of the interface call task of the parent node of the re-executed interface call task, then swap the position of the re-executed interface call task with the parent node of the re-executed interface call task, until the re-execution time is later than the execution time of the interface call task of the parent node of the re-executed interface call task, or until the execution time of the interface call task is later than the execution time of the interface call task of the leaf node.

7. An interface call control device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.

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

Citation Information

Patent Citations

  • Business processing method and device, server and medium

    CN113760500A

  • Method and device for dynamically adjusting message receiving rate

    CN113765813A