Interface calling methods and devices, storage media
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-05
- Publication Date
- 2026-08-14
AI Technical Summary
[0004]为了解决上述技术问题或者至少部分地解决上述技术问题,本公开的实施例提供了一种接口调用方法及装置、存储介质,以至少解决现有技术中,在接口调用中,接口的调用方式是固定的,容易导致任务处理速度慢甚至失败的问题
[0017]本公开实施例提供的上述技术方案与现有技术相比至少具有如下优点的部分或全部:在获取目标接口的配置信息和目标设备的服务状态信息的情况下,通过所述配置信息和所述服务状态信息中的至少一种信息确定所述目标接口的接口调用方式;在确定所述目标接口的接口调用方式的情况下,将指示所述接口调用方式的标记信息发送给接口被调端,以根据所述接口调用方式调用所述目标接口。采用上述技术手段,解决现有技术中,在接口调用中,接口的调用方式是固定的,容易导致任务处理速度慢甚至失败的问题。
Smart Images

Figure CN115904549B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of cloud computing technology, and in particular to an interface calling method and apparatus, and a storage medium. Background Technology
[0002] In API calls, the decision of whether to use synchronous or asynchronous calls is established during the API writing process. Synchronous calls are blocking calls; the caller waits for the called endpoint to complete its task before receiving a response. During this time, the caller is not allowed to execute the next task. Asynchronous calls, on the other hand, use a message or event-like mechanism. The called endpoint actively notifies the caller when it receives a message or an event occurs. During this time, the caller does not need to wait for a response and is allowed to execute the next task. A fixed API calling method can lead to blocking when the device is busy, causing task requests to be processed, tasks to stall, or even fail. However, if all APIs use asynchronous calls, multiple asynchronous calls can slow down task processing when the device is idle. If network fluctuations also occur, multiple API calls can lead to errors.
[0003] In the process of realizing the present invention, the inventors discovered that the related technology has at least the following technical problems: in interface calls, the calling method of the interface is fixed, which can easily lead to slow task processing speed or even failure. Summary of the Invention
[0004] In order to solve the above-mentioned technical problems, or at least partially solve the above-mentioned technical problems, the embodiments of this disclosure provide an interface calling method and apparatus, and a storage medium, so as to at least solve the problem in the prior art that the interface calling method is fixed, which easily leads to slow task processing speed or even failure.
[0005] The purpose of this disclosure is achieved through the following technical solution:
[0006] In a first aspect, embodiments of this disclosure provide an interface invocation method, comprising: obtaining configuration information of a target interface and service status information of a target device; determining an interface invocation mode of the target interface through at least one of the configuration information and the service status information; and sending a marker indicating the interface invocation mode to the interface called end to invoke the target interface according to the interface invocation mode.
[0007] Furthermore, obtaining the configuration information of the target interface and the service status information of the target device includes: receiving an interface call request sent by the interface caller, and determining the input parameters of the target interface and the Internet Protocol address of the target device based on the interface call request; obtaining the configuration information of the target interface based on the input parameters; and obtaining the service status information of the target device from the device monitoring system based on the Internet Protocol address.
[0008] Further, obtaining the service status information of the target device from the device monitoring system based on the Internet Protocol address includes: monitoring the service status information of multiple devices in real time through the device monitoring system and storing the service status information of the multiple devices in the monitoring system database of the device monitoring system; and obtaining the service status information of the target device from the monitoring system database based on the Internet Protocol address.
[0009] Further, determining the interface invocation method of the target interface through at least one of the configuration information and the service status information includes: determining whether the target interface is dynamically invoked through the dynamic invocation configuration information in the configuration information; if the target interface is not dynamically invoked, determining the interface invocation method of the target interface through the interface invocation type information in the configuration information; if the target interface is dynamically invoked, determining the interface invocation method of the target interface through the asynchronous invocation threshold in the configuration information and the service status information.
[0010] Furthermore, when the target interface is dynamically invoked, the interface invocation method of the target interface is determined by the asynchronous invocation threshold in the configuration information and the service status information, including: when the service percentage is greater than the asynchronous invocation threshold, the interface invocation method is determined to be an asynchronous invocation method, wherein the service status information includes the service percentage, which represents the degree of device busyness; when the service percentage is less than the asynchronous invocation threshold, the interface invocation method is determined to be a synchronous invocation method.
[0011] Further, sending the marker information indicating the interface invocation method to the interface called end to invoke the target interface according to the interface invocation method includes: when the marker information indicates that the interface invocation method is a synchronous invocation method, instructing the interface called end to execute a business processing task and returning the result of the business processing task to the interface calling end; when the marker information indicates that the interface invocation method is an asynchronous invocation method, determining in real time whether the service percentage is less than the asynchronous invocation threshold, and if the service percentage is less than the asynchronous invocation threshold, instructing the interface called end to execute a business processing task and returning the result of the business processing task to the interface calling end; wherein, the service status information includes the service percentage, which represents the degree of device busyness, and the configuration information includes the asynchronous invocation threshold.
[0012] Furthermore, when the marking information indicates that the interface call method is an asynchronous call method, it is determined in real time whether the service percentage is less than the asynchronous call threshold. If the service percentage is less than the asynchronous call threshold, the interface called end is instructed to execute a business processing task, and the result of the business processing task is returned to the interface caller. This includes: setting an interface task, wherein the interface task is used to determine in real time whether the service percentage is less than the asynchronous call threshold, and if the service percentage is less than the asynchronous call threshold, instructing the interface called end to execute the business processing task, and returning the result of the business processing task to the interface caller; or placing the business processing task into a message queue, wherein the message queue is used to determine in real time whether the service percentage is less than the asynchronous call threshold, and if the service percentage is less than the asynchronous call threshold, instructing the interface called end to execute the business processing task, and returning the result of the business processing task to the interface caller.
[0013] Furthermore, after sending the marker information indicating the interface invocation method to the interface called end so as to invoke the target interface according to the interface invocation method, the method further includes: sending the result information of invoking the target interface according to the interface invocation method to the interface calling end through a callback interface; instructing the interface caller to process the result information in an asynchronous manner.
[0014] Secondly, embodiments of this disclosure provide an interface invocation apparatus, comprising: an acquisition module, configured to acquire configuration information of a target interface and service status information of a target device; a determination module, configured to determine an interface invocation method of the target interface through at least one of the configuration information and the service status information; and an invocation module, configured to send marker information indicating the interface invocation method to an interface called end, so as to invoke the target interface according to the interface invocation method.
[0015] Thirdly, embodiments of this disclosure provide an electronic device. The electronic device includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, communication interface, and memory communicate with each other via the communication bus; the memory stores computer programs; and the processor, when executing the program stored in the memory, implements the interface calling method or image processing method as described above.
[0016] Fourthly, embodiments of this disclosure provide a computer-readable storage medium. The computer-readable storage medium stores a computer program that, when executed by a processor, implements the interface calling method or image processing method as described above.
[0017] Compared with the prior art, the technical solutions provided in this disclosure have at least some or all of the following advantages: When the configuration information of the target interface and the service status information of the target device are obtained, the interface invocation method of the target interface is determined through at least one of the configuration information and the service status information; when the interface invocation method of the target interface is determined, a marker indicating the interface invocation method is sent to the interface called end to invoke the target interface according to the interface invocation method. By employing the above technical means, the problem in the prior art where the interface invocation method is fixed, which easily leads to slow task processing speed or even failure, is solved. Attached Figure Description
[0018] The accompanying drawings, which are incorporated in and form a part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure.
[0019] To more clearly illustrate the technical solutions in the embodiments of this disclosure or the prior art, the accompanying drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, those skilled in the art can obtain other drawings based on these drawings without creative effort.
[0020] Figure 1 This schematically illustrates a hardware structure block diagram of a computer terminal for an interface calling method according to an embodiment of the present disclosure;
[0021] Figure 2 A flowchart illustrating an interface invocation method according to an embodiment of this disclosure is shown schematically.
[0022] Figure 3 The flowchart illustrating an embodiment of the present disclosure is shown in the form of obtaining configuration information of a target interface and service status information of a target device.
[0023] Figure 4 The schematic diagram illustrates a flowchart of an interface invocation method according to an embodiment of the present disclosure;
[0024] Figure 5 This schematic diagram illustrates a structural block diagram of an interface calling device according to an embodiment of the present disclosure;
[0025] Figure 6 The schematic diagram illustrates a structural block diagram of an electronic device provided in an embodiment of the present disclosure. Detailed Implementation
[0026] The present disclosure will be described in detail below with reference to the accompanying drawings and embodiments. It should be noted that, unless otherwise specified, the embodiments and features in the embodiments of the present disclosure can be combined with each other.
[0027] It should be noted that the terms "first," "second," etc., in the specification, claims, and drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0028] The methods and embodiments provided in this disclosure can be executed on a computer terminal or similar computing device. Taking running on a computer terminal as an example, Figure 1 The diagram schematically illustrates a hardware structure block diagram of a computer terminal for an interface calling method according to an embodiment of this disclosure. For example... Figure 1 As shown, a computer terminal may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 (which may include, but is not limited to, a microprocessor unit (MPU) or a programmable logic device (PLD)) and a memory 104 for storing data are also included. Optionally, the computer terminal may further include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that… Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the computer terminal described above. For example, the computer terminal may also include components that are more complex than those described above. Figure 1 The more or fewer components shown, or having the same Figure 1 Equivalent functions or ratios shown Figure 1The functions shown have more different configurations.
[0029] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the interface calling method in this embodiment. The processor 102 executes various functional applications and data processing by running the computer programs stored in the memory 104, thus implementing the above-described method. The memory 104 may include high-speed random access memory and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to a computer terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0030] The transmission device 106 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider for the computer terminal. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 may be a Radio Frequency (RF) module used for wireless communication with the Internet.
[0031] This embodiment provides an interface invocation method. Figure 2 A flowchart illustrating an embodiment of the interface invocation method of this disclosure is shown, such as... Figure 2 As shown, the process includes the following steps:
[0032] Step S202: Obtain the configuration information of the target interface and the service status information of the target device;
[0033] Step S204: Determine the interface invocation method of the target interface through at least one of the configuration information and the service status information;
[0034] Step S206: Send the tag information indicating the interface calling method to the interface called end, so as to call the target interface according to the interface calling method.
[0035] It should be noted that the embodiments disclosed herein are applicable to cloud-local interaction processes, which can involve the cloud calling the local interface or the local interface calling the cloud interface. In other words, the cloud can act as both the interface caller and the interface recipient; the local machine can act as both the interface caller and the interface recipient.
[0036] This disclosure provides a method for determining the interface invocation mode of a target interface by obtaining configuration information of the target interface and service status information of the target device, using at least one of the configuration information and service status information. Once the interface invocation mode is determined, a marker indicating the invocation mode is sent to the interface-called terminal to invoke the target interface according to the specified invocation mode. This technical approach solves the problem in the prior art where the interface invocation mode is fixed, which can easily lead to slow task processing or even failure.
[0037] Figure 3 This illustration schematically shows a flowchart of an embodiment of the present disclosure for obtaining configuration information of a target interface and service status information of a target device, such as... Figure 3 As shown, the process includes the following steps:
[0038] S302: Receive an interface call request sent by the interface call terminal, and determine the input parameters of the target interface and the Internet Protocol address of the target device according to the interface call request;
[0039] S304: Obtain the configuration information of the target interface based on the input parameters;
[0040] Alternatively, the configuration information of the target interface can be obtained based on the input parameters, or the configuration information of the target interface can be determined based on the input parameters and then obtained.
[0041] S306: Obtain the service status information of the target device from the device monitoring system based on the Internet Protocol address.
[0042] This embodiment of the disclosure can obtain the configuration information of the target interface and the service status information of the target device through the above-described technical means, and then determine the interface calling method of the target interface based on the configuration information and service status information. This solves the problem in the prior art that the interface calling method is fixed, which leads to slow task processing speed or even failure.
[0043] In one optional embodiment, obtaining the service status information of the target device from the device monitoring system according to the Internet Protocol address includes: monitoring the service status information of multiple devices in real time through the device monitoring system and storing the service status information of the multiple devices in the monitoring system database of the device monitoring system; and obtaining the service status information of the target device from the monitoring system database according to the Internet Protocol address.
[0044] The equipment monitoring system monitors the service status information of multiple devices in real time and stores the monitored service status information of the multiple devices in the monitoring system database of the equipment monitoring system. The service status information is information about the operation or working status of the devices.
[0045] Table 1 shows the data structure of the service status information of the target device.
[0046] Fields describe Server_type Service type (e.g., percentage of running memory) Server_threshold Service threshold (e.g., 90%) Is_alert Alarm? Alert_type Alarm Types …. ….
[0047] It should be noted that when the service type exceeds the service threshold, it is necessary to determine whether an alarm is needed and what type of alarm is required.
[0048] With the service status information of the multiple devices obtained from monitoring stored in the monitoring system database of the device monitoring system, the service status information of the target device is retrieved from the monitoring system database according to the Internet Protocol address. Here, the multiple devices include the target device, and one Internet Protocol address corresponds to one device.
[0049] In an optional embodiment, before monitoring the service status information of multiple devices in real time through the device monitoring system, the method further includes: receiving a monitoring instruction sent by a target object, and determining multiple devices that the device monitoring system needs to monitor in real time based on the monitoring instruction; or, determining multiple devices that the device monitoring system needs to monitor in real time based on the default settings of the device monitoring system.
[0050] In step S204, determining the interface invocation method of the target interface using at least one of the configuration information and the service status information includes: determining whether the target interface is dynamically invoked using dynamic invocation configuration information in the configuration information; if the target interface is not dynamically invoked, determining the interface invocation method of the target interface using interface invocation type information in the configuration information; if the target interface is dynamically invoked, determining the interface invocation method of the target interface using asynchronous invocation threshold in the configuration information and the service status information.
[0051] In other words, if the target interface is not dynamically invoked, the interface invocation method can be determined solely through the configuration information: the dynamic invocation configuration information determines that the target interface is not dynamically invoked; the interface invocation type information in the configuration information determines the interface invocation method. The interface invocation method includes asynchronous and synchronous invocation methods. If the target interface is dynamically invoked, the interface invocation method needs to be determined through both the configuration information and the service status information: the dynamic invocation configuration information determines that the target interface is dynamically invoked; the asynchronous invocation threshold in the configuration information and the service status information determine the interface invocation method.
[0052] Table 2 shows the data structure of the target interface configuration information.
[0053]
[0054]
[0055] In an optional embodiment, when the target interface is dynamically invoked, the interface invocation method of the target interface is determined by the asynchronous invocation threshold in the configuration information and the service status information, including: if the service percentage is greater than the asynchronous invocation threshold, the interface invocation method is determined to be an asynchronous invocation method, wherein the service status information includes the service percentage, which represents the degree of device busyness; if the service percentage is less than the asynchronous invocation threshold, the interface invocation method is determined to be a synchronous invocation method.
[0056] Optionally, the service percentage can also be a percentage of the device's running memory occupancy. The interface calling method is determined by comparing the running memory occupancy with the asynchronous call threshold: if the running memory occupancy is greater than the asynchronous call threshold, the interface calling method is determined to be an asynchronous calling method; if the running memory occupancy is less than the asynchronous call threshold, the interface calling method is determined to be a synchronous calling method.
[0057] The above-mentioned technical means can realize dynamic calling of interfaces, which solves the problem that the calling method of interfaces is fixed in the existing technology, resulting in slow task processing speed or even failure.
[0058] It should be noted that whether dynamic invocation is enabled can be adjusted by the target object based on specific circumstances. If an error occurs during the query, such as a service outage or server crash, the interface invocation type information in the configuration details will be used as the default interface invocation method.
[0059] In step S206, a marker indicating the interface invocation method is sent to the interface called end to invoke the target interface according to the interface invocation method. This includes: if the marker indicates that the interface invocation method is synchronous, instructing the interface called end to execute a business processing task and returning the result of the business processing task to the interface calling end; if the marker indicates that the interface invocation method is asynchronous, determining in real time whether the service percentage is less than the asynchronous invocation threshold, and if the service percentage is less than the asynchronous invocation threshold, instructing the interface called end to execute a business processing task and returning the result of the business processing task to the interface calling end; wherein, the service status information includes the service percentage, which represents the degree of device busyness, and the configuration information includes the asynchronous invocation threshold.
[0060] This embodiment of the disclosure adds an interface call management system. The interface call management system obtains the configuration information of the target interface and the service status information of the target device according to the interface call request sent by the interface caller. It determines the interface call method according to the configuration information and the service status information or one of the configuration information and the service status information. The interface called end then realizes the call to the target interface according to the interface call method determined by the interface call management system.
[0061] The interface call management system sends a flag indicating the interface call method to the interface callee. If the flag indicates a synchronous call method, the interface callee is instructed to execute a business processing task and return the result to the interface caller. If the flag indicates an asynchronous call method, the system continuously checks if the service percentage is less than the asynchronous call threshold. If the service percentage is less than the threshold (i.e., the target device is idle), the interface callee is instructed to execute a business processing task and return the result to the interface caller. If the service percentage is greater than the threshold, the target device is busy, and no processing is performed. The system continues to monitor and check if the service percentage is less than the threshold. If the service percentage is less than the threshold, the business processing task is processed.
[0062] It should be noted that when the marking information indicates that the interface call method is a synchronous call method, the result of executing the business processing task is directly returned to the interface caller; when the marking information indicates that the interface call method is an asynchronous call method, after instructing the interface called end to execute the business processing task, it is necessary to query the callback interface and return the result of executing the business processing task to the interface caller through the callback interface.
[0063] In an optional embodiment, when the marking information indicates that the interface call method is an asynchronous call method, it is determined in real time whether the service percentage is less than the asynchronous call threshold, and if the service percentage is less than the asynchronous call threshold, the interface called end is instructed to execute a business processing task, and the result of the business processing task is returned to the interface caller. This includes: setting an interface task, wherein the interface task is used to determine in real time whether the service percentage is less than the asynchronous call threshold, and if the service percentage is less than the asynchronous call threshold, instruct the interface called end to execute the business processing task, and return the result of the business processing task to the interface caller; or placing the business processing task into a message queue, wherein the message queue is used to determine in real time whether the service percentage is less than the asynchronous call threshold, and if the service percentage is less than the asynchronous call threshold, instruct the interface called end to execute the business processing task, and return the result of the business processing task to the interface caller.
[0064] This disclosure embodiment can set up an interface task. When the service percentage is less than the asynchronous call threshold, the interface task instructs the called end to execute a business processing task and returns the result of the business processing task to the interface caller. This disclosure embodiment can also directly place the business processing task into a message queue for processing. It should be noted that the message queue is a first-in, first-out (FIFO) task processing queue, which allows for processing business processing tasks in the order they are executed.
[0065] After executing step S206, that is, after sending the marker information indicating the interface calling method to the interface called end to call the target interface according to the interface calling method, the method further includes: sending the result information of calling the target interface according to the interface calling method to the interface calling end through a callback interface; instructing the interface caller to process the result information in an asynchronous manner.
[0066] It's important to note that all callback interfaces on the API caller side are asynchronous. This means that after the called end finishes processing its business logic, it transmits the result to the calling end via the callback interface. The calling end will always process the result and return a success message to the called end. The calling end decides when to process the result based on its own state. If the callback interface also supports both synchronous and asynchronous calls, it will create a circular dependency, slowing down the process. The callback interface needs to support configuration descriptions to prevent the recipient from failing to call the callback interface when returning a result. Additionally, the callback interface must support encryption.
[0067] Table 3 shows the configuration description information for the callback interface.
[0068] Fields describe Interface_name Interface Name Interface_param_type Interface parameter types …. ….
[0069] The information in Table 3 can be used to determine the interface name and parameter types of the callback interface.
[0070] To better understand the above technical solutions, this disclosure also provides an optional embodiment for explaining the above technical solutions.
[0071] Figure 4 The schematic diagram illustrates a flowchart of an interface invocation method according to an embodiment of this disclosure, such as... Figure 4 As shown, the process includes the following steps:
[0072] S402: Receive the interface call request sent by the interface caller;
[0073] S404: Determine the input parameters of the target interface and the Internet Protocol address of the target device according to the interface call request; obtain the configuration information of the target interface according to the input parameters; and obtain the service status information of the target device from the device monitoring system according to the Internet Protocol address.
[0074] S406: Determine the interface invocation method of the target interface through at least one of the configuration information and the service status information: determine whether the target interface is dynamically invoked through the dynamic invocation configuration information in the configuration information; if the target interface is not dynamically invoked, determine the interface invocation method of the target interface through the interface invocation type information in the configuration information; if the target interface is dynamically invoked, determine the interface invocation method of the target interface through the asynchronous invocation threshold in the configuration information and the service status information.
[0075] S408: Send the tag information indicating the interface calling method to the interface called end, and the interface called end determines whether the interface calling method is an asynchronous calling method;
[0076] S410: When the marking information indicates that the interface call method is synchronous call method, instruct the interface called end to perform business processing task and return the result of the business processing task to the interface call end;
[0077] S412: When the marking information indicates that the interface call method is an asynchronous call method, determine in real time whether the service percentage is less than the asynchronous call threshold, and if the service percentage is less than the asynchronous call threshold, instruct the interface called end to execute the business processing task, and return the result of the execution of the business processing task to the interface call end.
[0078] This disclosure provides a method for determining the interface invocation mode of a target interface by obtaining configuration information of the target interface and service status information of the target device, using at least one of the configuration information and service status information. Once the interface invocation mode is determined, a marker indicating the invocation mode is sent to the interface-called terminal to invoke the target interface according to the specified invocation mode. This technical approach solves the problem in the prior art where the interface invocation mode is fixed, which can easily lead to slow task processing or even failure.
[0079] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this disclosure, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as read-only memory (ROM), random access memory (RAM), magnetic disk, optical disk), and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods of the various embodiments of this disclosure.
[0080] This embodiment also provides an interface calling device for implementing the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, hardware implementations, or a combination of software and hardware, are also possible and contemplated.
[0081] Figure 5 This schematically illustrates a structural block diagram of an interface calling device according to an optional embodiment of the present disclosure, such as... Figure 5 As shown, the device includes:
[0082] The acquisition module 502 is used to acquire the configuration information of the target interface and the service status information of the target device;
[0083] The determining module 504 is used to determine the interface invocation method of the target interface through at least one of the configuration information and the service status information;
[0084] The calling module 506 is used to send the tag information indicating the interface calling method to the interface called end, so as to call the target interface according to the interface calling method.
[0085] This disclosure provides a method for determining the interface invocation mode of a target interface by obtaining configuration information of the target interface and service status information of the target device, using at least one of the configuration information and service status information. Once the interface invocation mode is determined, a marker indicating the invocation mode is sent to the interface-called terminal to invoke the target interface according to the specified invocation mode. This technical approach solves the problem in the prior art where the interface invocation mode is fixed, which can easily lead to slow task processing or even failure.
[0086] Optionally, the acquisition module 502 is further configured to receive an interface call request sent by the interface call client, and determine the input parameters of the target interface and the Internet Protocol address of the target device according to the interface call request; acquire the configuration information of the target interface according to the input parameters; or, the configuration information of the target interface can be determined according to the input parameters and then acquired; and acquire the service status information of the target device from the device monitoring system according to the Internet Protocol address.
[0087] This embodiment of the disclosure can obtain the configuration information of the target interface and the service status information of the target device through the above-described technical means, and then determine the interface calling method of the target interface based on the configuration information and service status information. This solves the problem in the prior art that the interface calling method is fixed, which leads to slow task processing speed or even failure.
[0088] Optionally, the acquisition module 502 is further configured to monitor the service status information of multiple devices in real time through the device monitoring system, and store the service status information of the multiple devices in the monitoring system database of the device monitoring system; and obtain the service status information of the target device from the monitoring system database according to the Internet Protocol address.
[0089] The equipment monitoring system monitors the service status information of multiple devices in real time and stores the monitored service status information of the multiple devices in the monitoring system database of the equipment monitoring system. The service status information is information about the operation or working status of the devices.
[0090] Table 1 shows the data structure of the service status information of the target device.
[0091] Fields describe Server_type Service type (e.g., percentage of running memory) Server_threshold Service threshold (e.g., 90%) Is_alert Alarm? Alert_type Alarm Types …. ….
[0092] It should be noted that when the service type exceeds the service threshold, it is necessary to determine whether an alarm is needed and what type of alarm is required.
[0093] With the service status information of the multiple devices obtained from monitoring stored in the monitoring system database of the device monitoring system, the service status information of the target device is retrieved from the monitoring system database according to the Internet Protocol address. Here, the multiple devices include the target device, and one Internet Protocol address corresponds to one device.
[0094] Optionally, the acquisition module 502 is further configured to receive monitoring instructions sent by the target object, and determine multiple devices that the device monitoring system needs to monitor in real time based on the monitoring instructions; or, determine multiple devices that the device monitoring system needs to monitor in real time based on the default settings of the device monitoring system.
[0095] Optionally, the determining module 504 is further configured to determine whether the target interface is dynamically invoked based on the dynamic invocation configuration information in the configuration information; if the target interface is not dynamically invoked, determine the interface invocation method of the target interface based on the interface invocation type information in the configuration information; if the target interface is dynamically invoked, determine the interface invocation method of the target interface based on the asynchronous invocation threshold and the service status information in the configuration information.
[0096] In other words, if the target interface is not dynamically invoked, the interface invocation method can be determined solely through the configuration information: the dynamic invocation configuration information determines that the target interface is not dynamically invoked; the interface invocation type information in the configuration information determines the interface invocation method. The interface invocation method includes asynchronous and synchronous invocation methods. If the target interface is dynamically invoked, the interface invocation method needs to be determined through both the configuration information and the service status information: the dynamic invocation configuration information determines that the target interface is dynamically invoked; the asynchronous invocation threshold in the configuration information and the service status information determine the interface invocation method.
[0097] Table 2 shows the data structure of the target interface configuration information.
[0098] Fields describe Interface_name Interface Name Interface_type Interface call type (synchronous or asynchronous) Is_dynamic Dynamic invocation Dynamic_type Dynamically invoke configurations (e.g., runtime memory usage). async_threshold Asynchronous call threshold (e.g., idle time) Threshold_type Threshold type (e.g., greater than, less than, equal to) …. ….
[0099] Optionally, the determining module 504 is further configured to determine that the interface call method is an asynchronous call method when the service percentage is greater than the asynchronous call threshold, wherein the service status information includes the service percentage, which represents the degree of device busyness; and to determine that the interface call method is a synchronous call method when the service percentage is less than the asynchronous call threshold.
[0100] Optionally, the service percentage can also be a percentage of the device's running memory occupancy. The interface calling method is determined by comparing the running memory occupancy with the asynchronous call threshold: if the running memory occupancy is greater than the asynchronous call threshold, the interface calling method is determined to be an asynchronous calling method; if the running memory occupancy is less than the asynchronous call threshold, the interface calling method is determined to be a synchronous calling method.
[0101] The above-mentioned technical means can realize dynamic calling of interfaces, which solves the problem that the calling method of interfaces is fixed in the existing technology, resulting in slow task processing speed or even failure.
[0102] It should be noted that whether dynamic invocation is used can be adjusted by the target object according to specific circumstances. If an error occurs during the query, such as a service crash, the interface invocation type information in the configuration information will be used as the default interface invocation method.
[0103] Optionally, the calling module 506 is further configured to, when the marking information indicates that the interface calling method is a synchronous calling method, instruct the interface called end to execute a business processing task and return the result of the business processing task to the interface calling end; when the marking information indicates that the interface calling method is an asynchronous calling method, determine in real time whether the service percentage is less than the asynchronous calling threshold, and if the service percentage is less than the asynchronous calling threshold, instruct the interface called end to execute a business processing task and return the result of the business processing task to the interface calling end; wherein, the service status information includes the service percentage, the service percentage represents the degree of device busyness, and the configuration information includes the asynchronous calling threshold.
[0104] This embodiment of the disclosure adds an interface call management system. The interface call management system obtains the configuration information of the target interface and the service status information of the target device according to the interface call request sent by the interface caller. It determines the interface call method according to the configuration information and the service status information or one of the configuration information and the service status information. The interface called end then realizes the call to the target interface according to the interface call method determined by the interface call management system.
[0105] The interface call management system sends a flag indicating the interface call method to the interface callee. If the flag indicates a synchronous call method, the interface callee is instructed to execute a business processing task and return the result to the interface caller. If the flag indicates an asynchronous call method, the system continuously checks if the service percentage is less than the asynchronous call threshold. If the service percentage is less than the threshold (i.e., the target device is idle), the interface callee is instructed to execute a business processing task and return the result to the interface caller. If the service percentage is greater than the threshold, the target device is busy, and no processing is performed. The system continues to monitor and check if the service percentage is less than the threshold. If the service percentage is less than the threshold, the business processing task is processed.
[0106] It should be noted that when the marking information indicates that the interface call method is a synchronous call method, the result of executing the business processing task is directly returned to the interface caller; when the marking information indicates that the interface call method is an asynchronous call method, after instructing the interface called end to execute the business processing task, it is necessary to query the callback interface and return the result of executing the business processing task to the interface caller through the callback interface.
[0107] Optionally, the calling module 506 is further configured to set an interface task, wherein the interface task is configured to determine in real time whether the service percentage is less than the asynchronous call threshold, and if the service percentage is less than the asynchronous call threshold, instruct the interface called end to execute the business processing task and return the result of executing the business processing task to the interface calling end; or the business processing task is placed in a message queue, wherein the message queue is configured to determine in real time whether the service percentage is less than the asynchronous call threshold, and if the service percentage is less than the asynchronous call threshold, instruct the interface called end to execute the business processing task and return the result of executing the business processing task to the interface calling end.
[0108] This disclosure embodiment can set up an interface task. When the service percentage is less than the asynchronous call threshold, the interface task instructs the called end to execute a business processing task and returns the result of the business processing task to the interface caller. This disclosure embodiment can also directly place the business processing task into a message queue for processing. It should be noted that the message queue is a first-in, first-out (FIFO) task processing queue, which allows for processing business processing tasks in the order they are executed.
[0109] Optionally, the calling module 506 is further configured to send the result information of calling the target interface according to the interface calling method to the interface calling end through the callback interface; and instruct the interface calling party to process the result information in an asynchronous manner.
[0110] It's important to note that all callback interfaces on the API caller side are asynchronous. This means that after the called end finishes processing its business logic, it transmits the result to the calling end via the callback interface. The calling end will always process the result and return a success message to the called end. The calling end decides when to process the result based on its own state. If the callback interface also supports both synchronous and asynchronous calls, it will create a circular dependency, slowing down the process. The callback interface needs to support configuration descriptions to prevent the recipient from failing to call the callback interface when returning a result. Additionally, the callback interface must support encryption.
[0111] Table 3 shows the configuration description information for the callback interface.
[0112] Fields describe Interface_name Interface Name Interface_param_type Interface parameter types …. ….
[0113] The information in Table 3 can be used to determine the interface name and parameter types of the callback interface.
[0114] It should be noted that the above modules can be implemented by software or hardware. For the latter, they can be implemented in the following ways, but are not limited to: all the above modules are located in the same processor; or, the above modules are located in different processors in any combination.
[0115] Embodiments of this disclosure provide an electronic device.
[0116] Figure 6 The schematic diagram illustrates a structural block diagram of an electronic device provided in an embodiment of the present disclosure.
[0117] Reference Figure 6 As shown, the electronic device 600 provided in this embodiment includes a processor 601, a communication interface 602, a memory 603, and a communication bus 604. The processor 601, the communication interface 602, and the memory 603 communicate with each other through the communication bus 604. The memory 603 is used to store computer programs. When the processor 601 executes the program stored in the memory, it implements the steps in any of the above method embodiments.
[0118] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the input / output device is connected to the processor.
[0119] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:
[0120] S1, obtain the configuration information of the target interface and the service status information of the target device;
[0121] S2, determine the interface invocation method of the target interface through at least one of the configuration information and the service status information;
[0122] S3, send the tag information indicating the interface calling method to the interface called end, so as to call the target interface according to the interface calling method.
[0123] Embodiments of this disclosure also provide a computer-readable storage medium. The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps in any of the method embodiments described above.
[0124] Optionally, in this embodiment, the storage medium may be configured to store a computer program for performing the following steps:
[0125] S1, obtain the configuration information of the target interface and the service status information of the target device;
[0126] S2, determine the interface invocation method of the target interface through at least one of the configuration information and the service status information;
[0127] S3, send the tag information indicating the interface calling method to the interface called end, so as to call the target interface according to the interface calling method.
[0128] The computer-readable storage medium may be included in the device / apparatus described in the above embodiments; or it may exist independently and not assembled into the device / apparatus. The computer-readable storage medium carries one or more programs that, when executed, implement the method according to the embodiments of this disclosure.
[0129] According to embodiments of this disclosure, the computer-readable storage medium can be a non-volatile computer-readable storage medium, such as including, but not limited to: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this disclosure, the computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0130] Optionally, specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementations, and will not be repeated here.
[0131] It will be apparent to those skilled in the art that the modules or steps of this disclosure described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. Optionally, they can be implemented using computer-executable program code, thereby storing them in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those presented herein, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, this disclosure is not limited to any particular combination of hardware and software.
[0132] The above description is merely a preferred embodiment of this disclosure and is not intended to limit the scope of this disclosure. Various modifications and variations can be made to this disclosure by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the principles of this disclosure should be included within the protection scope of this disclosure.
Claims
1. An interface invocation method, characterized in that, include: Obtain the configuration information of the target interface and the service status information of the target device; The interface invocation method of the target interface is determined by at least one of the configuration information and the service status information; Determining the interface invocation method of the target interface using at least one of the configuration information and the service status information includes: determining whether the target interface is dynamically invoked using dynamic invocation configuration information in the configuration information; if the target interface is not dynamically invoked, determining the interface invocation method of the target interface using interface invocation type information in the configuration information; if the target interface is dynamically invoked, determining the interface invocation method of the target interface using asynchronous invocation threshold in the configuration information and the service status information. The flag information indicating the interface invocation method is sent to the interface called end so that the target interface is invoked according to the interface invocation method.
2. The interface calling method according to claim 1, characterized in that, Obtain the configuration information of the target interface and the service status information of the target device, including: Receive the interface call request sent by the interface call client, and determine the input parameters of the target interface and the Internet Protocol address of the target device based on the interface call request; The configuration information of the target interface is obtained based on the input parameters; The service status information of the target device is obtained from the device monitoring system based on the Internet Protocol address.
3. The interface calling method according to claim 2, characterized in that, Obtain the service status information of the target device from the device monitoring system based on the Internet Protocol address, including: The device monitoring system monitors the service status information of multiple devices in real time and stores the service status information of the multiple devices in the monitoring system database of the device monitoring system. The service status information of the target device is obtained from the monitoring system database based on the Internet Protocol address.
4. The interface calling method according to claim 1, characterized in that, When the target interface is dynamically invoked, the interface invocation method of the target interface is determined by the asynchronous invocation threshold in the configuration information and the service status information, including: If the service percentage is greater than or equal to the asynchronous call threshold, the interface call method is determined to be an asynchronous call method, wherein the service status information includes the service percentage, which indicates the degree of device busyness; If the service percentage is less than the asynchronous call threshold, the interface call method is determined to be a synchronous call method.
5. The interface calling method according to claim 1, characterized in that, Sending the tagging information indicating the interface invocation method to the interface called end, so as to invoke the target interface according to the interface invocation method, includes: When the marking information indicates that the interface call method is synchronous, the interface called end is instructed to perform a business processing task and return the result of the business processing task to the interface caller. When the marking information indicates that the interface call method is an asynchronous call method, it is determined in real time whether the service percentage is less than the asynchronous call threshold. If the service percentage is less than the asynchronous call threshold, the interface called end is instructed to execute a business processing task, and the result of executing the business processing task is returned to the interface caller. The service status information includes the service percentage, which indicates the level of device activity, and the configuration information includes the asynchronous call threshold.
6. The interface calling method according to claim 5, characterized in that, When the marking information indicates that the interface call method is asynchronous, it is determined in real time whether the service percentage is less than the asynchronous call threshold. If the service percentage is less than the asynchronous call threshold, the interface called end is instructed to execute a business processing task, and the result of the business processing task is returned to the interface caller, including: An interface task is set up, wherein the interface task is used to determine in real time whether the service percentage is less than the asynchronous call threshold, and if the service percentage is less than the asynchronous call threshold, instruct the interface callee to execute the business processing task and return the result of the business processing task to the interface caller; or The business processing task is placed into a message queue, which is used to determine in real time whether the service percentage is less than the asynchronous call threshold. If the service percentage is less than the asynchronous call threshold, the interface called end is instructed to execute the business processing task, and the result of executing the business processing task is returned to the interface calling end.
7. The interface calling method according to claim 1, characterized in that, After sending the marker information indicating the interface invocation method to the interface called end, so as to invoke the target interface according to the interface invocation method, the method further includes: The result information of calling the target interface according to the interface calling method is sent to the interface calling end through the callback interface; This instructs the interface caller to process the result information asynchronously.
8. An interface calling device, characterized in that, include: The acquisition module is used to acquire the configuration information of the target interface and the service status information of the target device; The determination module is used to determine the interface invocation method of the target interface through at least one of the configuration information and the service status information; Determining the interface invocation method of the target interface using at least one of the configuration information and the service status information includes: determining whether the target interface is dynamically invoked using dynamic invocation configuration information in the configuration information; if the target interface is not dynamically invoked, determining the interface invocation method of the target interface using interface invocation type information in the configuration information; if the target interface is dynamically invoked, determining the interface invocation method of the target interface using asynchronous invocation threshold in the configuration information and the service status information. The calling module is used to send the tag information indicating the interface calling method to the interface called end, so as to call the target interface according to the interface calling method.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method of any one of claims 1 to 7.
Citation Information
Patent Citations
Self-adaptive interface calling method and system
CN105183672A
Interface calling method and device
CN106412009A