Application programming interface calling method, device, electronic device and storage medium

By encapsulating the response listening process and creating a combined asynchronous call task in JSF, the complex problems of asynchronous call thread blocking and log printing are solved, and efficient asynchronous call and optimized system performance is achieved.

CN113918242BActive Publication Date: 2025-04-15JINGDONG TECH HLDG CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011324427.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-11-23
Publication Date
2025-04-15
Estimated Expiration
2040-11-23

AI Technical Summary

Technical Problem

In Jingdong Service Framework (JSF), there is a blocking problem when calling asynchronously, especially when a generic service is acquired for the first time, which leads to system performance jitter and log printing is complicated and cumbersome.

Method used

By receiving a non-generic asynchronous call request, determine the API for calling and encapsulate the response listening process into the API to generate an encapsulation interface. Before calling the encapsulation interface, create a combined asynchronous calling task and encapsulate the call result during the call, including the return value of the callback function and the exception result. For generic asynchronous call requests, request the cache to obtain the generic service and encapsulate the call result into a combined asynchronous call task.

Benefits of technology

It solves the blocking problem of asynchronous calling threads, reduces the need for return value type conversion, reduces the difficulty of code maintenance, and optimizes the calling process of generic services, reducing system performance jitter.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113918242B_ABST
    Figure CN113918242B_ABST
Patent Text Reader

Abstract

The present disclosure provides an application programming interface calling method, device, electronic device and storage medium, which relate to the field of computer technology. Among them, the application programming interface calling method includes: receiving a non-generic asynchronous call request; determining the application programming interface used for calling in the non-generic asynchronous call request; according to the non-generic asynchronous call request, encapsulating the response listening process into the application programming interface to generate an encapsulation interface; before calling the encapsulation interface, creating a combined asynchronous call task of the encapsulation interface; in the calling process of the combined asynchronous call task, encapsulating the calling result of the combined asynchronous call task, and the calling result includes the return value and / or abnormal result of the callback function of the combined asynchronous call task. Through the technical solution of the present disclosure, the blocking problem in the asynchronous calling process is solved, it is compatible with any asynchronous calling framework, and the probability of system jitter in the asynchronous calling process is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to an application programming interface calling method, device, electronic device and storage medium. Background Art

[0002] Jingdong Service Framework (JSF for short) is a new standard Java framework for building Web applications.

[0003] In the related art, when executing a JSF asynchronous call, it is necessary to monitor the call result, and the parameters in the call result are Java base classes, which require the user to manually convert to the type required for the next data flow.

[0004] In addition, during the JSF asynchronous call process, there may be a failure to obtain the calling service, which may cause the calling thread to be suspended or blocked. Typically, the first acquisition of a generic service is a blocking operation. When applied to responsive programming, the first generic asynchronous call to the interface will cause serious jitter in the JSF system performance.

[0005] Finally, in the JSF asynchronous call process, since the asynchronous call process is divided into multiple asynchronously executed sub-threads and the completion sequence of each sub-thread is chaotic, printing logs based on JSF asynchronous calls is relatively complex and cumbersome.

[0006] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention

[0007] The purpose of the present disclosure is to provide an application programming interface calling method, device, electronic device and storage medium, which at least to a certain extent overcome the blocking problem in asynchronous calling in the related art.

[0008] Other features and advantages of the present disclosure will become apparent from the following detailed description, or may be learned in part by the practice of the present disclosure.

[0009] According to one aspect of the present disclosure, there is provided an application programming interface calling method, comprising: receiving a non-generic asynchronous call request; determining an application programming interface for calling in the non-generic asynchronous call request; encapsulating a response listening process into the application programming interface according to the non-generic asynchronous call request to generate an encapsulated interface; before calling the encapsulated interface, creating a combined asynchronous call task of the encapsulated interface; during the calling process of the combined asynchronous call task, encapsulating the calling result of the combined asynchronous call task, the calling result including the return value and / or exception result of the callback function of the combined asynchronous call task.

[0010] In one embodiment of the present disclosure, according to a non-generic asynchronous call request, encapsulating a response listening process into an application programming interface to generate an encapsulation interface includes: creating a response listening process according to the non-generic asynchronous call request; saving the response listening process into a call status recorder of the application programming interface; pre-storing a class of a callback function inside a calling thread of the application programming interface, and encapsulating the class into the application programming interface to generate an encapsulation interface that supports lambda expressions.

[0011] In one embodiment of the present disclosure, the application programming interface calling method also includes: obtaining call request parameters in a non-generic asynchronous call request through a filter of the application programming interface, and saving the call request parameters to local thread variables; determining call result parameters according to the call result; associating the call request parameters and the call result parameters according to the identification information of the call request parameters and the identification information of the call result parameters; receiving a log printing request of the associated call request parameters and call result parameters, and adding the log printing request to the combined asynchronous call task.

[0012] In one embodiment of the present disclosure, the application programming interface calling method further includes: if it is detected that the log printing request is completed, clearing the calling request parameters stored in the local thread variable.

[0013] According to one aspect of the present disclosure, there is provided an application programming interface calling method, comprising: receiving a generic asynchronous call request; determining an application programming interface for calling in the generic asynchronous call request; requesting a cache area to obtain a generic service of the application programming interface, and executing a generic call task according to the generic service; encapsulating a call result of the generic call task into a combined asynchronous call task, the call result including a return value and / or an exception result of a callback function of the combined asynchronous call task.

[0014] In one embodiment of the present disclosure, requesting a cache area to obtain a generic service of an application programming interface and executing a generic call task according to the generic service includes: requesting a cache area to obtain a generic service of an application programming interface and determining whether to obtain the generic service; if it is determined to obtain the generic service, determining a generic call function according to the generic service, and determining the return value of the generic call function as the call result; if it is determined that the generic service is not obtained, forwarding the request for obtaining the generic service to an asynchronous thread pool, and determining the business logic of initiating the generic asynchronous call request as a callback function for obtaining the generic service.

[0015] In one embodiment of the present disclosure, the application programming interface calling method further includes: determining parameter information of the generic asynchronous call request before the generic asynchronous call request is called; receiving a log printing request of the parameter information, and adding the log printing request to the combined asynchronous call task.

[0016] According to another aspect of the present disclosure, there is provided an application programming interface calling device, comprising: a receiving module for receiving a non-generic asynchronous call request; a determining module for determining an application programming interface for calling in the non-generic asynchronous call request; an encapsulation module for encapsulating a response listening process into an application programming interface according to the non-generic asynchronous call request to generate an encapsulation interface; a calling module for creating a combined asynchronous call task of the encapsulation interface before calling the encapsulation interface; the encapsulation module is also used to encapsulate the calling result of the combined asynchronous call task during the calling process of the combined asynchronous call task, and the calling result includes the return value and / or exception result of the callback function of the combined asynchronous call task.

[0017] According to another aspect of the present disclosure, there is provided an application programming interface calling device, comprising: a receiving module for receiving a generic asynchronous call request; a determining module for determining an application programming interface for calling in the generic asynchronous call request; a calling module for requesting a cache area to obtain a generic service of the application programming interface, and executing a generic calling task according to the generic service; and an encapsulation module for encapsulating a calling result of the generic calling task into a combined asynchronous calling task, wherein the calling result includes a return value and / or an exception result of a callback function of the combined asynchronous calling task.

[0018] According to another aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute any one of the above-mentioned application programming interface calling methods by executing the executable instructions.

[0019] According to another aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, any one of the above-mentioned application programming interface calling methods is implemented.

[0020] The application programming interface calling solution provided by the embodiment of the present disclosure solves the blocking problem of asynchronous calling threads by encapsulating the calling results into a combined asynchronous calling task.

[0021] In addition, since the combined asynchronous call task contains information such as asynchronous call request parameters, the class of the calling method, and the return value of the callback function, the user does not need to perform type conversion on the return value and can use it for subsequent data flow processes.

[0022] Secondly, by encapsulating the application programming interface, the generation of redundant code is reduced and the difficulty of code maintenance is reduced.

[0023] It is worth noting that by optimizing the calling process of generic services, the blocking problem of the first call to generic services is overcome. This is commonly used in responsive programming scenarios and reduces the jitter of system performance.

[0024] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification are used to explain the principles of the present disclosure. Obviously, the accompanying drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without creative work.

[0026] Figure 1 A schematic diagram showing an architecture of an application programming interface calling solution in an embodiment of the present disclosure;

[0027] Figure 2 A flowchart showing an application programming interface calling method in an embodiment of the present disclosure is shown;

[0028] Figure 3 A flowchart showing another method for calling an application programming interface in an embodiment of the present disclosure is shown;

[0029] Figure 4 A flowchart showing another method for calling an application programming interface in an embodiment of the present disclosure is shown;

[0030] Figure 5 A flowchart showing another method for calling an application programming interface in an embodiment of the present disclosure is shown;

[0031] Figure 6 A flowchart showing another method for calling an application programming interface in an embodiment of the present disclosure is shown;

[0032] Figure 7 A flowchart showing another method for calling an application programming interface in an embodiment of the present disclosure is shown;

[0033] Figure 8 A flowchart showing another method for calling an application programming interface in an embodiment of the present disclosure is shown;

[0034] Fig. 9 A flowchart showing another method for calling an application programming interface in an embodiment of the present disclosure is shown;

[0035] Fig.10 A flowchart showing another method for calling an application programming interface in an embodiment of the present disclosure is shown;

[0036] Fig.11 A schematic diagram showing an application programming interface calling device in an embodiment of the present disclosure;

[0037] Fig.12 A schematic diagram showing another application programming interface calling device in an embodiment of the present disclosure;

[0038] Fig.13 A schematic diagram of an electronic device in an embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0039] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that the disclosure will be more comprehensive and complete and to fully convey the concepts of the example embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.

[0040] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.

[0041] The solution provided by the present application solves the blocking problem of asynchronous call threads by encapsulating the call results into a combined asynchronous call task. In addition, since the combined asynchronous call task contains information such as asynchronous call request parameters, the class of the call method, and the return value of the callback function, the user does not need to perform type conversion on the return value and can use it for subsequent data flow processes. Secondly, by encapsulating the application programming interface, the generation of redundant code is reduced and the difficulty of code maintenance is reduced. Finally, by optimizing the calling process of generic services, the blocking problem of the first call to generic services is overcome, which is commonly used in responsive programming scenarios and reduces the jitter of system performance.

[0042] The solution provided in the embodiments of the present application involves technologies such as application programming interface calls, which are specifically explained through the following embodiments.

[0043] Figure 1 A schematic diagram showing an application programming interface calling architecture in an embodiment of the present disclosure.

[0044] like Figure 1 As shown, an application programming interface calling architecture in an embodiment of the present disclosure includes at least two servers, for example, a first JAVA server 102 and a second JAVA server 104. JSF is an RPC (Remote Procedure Call Protocol) tool for mutual calling between microservices.

[0045] (1) When the application on the first JAVA server 102 initiates a remote procedure call, the method parameters need to be passed to the second JAVA server 104 through the underlying network protocol. Since the network protocol is based on binary, the parameter values ​​in the memory must be serialized into binary form, that is, serialized (Serialize) or marshalled (marshal), and the serialized binary is sent to the second JAVA server 104 through addressing and transmission.

[0046] (2) After receiving the call request, the second JAVA server 104 needs to deserialize the parameters (the inverse operation of serialization) to restore them to the expression in the memory, then find the corresponding method (part of the addressing) to make a local call, and then obtain the return value.

[0047] (3) The return value (business data) must also be sent back to the application on the first JAVA server 102 and must also be sent in a serialized manner. After receiving it, the first JAVA server 102 deserializes it, restores it to the expression in the memory, and hands it over to the application on the first JAVA server 102.

[0048] Below, each step of the application programming interface calling method in this example implementation will be described in more detail with reference to the accompanying drawings and embodiments.

[0049] Figure 2 A flowchart of an application programming interface calling method in an embodiment of the present disclosure is shown. The method provided in the embodiment of the present disclosure can be executed by any electronic device with computing and processing capabilities, such as a server or a terminal, but is not limited thereto. In the following example description, the terminal is used as the execution subject for example description.

[0050] like Figure 2 As shown, the terminal executes the application programming interface calling method, including the following steps:

[0051] Step S202: receiving a non-generic asynchronous call request.

[0052] Step S204: determining an application programming interface for calling in the non-generic asynchronous call request.

[0053] Step S206: encapsulate the response monitoring process into an application programming interface according to the non-generic asynchronous call request to generate an encapsulation interface.

[0054] In the above embodiment, for non-generic asynchronous call requests, by encapsulating the response listening process into an API (Application Program Interface), there is no need to create a response listening process according to the non-generic asynchronous call request, nor is there any need to perform cumbersome code maintenance on the response listening process.

[0055] Step S208, before calling the encapsulation interface, create a combined asynchronous calling task of the encapsulation interface.

[0056] Step S210, during the calling process of the combined asynchronous calling task, encapsulate the calling result of the combined asynchronous calling task, where the calling result includes the return value and / or abnormal result of the callback function of the combined asynchronous calling task.

[0057] In the above embodiment, the non-generic asynchronous call request can be considered as an ordinary asynchronous call request, the input parameter is the lambda expression of the remote call, and the output parameter is the output of the combined asynchronous call task, so that the business system of the application programming interface does not need to pay attention to the internal logic of the asynchronous call process, and hides the response monitoring process and various exceptions.

[0058] Specifically, by encapsulating the call result of the combined asynchronous call task (CompletableFuture), in the above embodiment, the non-generic asynchronous call request can be considered as a normal asynchronous call request, the input parameter is the lambda expression of the remote call, and the output parameter is the output of the combined asynchronous call task, so that the business system of the application programming interface does not need to pay attention to the internal logic of the asynchronous call process, and hides the response monitoring process and various exceptions. The action provided for the dependent completion of the non-asynchronous method can be executed by the thread that completes the current CompletableFuture, or by any other caller of the completed method.

[0059] Additionally, all asynchronous methods without an explicit executor parameter are executed using "ForkJoinPool.commonPool()", unless it does not support at least two levels of parallelism, in which case a new thread is created to run each task. To simplify monitoring, debugging, and tracing, all generated composed asynchronous call tasks are marker interfaces.

[0060] based on Figure 2 The steps shown are as follows Figure 3 As shown, according to the non-generic asynchronous call request, the response listening process is encapsulated into the application programming interface to generate the encapsulation interface including:

[0061] Step S3062: Create a response listening process according to the non-generic asynchronous call request.

[0062] Step S3064, saving the response monitoring process to the call status recorder of the application programming interface.

[0063] Step S3066, pre-store the class of the callback function inside the calling thread of the application programming interface, and encapsulate the class into the application programming interface to generate an encapsulation interface that supports lambda expressions.

[0064] In the above embodiment, the call status recorder (RpcContext) is a temporary status recorder of a local thread (ThreadLocal). When an RPC request is received or initiated, the state of RpcContext will change. For example, A calls B, and B calls C. On machine B, before B calls C, RpcContext records the information of A calling B, and after B calls C, RpcContext records the information of B calling C.

[0065] In addition, by pre-storing the callback function class inside the calling thread of the application programming interface and encapsulating the class into the application programming interface, an encapsulation interface that supports lambda expressions is generated. The encapsulation interface is mainly used to encapsulate the class of the calling method. When a generic asynchronous call is made to the encapsulation interface, the general filter of the encapsulation interface extracts and saves the parameters of the generic asynchronous call request, and associates the return value of the call result.

[0066] based on Figure 2 The steps shown are as follows Figure 4 As shown, the application programming interface calling method also includes:

[0067] Step S402: obtaining call request parameters in the non-generic asynchronous call request through a filter of the application programming interface, and saving the call request parameters to a local thread variable.

[0068] Step S404, determining the calling result parameters according to the calling result.

[0069] Step S406: Correlate the call request parameters and the call result parameters according to the identification information of the call request parameters and the identification information of the call result parameters.

[0070] Step S408, receiving a log printing request associated with the call request parameter and the call result parameter, and adding the log printing request to the combined asynchronous call task.

[0071] In the related art, for single-thread synchronous call processing, the printed logs are easy to understand through the thread context, and can be viewed according to the thread name and log time when troubleshooting. However, the logs of asynchronous requests cannot be simply handled in this way. A large task will be divided into N subtasks for asynchronous and parallel processing. The execution order of each subtask is out of order, and subtasks of the same type are also executed out of order.

[0072] In the above embodiment, for ordinary asynchronous calls, the log printing is relatively complicated. The principle of obtaining the method name and parameters of the request is as follows: a custom Filter is used internally to intercept the original JSF request. After creating a ResponseListener, it is used to extract the function of calling the request parameters and save it to the ThreadLocal variable in the Filter. This function in the ThreadLocal in the Filter is obtained and executed.

[0073] based on Figure 2 The steps shown are as follows Figure 5 As shown, the application programming interface calling method also includes:

[0074] Step S502: If it is detected that the log printing request is completed, the calling request parameters stored in the local thread variable are cleared.

[0075] In the above embodiment, the call request parameters are extracted before the asynchronous call and the relevant parameters of the request are saved. After the execution is completed, the ThreadLocal is cleared to facilitate the use of the next thread.

[0076] Figure 6 A flowchart of an application programming interface calling method in an embodiment of the present disclosure is shown. The method provided in the embodiment of the present disclosure can be executed by any electronic device with computing and processing capabilities, such as a server or a terminal, but is not limited thereto. In the following example description, the terminal is used as the execution subject for example description.

[0077] like Figure 6 As shown, an application programming interface calling method is provided, comprising:

[0078] Step S602: Create a response monitoring process.

[0079] Step S604: Save the response monitoring process to the call status recorder.

[0080] Step S606, RemoteService.xxx() service: JSF general filter; save the request data to the response monitoring process, which can be used for log printing; send JSF asynchronous call request.

[0081] Step S608, sending the asynchronous call request ends.

[0082] In the above embodiment, "RemoteService.xxx()" is an instance of a remote service function, which is encapsulated in an API interface and supports lambda expressions. It is more convenient to combine with other asynchronous frameworks. The entire calling process does not have any blocking operations, making it fully suitable for responsive programming.

[0083] For example, based on the technical solution disclosed in the present invention, 200 non-generic asynchronous calls for obtaining membership services are initiated for the above encapsulation interface. However, the callback function that executes the non-generic asynchronous call does not generate a return value due to an exception, so the exception result is determined as the call result and written into CompletableFuture. When the next non-generic asynchronous call for obtaining membership services is initiated, the thread of the callback function is initialized.

[0084] Figure 7A flowchart of an application programming interface calling method in an embodiment of the present disclosure is shown. The method provided in the embodiment of the present disclosure can be executed by any electronic device with computing and processing capabilities, such as a server or a terminal, but is not limited thereto. In the following example description, the terminal is used as the execution subject for example description.

[0085] like Figure 7 As shown, an application programming interface calling method is provided, comprising:

[0086] Step S702: receiving a generic asynchronous call request.

[0087] Step S704: determine the application programming interface used for calling in the generic asynchronous call request.

[0088] Step S706: request the cache area to obtain the generic service of the application programming interface, and execute the generic call task according to the generic service.

[0089] Step S708, encapsulating the calling result of the generic calling task into the combined asynchronous calling task, the calling result including the return value and / or abnormal result of the callback function of the combined asynchronous calling task.

[0090] In the above embodiment, GenericService is obtained from the cache (generic service, for example, although 10 methods are provided, ten methods are not written in the interface, and there is no need to make function declarations and parameter declarations for these ten methods). If it is obtained, a generic asynchronous call is directly initiated. If it is not obtained, the acquisition operation of the generic asynchronous call request is handed over to the asynchronous thread pool for processing, and the business logic of initiating the generic asynchronous call request is processed as the callback function for obtaining GenericService.

[0091] based on Figure 7 The steps shown are as follows Figure 8 As shown, requesting the cache area to obtain the generic service of the application programming interface and executing the generic call task according to the generic service include:

[0092] Step S8062, requesting the cache area to obtain the generic service of the application programming interface, and determining whether to obtain the generic service, if so, executing step S8064, if not, executing step S8066.

[0093] Step S8064: If it is determined that a generic service is to be obtained, a generic call function is determined according to the generic service, and the return value of the generic call function is determined as the call result.

[0094] Step S8066: If it is determined that the generic service is not obtained, the request for obtaining the generic service is forwarded to the asynchronous thread pool, and the business logic for initiating the generic asynchronous call request is determined as a callback function for obtaining the generic service.

[0095] In the above embodiment, when initiating a generic service, the interface name, call request parameters and the class of the calling method are set to provide asynchronous calling services, such as membership services and account services. In order to solve the blocking problem of generic asynchronous calls, the call result is encapsulated into CompletableFuture. If the callback method returns a result, the return value is encapsulated into CompletableFuture. If the callback method does not return a result, the calling method is encapsulated into CompletableFuture.

[0096] based on Figure 7 The steps shown are as follows Fig. 9 As shown, the application programming interface calling method also includes:

[0097] Step S902: before the generic asynchronous call request is called, parameter information of the generic asynchronous call request is determined.

[0098] Step S904: receiving a log printing request of parameter information, and adding the log printing request to the combined asynchronous call task.

[0099] In the above embodiment, the request interface name, parameter list and request parameters can be directly obtained before the generic asynchronous call, so they can be directly printed. The result of the call is encapsulated into CompletableFuture, and the response log printing can be directly added to this CompletableFuture, which simplifies the log printing steps of the generic asynchronous call.

[0100] Fig.10 A flowchart of an application programming interface calling method in an embodiment of the present disclosure is shown. The method provided in the embodiment of the present disclosure can be executed by any electronic device with computing and processing capabilities, such as a server or a terminal, but is not limited thereto. In the following example description, the terminal is used as the execution subject for example description.

[0101] like Fig.10 As shown, an application programming interface calling method is provided, comprising:

[0102] Step S1002: asynchronously obtain generic services.

[0103] Step S1004: Initiate a JSF asynchronous call in the callback function of the generic service.

[0104] In the above embodiment, GenericService is obtained from the cache (generic service, for example, although 10 methods are provided, ten methods are not written in the interface, and there is no need to make function declarations and parameter declarations for these ten methods). If it is obtained, a generic asynchronous call is directly initiated. If it is not obtained, the acquisition operation of the generic asynchronous call request is handed over to the asynchronous thread pool for processing, and the business logic of initiating the generic asynchronous call request is processed as the callback function for obtaining GenericService.

[0105] Refer to the following Fig.11 The application programming interface calling device 1100 according to this embodiment of the present invention is described. Fig.11 The application programming interface calling device 1100 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0106] The application programming interface calling device 1100 is in the form of a hardware module. The components of the application programming interface calling device 1100 may include but are not limited to: a receiving module 1102 , a determining module 1104 , a packaging module 1106 and a calling module 1108 .

[0107] The receiving module 1102 is used to receive a non-generic asynchronous call request.

[0108] The determination module 1104 is used to determine an application programming interface for calling in a non-generic asynchronous call request.

[0109] The encapsulation module 1106 is used to encapsulate the response monitoring process into the application programming interface according to the non-generic asynchronous call request to generate an encapsulation interface.

[0110] The calling module 1108 is used to create a combined asynchronous calling task of the encapsulation interface before calling the encapsulation interface.

[0111] The encapsulation module 1106 is also used to encapsulate the calling result of the combined asynchronous calling task during the calling process of the combined asynchronous calling task, and the calling result includes the return value and / or abnormal result of the callback function of the combined asynchronous calling task.

[0112] Refer to the following Fig.12 The application programming interface calling device 1200 according to this embodiment of the present invention is described. Fig.12 The application programming interface calling device 1200 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0113] The application programming interface calling device 1200 is in the form of a hardware module. The components of the application programming interface calling device 1200 may include but are not limited to: a receiving module 1202 , a determining module 1204 , a calling module 1206 and a packaging module 1208 .

[0114] The receiving module 1202 is used to receive a generic asynchronous call request.

[0115] The determination module 1204 is used to determine the application programming interface used for calling in the generic asynchronous call request.

[0116] The calling module 1206 is used to request the cache area to obtain the generic service of the application programming interface, and execute the generic calling task according to the generic service.

[0117] The encapsulation module 1208 is used to encapsulate the call result of the generic call task into the combined asynchronous call task, and the call result includes the return value and / or exception result of the callback function of the combined asynchronous call task.

[0118] Refer to the following Fig.13 An electronic device 1300 according to this embodiment of the present invention is described. Fig.13 The electronic device 1300 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0119] like Fig.13 As shown, the electronic device 1300 is in the form of a general computing device. The components of the electronic device 1300 may include but are not limited to: at least one processing unit 1310, at least one storage unit 1320, and a bus 1330 connecting different system components (including the storage unit 1320 and the processing unit 1310).

[0120] The storage unit stores program codes, which can be executed by the processing unit 1310, so that the processing unit 1310 executes the steps of various exemplary embodiments of the present invention described in the above "Exemplary Method" section of this specification. For example, the processing unit 1310 can execute the steps of the above-mentioned application programming interface calling method.

[0121] The storage unit 1320 may include a readable medium in the form of a volatile storage unit, such as a random access storage unit (RAM) 13201 and / or a cache storage unit 13202 , and may further include a read-only storage unit (ROM) 13203 .

[0122] The storage unit 1320 may also include a program / utility 13204 having a set (at least one) of program modules 13205, such program modules 13205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.

[0123] Bus 1330 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.

[0124] The electronic device 1300 may also communicate with one or more external devices 1340 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device, and / or may communicate with any device that enables the electronic device 1300 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 1350. Furthermore, the electronic device 1300 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 1360. The network adapter 1360 communicates with other modules of the electronic device 1300 via the bus 1330. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0125] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the implementation of the present disclosure.

[0126] In an exemplary embodiment of the present disclosure, a computer-readable storage medium is also provided, on which a program product capable of implementing the above method of the present specification is stored. In some possible implementations, various aspects of the present invention may also be implemented in the form of a program product, which includes a program code, and when the program product is run on a terminal device, the program code is used to enable the terminal device to execute the steps according to various exemplary embodiments of the present invention described in the above "Exemplary Method" section of the present specification.

[0127] The program product for implementing the above method according to an embodiment of the present invention may adopt a portable compact disk read-only memory (CD-ROM) and include program code, and may be run on a terminal device, such as a personal computer. However, the program product of the present invention is not limited thereto, and in this document, a readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, apparatus, or device.

[0128] Computer readable signal media may include data signals propagated in baseband or as part of a carrier wave, in which readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Readable signal media may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.

[0129] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.

[0130] Program code for performing the operations of the present invention may be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java, C++, etc., and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., through the Internet using an Internet service provider).

[0131] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.

[0132] In addition, although the steps of the method in the present disclosure are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.

[0133] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a mobile terminal, or a network device, etc.) to execute the method according to the implementation of the present disclosure.

[0134] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any modification, use or adaptation of the present disclosure, which follows the general principles of the present disclosure and includes common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the appended claims.

Claims

1. An application programming interface calling method, characterized in that: include: Receive non-generic asynchronous call requests; Determine an application programming interface for invoking in the non-generic asynchronous call request; According to the non-generic asynchronous call request, encapsulating the response monitoring process into the application programming interface to generate an encapsulation interface; Before calling the encapsulation interface, creating a combined asynchronous calling task of the encapsulation interface; In the calling process of the combined asynchronous calling task, encapsulating the calling result of the combined asynchronous calling task, the calling result includes the return value and / or abnormal result of the callback function of the combined asynchronous calling task; Acquire the call request parameters in the non-generic asynchronous call request through the filter of the application programming interface, and save the call request parameters to the local thread variable; Determine a call result parameter according to the call result; Associating the call request parameter with the call result parameter according to the identification information of the call request parameter and the identification information of the call result parameter; A log printing request associated with the call request parameter and the call result parameter is received, and the log printing request is added to the combined asynchronous call task.

2. The method for calling an application programming interface according to claim 1, characterized in that: According to the non-generic asynchronous call request, encapsulating the response listening process into the application programming interface to generate an encapsulation interface includes: Creating the response listening process according to the non-generic asynchronous call request; Saving the response monitoring process to a call status recorder of the application programming interface; The class of the callback function is pre-stored inside the calling thread of the application programming interface, and the class is encapsulated into the application programming interface to generate an encapsulation interface supporting lambda expressions.

3. The method for calling an application programming interface according to claim 1, characterized in that: Also includes: If it is detected that the log printing request is completed, the calling request parameter stored in the local thread variable is cleared.

4. An application programming interface calling device, characterized in that: A receiving module, used for receiving non-generic asynchronous call requests; A determination module, used to determine an application programming interface for calling in the non-generic asynchronous call request; An encapsulation module, used for encapsulating the response monitoring process into the application programming interface according to the non-generic asynchronous call request to generate an encapsulation interface; A calling module, used for creating a combined asynchronous calling task of the encapsulation interface before calling the encapsulation interface; The encapsulation module is further used to encapsulate the calling result of the combined asynchronous calling task during the calling process of the combined asynchronous calling task, wherein the calling result includes the return value and / or abnormal result of the callback function of the combined asynchronous calling task; Acquire the call request parameters in the non-generic asynchronous call request through the filter of the application programming interface, and save the call request parameters to the local thread variable; Determine a call result parameter according to the call result; Associating the call request parameter with the call result parameter according to the identification information of the call request parameter and the identification information of the call result parameter; A log printing request associated with the call request parameter and the call result parameter is received, and the log printing request is added to the combined asynchronous call task.

5. An electronic device, characterized in that: include: processor; as well as A memory, configured to store executable instructions of the processor; The processor is configured to execute the application programming interface calling method according to any one of claims 1 to 3 by executing the executable instructions.

6. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the application programming interface calling method described in any one of claims 1 to 3 is implemented.