Interface calling method, device, equipment and storage medium
By configuring a declarative second interface for each interface, and using the second interface to generate call logs according to the user-defined matching strategy, the problem of redundant information in the logs in the prior art is solved, and efficient and customized log generation and storage are achieved.
Patent Information
- Application Number
- CN202210590858.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-27
- Publication Date
- 2025-06-27
- Estimated Expiration
- 2042-05-27
AI Technical Summary
When generating call logs, the existing open source link tracking system contains a lot of redundant information, which cannot meet the user's log generation needs and occupies storage space.
By configuring a declarative second interface corresponding to each interface, the second interface is used to filter out the information that the user really needs based on the user's customized matching strategy, and an efficient call log is generated.
It realizes customizing log content according to user needs, reducing redundant information, improving storage efficiency, and ensuring that the interface call log can be obtained in real time, supporting fault monitoring.
Smart Images

Figure CN115033397B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of electronic technologies, and in particular, to an interface call method, apparatus, device, and storage medium. Background Art
[0002] Currently, during the operation of a distributed system, a large amount of logs are usually generated. System developers can analyze the logs to troubleshoot system failures and ensure the normal operation of the system.
[0003] In related technologies, when obtaining the logs generated during the operation of a distributed system, an open-source link tracking system is usually used to generate the call logs of each interface in the distributed system.
[0004] However, when the current open-source link tracking system generates call logs, since users cannot modify the log generation method in the link tracking system, the generated call logs include a large amount of redundant information (i.e., information that users do not need to pay attention to), which cannot meet the user's log generation requirements and is likely to occupy a large amount of storage space to store the call logs. Summary of the Invention
[0005] This application provides an interface call method, apparatus, device, and storage medium to solve the problem that the call logs generated by using an open-source link tracking system when an interface in the system is called include a large amount of redundant information in related technologies.
[0006] In a first aspect, this application provides an interface call method, including:
[0007] In response to the generation of a call request for calling a first interface, call a second interface corresponding to the first interface; wherein, the call request is used to indicate obtaining the request result of the first interface, and the call request includes a parameter value corresponding to a first keyword of the second interface;
[0008] Based on the second interface, for each first keyword corresponding to the second interface, determine, according to the first matching strategy corresponding to the first keyword, a parameter value corresponding to the first keyword in the call request; and based on the second interface, use each first keyword and the parameter value corresponding to each first keyword as the call log of the first interface;
[0009] If it is determined that parameter values corresponding to each first keyword corresponding to the second interface are found based on the second interface, then call the first interface and generate a request result corresponding to the call request based on the first interface.
[0010] In some embodiments, there are multiple first matching policies corresponding to the first keyword; the first matching policies have priority information, and the priority information is used to indicate the execution order of the first matching policies; based on the second interface, for each first keyword corresponding to the second interface, according to the first matching policy corresponding to the first keyword, determining parameter values corresponding one by one to the first keyword in the call request includes:
[0011] Based on the second interface, for each first keyword corresponding to the second interface, repeat the following steps until a preset condition is reached: Based on the second interface, determine the currently to-be-executed first matching policy according to the priority information of the first matching policy corresponding to the first keyword; Based on the second interface, determine the matching result of the first keyword in the call request according to the currently to-be-executed first matching policy; The preset condition is: the matching result of the first keyword determined based on the second interface is not empty;
[0012] Use the matching result of the first keyword as the parameter value corresponding one by one to the first keyword.
[0013] In some embodiments, the first matching policy includes: a tag field and a first generation field, wherein the tag field is used to indicate the request data in the call request; the first generation field is used to indicate the processing policy of the request data; The determining, based on the second interface, the matching result of the first keyword in the call request according to the currently to-be-executed first matching policy includes:
[0014] Based on the second interface, perform a matching process in the call request according to the expression of the tag field in the currently to-be-executed first matching policy to obtain the request data in the call request;
[0015] Based on the second interface, process the request data in the call request according to the expression of the first generation field in the currently to-be-executed first matching policy, and use the result obtained after processing as the matching result of the first keyword.
[0016] In some embodiments, the processing, based on the second interface, the request data in the call request according to the field value of the first generation field in the currently to-be-executed first matching policy, and using the result obtained after processing as the matching result of the first keyword includes:
[0017] Based on the second interface, if it is determined that the expression of the first generation field in the currently to-be-executed first matching policy is empty, then use the request data in the call request as the matching result of the first keyword;
[0018] Based on the second interface, if it is determined that the expression of the first generation field in the currently to-be-executed first matching policy is a JsonPath expression, then according to the JsonPath expression, the request data in the call request is parsed and processed, and the result obtained after the parsing and processing is used as the matching result of the first keyword;
[0019] Based on the second interface, if it is determined that the expression of the first generation field in the currently to-be-executed first matching policy is not empty and not a JsonPath expression, then according to the introspection method, the method for obtaining the parameter value indicated by the expression of the first generation field in the request data is determined, and according to the obtaining method, the parameter value indicated by the expression of the first generation field is determined; the parameter value indicated by the expression of the first generation field is used as the matching result of the first keyword.
[0020] In some embodiments, the step of, based on the second interface, if it is determined that the expression of the first generation field in the currently to-be-executed first matching policy is a JsonPath expression, then according to the JsonPath expression, the request data in the call request is parsed and processed, and the result obtained after the parsing and processing is used as the matching result of the first keyword, includes:
[0021] Based on the second interface, if it is determined that a preset symbol is included at a preset position in the expression of the first generation field in the currently to-be-executed first matching policy, then the expression of the first generation field is a JsonPath expression;
[0022] Based on the second interface, according to the JsonPath expression, the request data in the call request is parsed and processed, and the result obtained after the parsing and processing is used as the matching result of the first keyword.
[0023] In some embodiments, the method further includes:
[0024] In response to the first interface generating a request result corresponding to the call request, a second interface corresponding to the first interface is called; the request result includes a parameter value corresponding to a second keyword of the second interface;
[0025] Based on the second interface, for each second keyword corresponding to the second interface, according to the second matching policy corresponding to the second keyword, a parameter value corresponding to the second keyword one by one is determined in the request result; and based on the second interface, each second keyword and the parameter value corresponding to each second keyword one by one are used as the response log of the first interface.
[0026] In some embodiments, the second matching strategy includes: a second generation field; the second generation field is used to indicate the processing method of the request result; based on the second interface, for each second keyword corresponding to the second interface, according to the second matching strategy corresponding to the second keyword, determining parameter values corresponding one by one to the second keyword in the request result includes:
[0027] Based on the second interface, for each second keyword corresponding to the second interface, if it is determined that the expression of the second generation field in the second matching strategy corresponding to the second keyword is empty, then use the request result as the parameter value of the second keyword;
[0028] Based on the second interface, for each second keyword corresponding to the second interface, if it is determined that the expression of the second generation field in the second matching strategy corresponding to the second keyword is a jsonpath expression, then parse the request result according to the jsonpath expression, and use the result obtained after the parsing process as the parameter value of the second keyword;
[0029] Based on the second interface, for each second keyword corresponding to the second interface, if it is determined that the expression of the second generation field in the second matching strategy corresponding to the second keyword is not empty and not a jsonpath expression, then determine the acquisition method of the parameter value indicated by the expression of the second generation field in the request result according to the introspection method, and determine the parameter value indicated by the expression of the second generation field according to the acquisition method; use the parameter value indicated by the expression of the second generation field as the parameter value of the second keyword.
[0030] In some embodiments, the invoking, in response to the generation of a call request for the first interface, of a second interface corresponding one by one to the first interface includes:
[0031] In response to the generation of a call request for the first interface, obtain the interface name of the first interface;
[0032] Based on the interface name of the first interface and a preset corresponding relationship, determine a second interface corresponding one by one to the first interface, and invoke the second interface, where the preset corresponding relationship is used to indicate the corresponding relationship between the interface name of the first interface and the interface name of the second interface.
[0033] In a second aspect, the present application provides an interface calling device, including:
[0034] The first calling unit is configured to call a second interface corresponding to the first interface in response to the generation of a call request for calling the first interface; wherein, the call request is used to indicate obtaining a request result of the first interface, and the call request includes a parameter value corresponding to a first keyword of the second interface;
[0035] The first determining unit is configured to, based on the second interface, for each first keyword corresponding to the second interface, determine, according to a first matching policy corresponding to the first keyword, a parameter value corresponding to the first keyword in the call request;
[0036] The second determining unit is configured to, based on the second interface, use each first keyword and the parameter value corresponding to each first keyword as a call log of the first interface;
[0037] The second calling unit is configured to, if it is determined that parameter values corresponding to each first keyword corresponding to the second interface are found based on the second interface, call the first interface and generate a request result corresponding to the call request based on the first interface.
[0038] In some embodiments, there are multiple first matching policies corresponding to the first keyword; the first matching policy has priority information, and the priority information is used to indicate an execution order of the first matching policy; the first determining unit includes:
[0039] Based on the second interface, for each first keyword corresponding to the second interface, repeat the following first determining module and second determining module until a preset condition is reached:
[0040] The first determining module is configured to, based on the second interface, determine a currently to-be-executed first matching policy according to the priority information of the first matching policy corresponding to the first keyword;
[0041] The second determining module is configured to, based on the second interface, determine a matching result of the first keyword in the call request according to the currently to-be-executed first matching policy; the preset condition is that the matching result of the first keyword is determined to be non-empty based on the second interface;
[0042] The third determining module is configured to use the matching result of the first keyword as the parameter value corresponding to the first keyword one by one.
[0043] In some embodiments, the first matching policy includes: a tag field and a first generation field, wherein the tag field is used to indicate request data in the call request; the first generation field is used to indicate a processing policy of the request data; the second determining module is specifically configured to:
[0044] Based on the second interface, perform matching processing in the call request according to the expression of the tag field in the currently to-be-executed first matching policy to obtain the request data in the call request;
[0045] Based on the second interface, process the request data in the call request according to the expression of the first generation field in the currently to-be-executed first matching policy, and use the result obtained after processing as the matching result of the first keyword.
[0046] In some embodiments, the second determination module is specifically configured to:
[0047] Based on the second interface, if it is determined that the expression of the first generation field in the currently to-be-executed first matching policy is empty, use the request data in the call request as the matching result of the first keyword;
[0048] Based on the second interface, if it is determined that the expression of the first generation field in the currently to-be-executed first matching policy is a jsonpath expression, perform parsing processing on the request data in the call request according to the jsonpath expression, and use the result obtained after parsing processing as the matching result of the first keyword;
[0049] Based on the second interface, if it is determined that the expression of the first generation field in the currently to-be-executed first matching policy is not empty and not a jsonpath expression, determine the method for obtaining the parameter value indicated by the expression of the first generation field in the request data according to the introspection method, and determine the parameter value indicated by the expression of the first generation field according to the obtaining method; use the parameter value indicated by the expression of the first generation field as the matching result of the first keyword.
[0050] In some embodiments, the second determination module is specifically configured to:
[0051] Based on the second interface, if it is determined that a preset symbol is included at a preset position in the expression of the first generation field in the currently to-be-executed first matching policy, the expression of the first generation field is a jsonpath expression;
[0052] Based on the second interface, perform parsing processing on the request data in the call request according to the jsonpath expression, and use the result obtained after parsing processing as the matching result of the first keyword.
[0053] In some embodiments, the apparatus further includes:
[0054] A third calling unit, configured to generate a request result corresponding to the calling request in response to the first interface, and call a second interface corresponding to the first interface one by one; the request result includes a parameter value corresponding to a second keyword of the second interface;
[0055] A third determining unit, configured to, based on the second interface, for each second keyword corresponding to the second interface, determine a parameter value corresponding to the second keyword one by one in the request result according to a second matching policy corresponding to the second keyword;
[0056] A fourth determining unit, configured to, based on the second interface, use each second keyword and a parameter value corresponding to each second keyword one by one as a response log of the first interface.
[0057] In some embodiments, the second matching policy includes: a second generation field; the second generation field is used to indicate a processing manner of the request result; the third determining unit includes:
[0058] A third determining module, configured to, based on the second interface, for each second keyword corresponding to the second interface, if it is determined that an expression of the second generation field in the second matching policy corresponding to the second keyword is empty, use the request result as the parameter value of the second keyword;
[0059] A fourth determining module, configured to, based on the second interface, for each second keyword corresponding to the second interface, if it is determined that an expression of the second generation field in the second matching policy corresponding to the second keyword is a jsonpath expression, perform parsing processing on the request result according to the jsonpath expression, and use a result obtained after the parsing processing as the parameter value of the second keyword;
[0060] A fifth determining module, configured to, based on the second interface, for each second keyword corresponding to the second interface, if it is determined that an expression of the second generation field in the second matching policy corresponding to the second keyword is not empty and is not a jsonpath expression, determine a method for obtaining a parameter value indicated by the expression of the second generation field in the request result according to an introspection manner, and determine the parameter value indicated by the expression of the second generation field according to the obtaining method; use the parameter value indicated by the expression of the second generation field as the parameter value of the second keyword.
[0061] In some embodiments, the first calling unit includes:
[0062] An obtaining module, configured to obtain an interface name of the first interface in response to generation of a calling request for calling the first interface;
[0063] A sixth determination module, configured to determine a second interface that corresponds one-to-one with the first interface based on the interface name of the first interface and a preset correspondence relationship, and call the second interface, where the preset correspondence relationship is used to indicate the correspondence relationship between the interface name of the first interface and the interface name of the second interface.
[0064] In a third aspect, the present application provides an electronic device, including: a memory, a processor;
[0065] The memory; a memory for storing executable instructions of the processor;
[0066] Wherein, the processor is configured to execute the method according to any one of the first aspect based on the executable instructions.
[0067] In a fourth aspect, the present application provides a computer-readable storage medium, in which computer-executable instructions are stored, and when the computer-executable instructions are executed by a processor, they are used to implement the method according to any one of the first aspect.
[0068] In a fifth aspect, the present application provides a computer program product, where the computer program product includes a computer program, and when the computer program is executed by a processor, it implements the method according to any one of the first aspect.
[0069] The interface call method, device, equipment, and storage medium provided by this application. The method includes: in response to the generation of a call request for calling a first interface, calling a second interface that corresponds one-to-one with the first interface; where the call request is used to indicate obtaining the request result of the first interface, and the call request includes a parameter value corresponding to a first keyword of the second interface; based on the second interface, for each first keyword corresponding to the second interface, according to the first matching policy corresponding to the first keyword, determining in the call request a parameter value that corresponds one-to-one with the first keyword; and based on the second interface, taking each first keyword and the parameter value corresponding one-to-one with each first keyword as the call log of the first interface; if it is determined that parameter values corresponding to each first keyword corresponding to the second interface are found based on the second interface, then calling the first interface and generating, based on the first interface, the request result corresponding to the call request. By configuring a declarative second interface for each first interface, and then obtaining the call log of the first interface through the second interface. In this embodiment, the user can customize the first matching policy corresponding to the first keyword in the second interface, so that the user can filter out the information that the user really needs based on the first matching policy. Moreover, in the embodiment of this application, a key-value storage method is used for storage, which can improve the efficiency of the user's subsequent query of the call log. In addition, in this embodiment, after it is determined that the second interface has found parameter values corresponding to each first keyword in the second interface, the first interface is then called, thereby avoiding the situation where when the call request lacks the necessary parameters for calling the first interface, the call to the first interface cannot be realized, or when the second interface fails, the call log of the first interface cannot be obtained in real time, and thus the fault monitoring of the first interface cannot be realized. BRIEF DESCRIPTION OF THE DRAWINGS
[0070] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present application, and are used together with the specification to explain the principles of the present application.
[0071] Figure 1 It is a schematic flowchart of an interface call method provided by an embodiment of the present application;
[0072] Figure 2 It is a schematic flowchart of another interface call method provided by an embodiment of the present application;
[0073] Figure 3 It is a schematic structural diagram of an interface call device provided by an embodiment of the present application;
[0074] Figure 4 It is a schematic structural diagram of an interface call device provided by an embodiment of the present application;
[0075] Figure 5 This is a schematic structural diagram of an electronic device provided in an embodiment of the present application.
[0076] Through the above-mentioned drawings, specific embodiments of the present application have been shown, and more detailed descriptions will be given later. These drawings and textual descriptions are not intended to limit the scope of the concept of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. Specific Embodiments
[0077] Here, exemplary embodiments will be described in detail, and examples are shown in the drawings. When the following description refers to the drawings, unless otherwise indicated, the same numerals in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present application.
[0078] In the description of the present application, it should be understood that terms such as "first", "second", "third", etc. are only used to distinguish similar objects, and do not necessarily need to be used to describe a specific order or sequence, nor can they be understood as indicating or implying relative importance. For those of ordinary skill in the art, the specific meanings of the above terms in the present application can be understood according to specific circumstances. In addition, in the description of the present application, unless otherwise specified, "a plurality of" means two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist simultaneously, and B exists alone. The character " / " generally represents an "or" relationship between the associated objects before and after.
[0079] Currently, during the system development and use process, in order to be able to monitor the running status of each interface in the system in real time, the call logs of each interface are usually obtained, and then the system is monitored for faults based on the call logs of each interface.
[0080] In the related art, when performing fault monitoring, some open-source link tracking systems are usually used, such as the zipkin system, the skywalking system, etc. However, when using the current open-source link tracking systems to generate call logs, the log generation method and log generation format have been fixedly written by the developers of the link tracking systems in the link tracking systems, and users cannot modify them, resulting in a large amount of redundant information that users do not care about in the call logs generated by the above-mentioned link tracking systems, which cannot meet the log generation requirements of users, and the generated call logs will also occupy a large amount of storage space, wasting storage resources.
[0081] The interface call method, device, equipment, and storage medium provided by the present application are used to solve the above technical problems.
[0082] The technical solution of the present application and how the technical solution of the present application solves the above technical problems will be described in detail below with specific embodiments. These several specific embodiments below can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below with reference to the accompanying drawings.
[0083] Figure 1 It is a schematic flowchart of an interface call method provided by an embodiment of the present application. As Figure 1 shown, the method includes the following steps:
[0084] S101. In response to the generation of a call request for calling a first interface, call a second interface that corresponds one-to-one to the first interface; wherein, the call request is used to indicate obtaining the request result of the first interface, and the call request includes a parameter value corresponding to a first keyword of the second interface.
[0085] Exemplarily, the interfaces in this embodiment, that is, application programming interfaces, and the interface call method provided in this embodiment can be applied to a distributed system. For example, when the interfaces corresponding to each microservice included in the distributed system are called. It should be noted that the interface call method provided in this embodiment is not limited to the distributed system, and the above interface call method can be used by other systems provided with interfaces to complete interface calls and generate corresponding call logs.
[0086] The call request in this step is used to represent that it is necessary to call the first interface, and then obtain the request result obtained after the first interface is called. It can be understood that the call request for the first interface can be generated based on a user's operation instruction, or can be generated by other interfaces during the process of continuous interface calls during the operation of the system.
[0087] In order to obtain the call log of the first interface, in this embodiment, when it is determined that a call request for calling the first interface is generated, first, a second interface that corresponds one-to-one to the first interface will be called. Among them, the first interface can be understood as an application programming interface in the system for implementing the system business function (for example, order query function, sales volume statistics function, etc.), and the second interface is an application programming interface for generating the call log of the corresponding first interface.
[0088] In one example, in order to determine the second interface that corresponds one-to-one to the first interface, an annotation can be added at the input parameter of the first interface, and the annotation includes the storage location corresponding to the second interface corresponding to the first interface.
[0089] S102. Based on the second interface, for each first keyword corresponding to the second interface, according to the first matching policy corresponding to the first keyword, determine the parameter value corresponding one by one to the first keyword in the call request.
[0090] Exemplarily, in this embodiment, in order to generate the call log of the first interface, one or more first keywords and the first matching policy corresponding to each first keyword are written in the program of the second interface corresponding one by one to the first interface. Among them, the first matching policy is used to indicate how to match the parameter value of the first keyword corresponding to the first matching policy in the call request of the first interface. That is, based on the second interface, according to the first keyword set in the second interface and the first matching policy corresponding to the first keyword, filter and match the parameter value corresponding to each first keyword in the call request.
[0091] In one example, it can be understood that in the call request, in addition to including the parameters that need to be input to the first interface when calling the first interface, etc., there will also be other redundant information, such as protocol fields for communication between some interfaces and other information that users do not care about. Therefore, when setting the first matching policy corresponding to the first keyword in this embodiment, the user can use the method of how to extract the parameters that the user is concerned about as the first matching policy.
[0092] S103. Based on the second interface, use each first keyword and the parameter value corresponding one by one to each first keyword as the call log of the first interface.
[0093] Exemplarily, in this embodiment, after obtaining each first keyword and the parameter value corresponding one by one to each first keyword, the above first keyword and the parameter value corresponding to the first keyword will be stored correspondingly as the call log of the first interface. That is, the call log generated in this embodiment is stored in a key-value manner for the user to view.
[0094] S104. If it is determined that the parameter value corresponding to each first keyword corresponding to the second interface is found based on the second interface, then call the first interface and generate the request result corresponding to the call request based on the first interface.
[0095] Exemplarily, when it is determined that the second interface finds the parameter value corresponding to each first keyword set in the second interface, at this time, the first interface can be called based on the call request that needs to call the first interface, and then the call result corresponding to the call request can be obtained based on the first call interface.
[0096] In one example, if it is determined that the parameter values corresponding to each first keyword corresponding to the second interface cannot be found based on the second interface, at this time, a prompt message can be sent to the user. Among them, the prompt message can be used to indicate that the generation of the call log of the current first interface fails, which may be due to a failure of the second interface during operation, or a lack of parameter values required to call the first interface in the generated call request for calling the first interface.
[0097] In this embodiment, by configuring a declarative second interface corresponding to each first interface, and then through the second interface, the parameter values corresponding to each first keyword are matched in the call request of the first interface. After that, based on the first keyword and the parameter values corresponding to each first keyword, the call log of the first interface is obtained. In this embodiment, the user can customize the first matching strategy corresponding to the first keyword in the second interface, so that the user can filter out the information that the user really needs based on the first matching strategy. And, in the embodiment of the present application, the key-value storage method is used for storage, which can improve the efficiency of the user's subsequent query of the call log. In addition, in this embodiment, after it is determined that the second interface has found the parameter values corresponding to each first keyword in the second interface, the first interface is called, thereby avoiding the situation where the call to the first interface cannot be realized when the call request lacks the necessary parameters for calling the first interface, or when the second interface fails, the call log of the first interface cannot be obtained in real time, and thus the fault monitoring of the first interface cannot be realized.
[0098] Figure 2 It is a schematic flowchart of another interface call method provided by the embodiment of the present application. As Figure 2 shown, the method includes the following steps:
[0099] S201. In response to the generation of a call request for calling a first interface, obtain the interface name of the first interface.
[0100] Exemplarily, when a call request for calling a first interface is generated, in order to determine the second interface corresponding one-to-one to the first interface, in this embodiment, the interface name of the first interface can be obtained first. Among them, the call request may include the interface name of the first interface to be called, or the call request includes the interface address of the first interface to be called, and then based on the interface address, the interface name of the first interface is further determined.
[0101] S202. Based on the interface name of the first interface and a preset correspondence, determine the second interface corresponding one-to-one to the first interface, and call the second interface. The preset correspondence is used to indicate the correspondence between the interface name of the first interface and the interface name of the second interface.
[0102] Exemplarily, after obtaining the name of the first interface, based on a preset correspondence relationship including the name of the first interface and the name of the second interface, the second interface to be called can be determined, and the call to the second interface can be executed.
[0103] In one example, when determining the name for each second interface, the correspondence relationship between the name of the first interface and the name of the second interface can be set by adding a unified suffix after the name of the corresponding first interface, so that the second interface corresponding to the first interface to be called can be quickly determined.
[0104] It can be understood that in this embodiment, since different interfaces in the same system need to have different names, that is, the names of the interfaces have the characteristic of uniqueness, the second interface corresponding to the first interface is determined through the correspondence relationship between the interface names, thereby improving the accuracy of the obtained second interface, so as to obtain the call log of the first interface required by the user.
[0105] After step S202, based on the second interface, for each first keyword corresponding to the second interface, the following steps S203 and S204 are repeated until a preset condition is met: The preset condition is: The matching result of the first keyword determined based on the second interface is not empty; multiple first matching policies corresponding to the first keyword; The first matching policy has priority information, and the priority information is used to indicate the execution order of the first matching policy.
[0106] S203. Based on the second interface, according to the priority information of the first matching policy corresponding to the first keyword, determine the currently to-be-executed first matching policy.
[0107] Exemplarily, in this embodiment, multiple first matching policies can be correspondingly set for each first keyword in the second interface. It can be understood that the first interface may be used in different application scenarios, and in different application scenarios, the call requests for indicating the call of the first interface may adopt different data encapsulation methods to encapsulate the parameter values corresponding to the first keyword that the user needs to obtain. Therefore, multiple first matching policies can be set for each first interface to correspond to the methods of extracting the parameter values corresponding to the first keyword in the call request under different encapsulation methods.
[0108] Moreover, in this embodiment, the first matching policy corresponding to the first keyword also has priority information, where the priority information of the first matching policy is used to indicate the execution order of the first matching policy when determining the parameter value of the first keyword corresponding to the first matching policy. In one example, when determining the priority information of the first matching policy, it can be determined based on the call frequency of the first interface in different application scenarios, thereby improving the efficiency of generating the call log.
[0109] S204. Based on the second interface, determine the matching result of the first keyword in the call request according to the first matching policy to be currently executed; the call request includes parameter values corresponding to the first keyword of the second interface.
[0110] Exemplarily, after determining the second interface to be called, for each first keyword corresponding to the second interface, first, the execution order of the first matching policies can be determined according to the priority information of each first matching policy corresponding to the first keyword. Then, based on the execution order of the first matching policies, the first matching policies are executed in sequence. If, based on a certain first matching policy, the matching result of the first keyword in the call request indicates that the matching result is not empty, then at this time, the execution of the remaining unexecuted first matching policies can be stopped.
[0111] In some embodiments, the first matching policy includes: a tag field and a first generation field, where the tag field is used to indicate the request data in the call request; the first generation field is used to indicate the processing policy of the request data. Step S204 specifically includes the following steps:
[0112] The first step of step S204: Based on the second interface, perform a matching process in the call request according to the expression of the tag field in the first matching policy to be currently executed, and obtain the request data in the call request.
[0113] The second step of step S204: Based on the second interface, process the request data in the call request according to the expression of the first generation field in the first matching policy to be currently executed, and use the result obtained after processing as the matching result of the first keyword.
[0114] Exemplarily, in this embodiment, a setting method of the first matching policy is given. In the first matching policy, there are a tag field and a first generation field. It can be understood that the call request usually includes multiple request data, and each request data corresponds to its own field identifier. Therefore, in the first matching policy, the expression of the tag field can be set so that the request data to be obtained can be determined in the call request based on the expression of the tag field. That is, the expression corresponding to the tag field in the first matching policy is matched with each field identifier in the call request. When the expression successfully matches a certain field identifier, at this time, the request data corresponding to the field identifier is the request data to be obtained.
[0115] In addition, a first generation field is also set in the first matching policy. The first generation field can be used to indicate the method of determining the parameter value corresponding to the first keyword in the request data, that is, the processing policy for the request data. For example, since the data encapsulation methods in different call requests are different, and the parameter values corresponding to different first keywords to be determined are also different in the data encapsulation method of the same call request, therefore, in this embodiment, different processing policies can be indicated by setting the first generation field in the first matching policy, so as to be suitable for the extraction of the parameter values of different first keywords.
[0116] For example, in one possible case, the expression corresponding to the first generation field can be used as a policy identifier for characterizing the processing policy that needs to be executed on the determined request data. Through this policy identifier, the code segment of the processing policy corresponding to this policy identifier can be found.
[0117] It can be understood that in this embodiment, the request data in the call request is filtered by setting a label field in the first matching policy, thereby improving the efficiency of subsequently determining the parameter value corresponding to the first keyword. And by setting a first generation field in the first matching policy to characterize the processing policy of the request data corresponding to this first matching policy, it can be ensured that this first matching policy can be applicable to the data encapsulation method of the request data determined by this first matching policy, thereby improving the accuracy of the obtained parameter value corresponding to the first keyword.
[0118] In some embodiments, when performing the second step of step S204, it can be implemented through the following steps:
[0119] Based on the second interface, if it is determined that the expression of the first generation field in the currently to-be-executed first matching policy is empty, the request data in the call request is used as the matching result of the first keyword;
[0120] Based on the second interface, if it is determined that the expression of the first generation field in the currently to-be-executed first matching policy is a jsonpath expression, the request data in the call request is parsed and processed according to the jsonpath expression, and the result obtained after the parsing and processing is used as the matching result of the first keyword;
[0121] Based on the second interface, if it is determined that the expression of the first generation field in the currently to-be-executed first matching policy is not empty and not a jsonpath expression, the method for obtaining the parameter value indicated by the expression of the first generation field in the request data is determined according to the introspection method, and according to the obtaining method, the parameter value indicated by the expression of the first generation field is determined; the parameter value indicated by the expression of the first generation field is used as the matching result of the first keyword.
[0122] Exemplarily, when processing the call data in the call request determined based on the tag field in the first matching policy, first, the processing policy can be determined based on the first generation field included in the first matching policy. Specifically, it can be divided into the following three cases:
[0123] In the first case: when the expression of the first generation field included in the first matching policy is empty, at this time, the first interface will use the request data in the call request generated by the first interface as the matching result of the first keyword corresponding to this first matching policy, that is, at this time, there is no need to process the request data in the call request generated by the first interface.
[0124] In the second case: when the expression of the first generation field included in the first matching policy is a jsonpath expression, at this time, the first interface directly parses the request data in the call request generated by the first interface based on the jsonpath expression corresponding to the first generation field, and then parses the parameter value indicated by this jsonpath expression in the request data in the call request, and uses the found parameter value as the matching result of the first keyword corresponding to this first matching policy.
[0125] In the third case: when the expression of the first generation field included in the first matching policy is not empty and is not a jsonpath expression, at this time, based on the expression of the first generation field, in an introspective way, the parameter value indicated by the expression of the first generation field can be determined in the request data in the call request. Specifically, first, the method for obtaining the parameter value corresponding to the expression of the first generation field can be determined, and then based on the determined obtaining method, the parameter value indicated by the expression of the first generation field can be found in the request data in the call request; then, the determined parameter value is used as the matching result of the first keyword.
[0126] For example, the following is a code snippet for generating call logs in a second interface:
[0127]
[0128]
[0129] Among them, the expression after "key" is used to represent the first keyword. There are three first keywords in this code snippet, namely "dId", "uId", and "ipm". Each first keyword corresponds to its own first matching strategy (identified by Candidate). And in the first matching strategy, there are also label fields (identified by paramName), first generation fields (identified by expr), and priority represents the priority information of the first matching strategy corresponding to the same first keyword. For the first keyword "dId", the expressions of the label fields in the two first matching strategies are identified by the following character "request" in the above code snippet, and the expression of the first generation field in this first matching strategy is identified by the following character "deviceId" in the above code snippet. At this time, based on the introspection method, the acquisition method of the parameter value indicated by "deviceId" can be obtained, and based on the determined acquisition method, the matching result corresponding to the first keyword "dId" can be determined in the request data corresponding to "request". If the matching result is empty, the next matching strategy will be continued, that is, the strategy where the expression of the first generation field is identified by the following character "$.dId" in the above code snippet. Since there is a symbol "$" at the first character in "$.dId", it indicates that the expression of this first generation field is a jsonpath expression, and the matching result corresponding to the first keyword "dId" can be directly determined in the request result based on this jsonpath expression.
[0130] For the first matching strategy corresponding to the first keyword "ipm", in this first matching strategy, the expression corresponding to the first generation field is empty, that is, there is no such first generation field in this first matching strategy. Then, at this time, the request data corresponding to the expression "request" of the label field in the call request can be directly used as the matching result corresponding to the first keyword "ipm".
[0131] In addition, in the actual application process, when the parameter value corresponding to the first keyword to be obtained in the request data in the call request is of a simple pojo type, the parameter value can be obtained through the introspection method. When the parameter value corresponding to the first keyword to be obtained in the request data in the call request is a complex javabean object, the jsonpath expression is used to obtain the parameter value.
[0132] In this embodiment, by setting different expressions of the first generation fields in the first matching strategies corresponding to different first keywords, and then setting different expressions of the first generation fields corresponding to different parameter value encapsulation methods, the accuracy of the parameter value corresponding to the first keyword finally matched in the call request can be improved.
[0133] In some embodiments, when determining whether the expression of the first generation field in the first matching policy to be currently executed is a JsonPath expression, at this time, it can be determined in the following manner: Based on the second interface, if it is determined that a preset symbol is included at the preset position of the expression of the first generation field in the first matching policy to be currently executed, then the expression of the first generation field is a JsonPath expression.
[0134] Exemplarily, in this embodiment, when determining whether the expression of the first generation field is a JsonPath expression, at this time, it can be determined whether a preset symbol is included at the preset position in the expression of the first generation field. For example, whether the first character of the expression is the "$" symbol. If the first character is the "$" symbol, then the expression of the first generation field is a JsonPath expression.
[0135] It can be understood that in this embodiment, through the above-mentioned method for determining the JsonPath expression, the accuracy of the determination result of the JsonPath expression can be improved, and further, the accuracy of the parameter value corresponding to the first keyword obtained can be improved.
[0136] S205. Use the matching result of the first keyword as the parameter value corresponding to the first keyword one by one.
[0137] Exemplarily, when the matching result of the first keyword indicates that the matching result is not empty, at this time, the matching result corresponding to the first keyword can be used as the parameter value corresponding to the first keyword one by one.
[0138] It can be understood that in this embodiment, by setting priority information for each first matching policy corresponding to the first keyword, the parameter value corresponding to the first keyword can be quickly determined, thereby improving the generation efficiency of the call log of the first interface. In addition, each first matching policy corresponding to the first keyword can be determined based on the data encapsulation method of the call request of the first interface in different application scenarios, so that the second interface can accurately obtain the call log corresponding to the first interface in different application scenarios of the first interface.
[0139] S206. Based on the second interface, use each first keyword and the parameter value corresponding to each first keyword one by one as the call log of the first interface.
[0140] Exemplarily, for this step, reference can be made to step S103, and the specific principle will not be elaborated here.
[0141] S207. If it is determined that the parameter value corresponding to each first keyword corresponding to the second interface is found based on the second interface, then call the first interface and generate a request result corresponding to the call request based on the first interface.
[0142] Exemplarily, this step can refer to step S104, and the specific principle will not be elaborated herein.
[0143] S208. In response to the request result corresponding to the call request generated by the first interface, call the second interface that corresponds one-to-one to the first interface; the request result includes the parameter value corresponding to the second keyword of the second interface.
[0144] Exemplarily, in this embodiment, after the call log corresponding to the call request is generated by the first interface, at this time, a response log of the first interface can also be generated based on the second interface. Specifically, after determining the request result corresponding to the call request generated by the first interface, at this time, continue to execute the call of the second interface that corresponds one-to-one to the first interface.
[0145] S209. Based on the second interface, for each second keyword corresponding to the second interface, according to the second matching policy corresponding to the second keyword, determine the parameter value corresponding one-to-one to the second keyword in the request result; and based on the second interface, use each second keyword and the parameter value corresponding one-to-one to each second keyword as the response log of the first interface.
[0146] Exemplarily, in this embodiment, the second interface can also be provided with a second keyword and a second matching policy corresponding to the second keyword, wherein the second matching policy can be used to indicate how to determine the parameter value of the second keyword corresponding to the second matching policy in the call request. And, one or more second keywords can be set in the second interface, and no specific limitation is made in this embodiment. After determining the parameter value of the second keyword corresponding to the second interface based on the second interface, each second keyword and the parameter value corresponding to each second keyword can be stored in the key-value manner as the response log of the first interface.
[0147] It can be understood that the second interface can also be provided with a second keyword and a second matching policy corresponding to the second keyword, so that after the call of the first interface is completed, based on the second matching policy set in the second interface, the parameter value of the second keyword corresponding to the second interface can be matched in the request result generated by the first interface, and then the response log of the first interface can be obtained. Through the above method, the user can determine whether the first interface fails during the response call based on the response log of the first interface. In addition, by simultaneously setting the first keyword in the call log of the same first interface and the second keyword in the response log in the second interface, it is possible to reduce and avoid setting a relatively large number of second interfaces, and reduce the storage space for storing the corresponding relationship between the first interface and the second interface.
[0148] In some embodiments, the second matching strategy includes: a second generation field; the second generation field is used to indicate the processing method of the request result; when performing the step "based on the second interface, for each second keyword corresponding to the second interface, according to the second matching strategy corresponding to the second keyword, determine the parameter value corresponding to the second keyword one by one in the request result" in step S209, it can be implemented through the following steps:
[0149] Based on the second interface, for each second keyword corresponding to the second interface, if it is determined that the expression of the second generation field in the second matching strategy corresponding to the second keyword is empty, then use the request result as the parameter value of the second keyword;
[0150] Based on the second interface, for each second keyword corresponding to the second interface, if it is determined that the expression of the second generation field in the second matching strategy corresponding to the second keyword is a jsonpath expression, then parse and process the request result according to the jsonpath expression, and use the result obtained after the parsing and processing as the parameter value of the second keyword;
[0151] Based on the second interface, for each second keyword corresponding to the second interface, if it is determined that the expression of the second generation field in the second matching strategy corresponding to the second keyword is not empty and not a jsonpath expression, then determine the acquisition method of the parameter value indicated by the expression of the second generation field in the request result according to the introspection method, and determine the parameter value indicated by the expression of the second generation field according to the acquisition method; use the parameter value indicated by the expression of the second generation field as the parameter value of the second keyword.
[0152] Exemplarily, in this embodiment, since the request result generated by the first interface usually only includes the return data corresponding to one field identifier, therefore, compared with the first matching strategy, there is no need to set a label field in the second matching strategy, and only the second generation field needs to be set in the second matching strategy, and the second generation field is used to characterize how to process the request result to obtain the parameter value corresponding to the second keyword included in the request result.
[0153] Specifically, it can be divided into the following three cases:
[0154] In one case: when the expression of the second generation field included in the second matching strategy is empty, at this time, the second interface will use the request result generated by the first interface as the parameter value of the second keyword corresponding to this second matching strategy, that is, at this time, there is no need to process the request result generated by the first interface.
[0155] In the second case: When the expression of the second generation field included in the second matching policy is a JsonPath expression, at this time, the second interface directly parses the request result generated by the first interface based on the JsonPath expression corresponding to the second generation field, and then parses the parameter value indicated by the JsonPath expression in the request result, and uses the found parameter value as the parameter value of the second keyword corresponding to the second matching policy.
[0156] In the third case: When the expression of the second generation field included in the second matching policy is not empty and is not a JsonPath expression, at this time, based on the expression of the second generation field, the introspection method can be used to determine the parameter value indicated by the expression of the second generation field in the request result. Specifically, first, the method for obtaining the parameter value corresponding to the expression of the second generation field can be determined, and then based on the determined obtaining method, the parameter value indicated by the expression of the second generation field is found in the request result; then, the determined parameter value is used as the parameter value of the second keyword. For example, the following is a code snippet for generating response logs in the second interface: retLog = {@TraceLog(key = "code", candidates = {@Candidate(expr = "$.retCode")}),
[0157] @TraceLog(key = "msg", candidates = {@Candidate(expr = "retInfo")})}
[0158] Among them, the expression after "key" is used to represent the second keyword. There are two second keywords in this code snippet, namely "code" and "msg". Each second keyword corresponds to its own second matching strategy (identified by "candidates"). And the second matching strategy also includes a second generation field (identified by "expr"). The expression of the second generation field in the second matching strategy corresponding to the second keyword "code" is identified by the following characters "$.retCode" in the above code snippet. Since the symbol "$" is set at the first character in "$.retCode", it indicates that the expression of this second generation field is a jsonpath expression, and based on this jsonpath expression, the parameter value corresponding to the second keyword "code" can be directly determined in the request result. In addition, the expression of the second generation field in the second matching strategy corresponding to the second keyword "msg" is identified by the following characters "retInfo" in the above code snippet. At this time, the method for obtaining the parameter value indicated by "retInfo" can be obtained through introspection, and based on the determined obtaining method, the parameter value corresponding to the second keyword "msg" can be determined in the request result.
[0159] In some embodiments, after generating the response log based on the second interface, the request result generated based on the first interface can be returned to the invoker of the first interface to achieve result feedback.
[0160] In this embodiment, different expressions of the second generation field can be set in the second matching strategies corresponding to different second keywords. When the parameter value corresponding to the second keyword to be obtained in the request result is a simple pojo type, the parameter value can be obtained through introspection. When the parameter value corresponding to the second keyword to be obtained in the request result is a complex javabean object, the jsonpath expression is used to obtain the parameter value. Furthermore, for different encapsulation methods of the parameter values, different expressions corresponding to the second generation field are set to improve the accuracy of the parameter value corresponding to the second keyword finally matched in the request result.
[0161] Figure 3 The following is a schematic structural diagram of an interface calling device provided by an embodiment of the present application, as Figure 3 shown. The device includes:
[0162] A first calling unit 31, configured to call a second interface corresponding to the first interface in response to the generation of a call request for calling the first interface; wherein, the call request is used to indicate obtaining the request result of the first interface, and the call request includes a parameter value corresponding to the first keyword of the second interface.
[0163] The first determination unit 32 is configured to, based on the second interface, for each first keyword corresponding to the second interface, determine, according to the first matching policy corresponding to the first keyword, the parameter value corresponding to the first keyword one by one in the call request;
[0164] The second determination unit 33 is configured to, based on the second interface, use each first keyword and the parameter value corresponding to each first keyword one by one as the call log of the first interface;
[0165] The second call unit 34 is configured to, if it is determined that the parameter values corresponding to each first keyword corresponding to the second interface are found based on the second interface, call the first interface and generate a request result corresponding to the call request based on the first interface.
[0166] The device provided in this embodiment is used to implement the technical solution provided by the above method, and its implementation principle and technical effect are similar, which will not be elaborated here.
[0167] Figure 4 FIG. is a schematic structural diagram of an interface call device provided by an embodiment of the present application. On the basis of the structure of the device shown in Figure 3 Multiple first matching policies corresponding to the first keyword; the first matching policy has priority information, and the priority information is used to indicate the execution order of the first matching policy; the first determination unit 32 includes:
[0168] Based on the second interface, for each first keyword corresponding to the second interface, repeat the following first determination module 321 and second determination module 322 until a preset condition is reached:
[0169] The first determination module 321 is configured to, based on the second interface, determine the currently to-be-executed first matching policy according to the priority information of the first matching policy corresponding to the first keyword;
[0170] The second determination module 322 is configured to, based on the second interface, determine the matching result of the first keyword in the call request according to the currently to-be-executed first matching policy; the preset condition is that the matching result of the first keyword is determined to be non-empty based on the second interface;
[0171] The third determination module 323 is configured to use the matching result of the first keyword as the parameter value corresponding to the first keyword one by one.
[0172] In some embodiments, the first matching policy includes: a tag field and a first generation field, where the tag field is used to indicate the request data in the call request; the first generation field is used to indicate the processing policy of the request data; the second determination module 322 is specifically configured to:
[0173] Based on the second interface, perform matching processing in the call request according to the expression of the tag field in the currently to-be-executed first matching policy to obtain the request data in the call request;
[0174] Based on the second interface, process the request data in the call request according to the expression of the first generation field in the currently to-be-executed first matching policy, and use the result obtained after processing as the matching result of the first keyword.
[0175] In some embodiments, the second determination module 322 is specifically configured to:
[0176] Based on the second interface, if it is determined that the expression of the first generation field in the currently to-be-executed first matching policy is empty, then use the request data in the call request as the matching result of the first keyword;
[0177] Based on the second interface, if it is determined that the expression of the first generation field in the currently to-be-executed first matching policy is a jsonpath expression, then perform parsing processing on the request data in the call request according to the jsonpath expression, and use the result obtained after parsing processing as the matching result of the first keyword;
[0178] Based on the second interface, if it is determined that the expression of the first generation field in the currently to-be-executed first matching policy is not empty and not a jsonpath expression, then determine the method for obtaining the parameter value indicated by the expression of the first generation field in the request data according to the introspection method, and determine the parameter value indicated by the expression of the first generation field according to the obtaining method; use the parameter value indicated by the expression of the first generation field as the matching result of the first keyword.
[0179] In some embodiments, the second determination module 322 is specifically configured to:
[0180] Based on the second interface, if it is determined that a preset symbol is included at a preset position in the expression of the first generation field in the currently to-be-executed first matching policy, then the expression of the first generation field is a jsonpath expression;
[0181] Based on the second interface, perform parsing processing on the request data in the call request according to the jsonpath expression, and use the result obtained after parsing processing as the matching result of the first keyword.
[0182] In some embodiments, the apparatus further includes:
[0183] The third call unit 35 is configured to, in response to the first interface generating a request result corresponding to the call request, call the second interface corresponding to the first interface one by one; the request result includes the parameter value corresponding to the second keyword of the second interface;
[0184] A third determination unit 36, configured to, based on the second interface, for each second keyword corresponding to the second interface, determine, according to the second matching policy corresponding to the second keyword, a parameter value corresponding one-to-one to the second keyword in the request result;
[0185] A fourth determination unit 37, configured to, based on the second interface, use each second keyword and the parameter value corresponding one-to-one to each second keyword as the response log of the first interface.
[0186] In some embodiments, the second matching policy includes: a second generation field; the second generation field is used to indicate the processing manner of the request result; the third determination unit 36 includes:
[0187] A third determination module 361, configured to, based on the second interface, for each second keyword corresponding to the second interface, if it is determined that the expression of the second generation field in the second matching policy corresponding to the second keyword is empty, use the request result as the parameter value of the second keyword;
[0188] A fourth determination module 362, configured to, based on the second interface, for each second keyword corresponding to the second interface, if it is determined that the expression of the second generation field in the second matching policy corresponding to the second keyword is a jsonpath expression, parse and process the request result according to the jsonpath expression, and use the result obtained after the parsing and processing as the parameter value of the second keyword;
[0189] A fifth determination module 363, configured to, based on the second interface, for each second keyword corresponding to the second interface, if it is determined that the expression of the second generation field in the second matching policy corresponding to the second keyword is not empty and not a jsonpath expression, determine, according to the introspection method, the obtaining method of the parameter value indicated by the expression of the second generation field in the request result, and determine the parameter value indicated by the expression of the second generation field according to the obtaining method; use the parameter value indicated by the expression of the second generation field as the parameter value of the second keyword.
[0190] In some embodiments, the first calling unit 31 includes:
[0191] An obtaining module 311, configured to, in response to the generation of a calling request for calling the first interface, obtain the interface name of the first interface;
[0192] A sixth determination module 312, configured to, based on the interface name of the first interface and a preset corresponding relationship, determine a second interface corresponding one-to-one to the first interface, and call the second interface, where the preset corresponding relationship is used to indicate the corresponding relationship between the interface name of the first interface and the interface name of the second interface.
[0193] The device provided in this embodiment is used to implement the technical solution provided by the above method, and its implementation principle and technical effects are similar, so they will not be elaborated here.
[0194] This application provides an electronic device, including: a memory and a processor;
[0195] The memory; a memory for storing executable instructions that can be executed by the processor;
[0196] Wherein, the processor is used to execute the method according to the executable instructions.
[0197] Figure 5 is a schematic structural diagram of an electronic device provided in an embodiment of this application. As Figure 5 shown, the electronic device includes:
[0198] A processor 291, and the electronic device further includes a memory 292; it may also include a communication interface 293 and a bus 294. Among them, the processor 291, the memory 292, and the communication interface 293 can complete communication with each other through the bus 294. The communication interface 293 can be used for information transmission. The processor 291 can call the logical instructions in the memory 294 to execute the method of the above embodiment.
[0199] In addition, when the logical instructions in the above-mentioned memory 292 are implemented in the form of a software functional unit and sold or used as an independent product, they can be stored in a computer-readable storage medium.
[0200] The memory 292, as a computer-readable storage medium, can be used to store software programs and computer-executable programs, such as the program instructions / modules corresponding to the method in the embodiment of this application. The processor 291 executes the functions and data processing by running the software programs, instructions, and modules stored in the memory 292, that is, to implement the method in the above method embodiment.
[0201] The memory 292 may include a program storage area and a data storage area. Among them, the program storage area can store an operating system and application programs required for at least one function; the data storage area can store data created according to the use of the terminal device, etc. In addition, the memory 292 may include a high-speed random access memory and may also include a non-volatile memory.
[0202] This application provides a computer-readable storage medium, in which computer-executable instructions are stored, and when the computer-executable instructions are executed by a processor, they are used to implement the method of any one of the above.
[0203] A computer program product of the present application, the computer program product includes a computer program, and the computer program implements the method of any one when executed by a processor.
[0204] Those skilled in the art will readily conceive of other embodiments of the present application after considering the specification and practicing the invention disclosed herein. The present application is intended to cover any variations, uses, or adaptations of the present application, which follow the general principles of the present application and include well-known common general knowledge or conventional technical means in the technical field not disclosed in the present application. The specification and examples are only regarded as exemplary, and the true scope and spirit of the present application are pointed out by the appended claims.
[0205] It should be understood that the present application is not limited to the exact structures described above and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present application is only limited by the appended claims.
Claims
1. An interface call method, characterized in that, Including: In response to the generation of a call request for calling a first interface, call a second interface that corresponds one-to-one to the first interface; wherein, the call request is used to indicate obtaining a request result of the first interface, and the call request includes a parameter value corresponding to a first keyword of the second interface. Based on the second interface, for each first keyword corresponding to the second interface, according to a first matching policy corresponding to the first keyword, determine a parameter value corresponding one-to-one to the first keyword in the call request; and based on the second interface, use each first keyword and the parameter value corresponding one-to-one to each first keyword as a call log of the first interface. If it is determined that parameter values corresponding to each first keyword corresponding to the second interface are found based on the second interface, then call the first interface and generate a request result corresponding to the call request based on the first interface. Multiple first matching policies corresponding to the first keyword; the first matching policy has priority information, and the priority information is used to indicate an execution order of the first matching policy; based on the second interface, for each first keyword corresponding to the second interface, according to the first matching policy corresponding to the first keyword, determining a parameter value corresponding one-to-one to the first keyword in the call request includes: Based on the second interface, for each first keyword corresponding to the second interface, repeat the following steps until a preset condition is met: Based on the second interface, according to the priority information of the first matching policy corresponding to the first keyword, determine a currently to-be-executed first matching policy; based on the second interface, according to the currently to-be-executed first matching policy, determine a matching result of the first keyword in the call request; the preset condition is that the matching result of the first keyword determined based on the second interface is not empty. Use the matching result of the first keyword as the parameter value corresponding one-to-one to the first keyword.
2. The method according to claim 1, characterized in that, The first matching policy includes: a tag field and a first generation field, wherein the tag field is used to indicate request data in the call request; the first generation field is used to indicate a processing policy for the request data; based on the second interface, according to the currently to-be-executed first matching policy, determining the matching result of the first keyword in the call request includes: Based on the second interface, perform a matching process in the call request according to an expression of the tag field in the currently to-be-executed first matching policy to obtain the request data in the call request. Based on the second interface, process the request data in the call request according to an expression of the first generation field in the currently to-be-executed first matching policy, and use the result obtained after the processing as the matching result of the first keyword.
3. The method according to claim 2, wherein The based on the second interface, processing the request data in the call request according to a field value of the first generation field in the currently to-be-executed first matching policy, and using the result obtained after the processing as the matching result of the first keyword includes: Based on the second interface, if it is determined that the expression of the first generated field in the currently to-be-executed first matching policy is empty, the request data in the call request is used as the matching result of the first keyword; Based on the second interface, if it is determined that the expression of the first generated field in the currently to-be-executed first matching policy is a JsonPath expression, the request data in the call request is parsed according to the JsonPath expression, and the result obtained after the parsing process is used as the matching result of the first keyword; Based on the second interface, if it is determined that the expression of the first generated field in the currently to-be-executed first matching policy is not empty and not a JsonPath expression, the method for obtaining the parameter value indicated by the expression of the first generated field in the request data is determined according to the introspection method, and the parameter value indicated by the expression of the first generated field is determined according to the obtaining method; the parameter value indicated by the expression of the first generated field is used as the matching result of the first keyword.
4. The method according to claim 3, wherein The "Based on the second interface, if it is determined that the expression of the first generated field in the currently to-be-executed first matching policy is a JsonPath expression, the request data in the call request is parsed according to the JsonPath expression, and the result obtained after the parsing process is used as the matching result of the first keyword" includes: Based on the second interface, if it is determined that a preset symbol is included at a preset position in the expression of the first generated field in the currently to-be-executed first matching policy, the expression of the first generated field is a JsonPath expression; Based on the second interface, the request data in the call request is parsed according to the JsonPath expression, and the result obtained after the parsing process is used as the matching result of the first keyword.
5. The method according to claim 1, characterized in that The method further includes: In response to the first interface generating a request result corresponding to the call request, a second interface corresponding one-to-one to the first interface is called; the request result includes a parameter value corresponding to a second keyword of the second interface; Based on the second interface, for each second keyword corresponding to the second interface, a parameter value corresponding one-to-one to the second keyword is determined in the request result according to the second matching policy corresponding to the second keyword; and based on the second interface, each second keyword and the parameter value corresponding one-to-one to each second keyword are used as the response log of the first interface.
6. The method according to claim 5, wherein The second matching policy includes: a second generated field; the second generated field is used to indicate the processing method of the request result; the "Based on the second interface, for each second keyword corresponding to the second interface, a parameter value corresponding one-to-one to the second keyword is determined in the request result according to the second matching policy corresponding to the second keyword" includes: Based on the second interface, for each second keyword corresponding to the second interface, if it is determined that the expression of the second generated field in the second matching policy corresponding to the second keyword is empty, then use the request result as the parameter value of the second keyword; Based on the second interface, for each second keyword corresponding to the second interface, if it is determined that the expression of the second generated field in the second matching policy corresponding to the second keyword is a jsonpath expression, then parse the request result according to the jsonpath expression, and use the result obtained after the parsing process as the parameter value of the second keyword; Based on the second interface, for each second keyword corresponding to the second interface, if it is determined that the expression of the second generated field in the second matching policy corresponding to the second keyword is not empty and not a jsonpath expression, then determine the method for obtaining the parameter value indicated by the expression of the second generated field in the request result according to the introspection method, and determine the parameter value indicated by the expression of the second generated field according to the obtaining method; use the parameter value indicated by the expression of the second generated field as the parameter value of the second keyword.
7. The method according to any one of claims 1 to 6, characterized in that The generation of a call request for invoking the first interface, and invoking a second interface that corresponds one-to-one with the first interface includes: In response to the generation of a call request for invoking the first interface, obtain the interface name of the first interface; Based on the interface name of the first interface and a preset correspondence, determine the second interface that corresponds one-to-one with the first interface, and invoke the second interface, where the preset correspondence is used to indicate the correspondence between the interface name of the first interface and the interface name of the second interface.
8. An interface call device, characterized in that, Includes: A first invocation unit, configured to, in response to the generation of a call request for invoking the first interface, invoke a second interface that corresponds one-to-one with the first interface; wherein, the call request is used to indicate obtaining the request result of the first interface, and the call request includes parameter values corresponding to the first keyword of the second interface; A first determination unit, configured to, based on the second interface, for each first keyword corresponding to the second interface, determine, according to the first matching policy corresponding to the first keyword, the parameter value that corresponds one-to-one with the first keyword in the call request; A second determination unit, configured to, based on the second interface, use each first keyword and the parameter value that corresponds one-to-one with each first keyword as the call log of the first interface; A second invocation unit, configured to, if it is determined that parameter values corresponding to each first keyword corresponding to the second interface are found based on the second interface, then invoke the first interface and generate a request result corresponding to the call request based on the first interface; Multiple first matching policies corresponding to the first keyword; the first matching policy has priority information, and the priority information is used to indicate the execution order of the first matching policy; the first determination unit includes: Based on the second interface, for each first keyword corresponding to the second interface, repeat the following first determination module and second determination module until a preset condition is reached: The first determination module is configured to determine a currently to-be-executed first matching policy based on the second interface and according to the priority information of the first matching policy corresponding to the first keyword; The second determination module is configured to determine a matching result of the first keyword in the call request based on the second interface and according to the currently to-be-executed first matching policy; the preset condition is that the matching result of the first keyword determined based on the second interface is not empty; The third determination module is configured to use the matching result of the first keyword as a parameter value corresponding one by one to the first keyword.
9. An electronic device, characterized in that, Comprising: A memory, a processor, and a computer program; Wherein, the processor can process instructions executed within the computer system; The computer program is stored in the memory and is configured to be executed by the processor to implement the method according to any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, Computer-executable instructions are stored in the computer-readable storage medium, and when the computer-executable instructions are executed by the processor, they are used to implement the method according to any one of claims 1-7.
11. A computer program product comprising a computer program, which when executed by a processor implements the method according to any one of claims 1-7.
Citation Information
Patent Citations
Method and device for calling SO file
CN104298932A
Data calling method and apparatus, and computer readable storage medium
CN107861713A
Interface mock test method, device and equipment based on information security and storage medium
CN109656807A
Log query method and device, electronic equipment and medium
CN113254399A