CN115033397A - Interface calling method, device, equipment and storage medium - Google Patents

Interface calling method, device, equipment and storage medium Download PDF

Info

Publication number
CN115033397A
CN115033397A CN202210590858.2A CN202210590858A CN115033397A CN 115033397 A CN115033397 A CN 115033397A CN 202210590858 A CN202210590858 A CN 202210590858A CN 115033397 A CN115033397 A CN 115033397A
Authority
CN
China
Prior art keywords
interface
keyword
request
expression
matching
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210590858.2A
Other languages
Chinese (zh)
Inventor
高云峰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Qingdao Haier Technology Co Ltd
Haier Smart Home Co Ltd
Original Assignee
Qingdao Haier Technology Co Ltd
Haier Smart Home Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Qingdao Haier Technology Co Ltd, Haier Smart Home Co Ltd filed Critical Qingdao Haier Technology Co Ltd
Priority to CN202210590858.2A priority Critical patent/CN115033397A/en
Publication of CN115033397A publication Critical patent/CN115033397A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The interface calling method, the device, the equipment and the storage medium provided by the application comprise the following steps: responding to the generation of a calling request for calling the first interface, and calling second interfaces corresponding to the first interfaces one by one; on the basis of the second interface, aiming at each first keyword corresponding to the second interface, determining parameter values corresponding to the first keywords one by one in the calling request according to a first matching strategy corresponding to the first keywords; based on the second interface, taking each first keyword and the parameter value corresponding to each first keyword one to one as a call log of the first interface; and if the parameter value corresponding to each first keyword corresponding to the second interface is found based on the second interface, calling the first interface, and generating a request result corresponding to the calling request based on the first interface. In the method, the user can customize the first matching strategy corresponding to the first keyword in the second interface, so that the user can screen out the information really needed by the user.

Description

Interface calling method, device, equipment and storage medium
Technical Field
The present application relates to the field of electronic technologies, and in particular, to an interface calling method, apparatus, device, and storage medium.
Background
At present, a large amount of logs are usually generated in the operation process of a distributed system, and a system developer can analyze the logs to further realize troubleshooting of the system so as to ensure normal operation of the system.
In the related art, when a log generated during the operation of the distributed system is obtained, an open-source link tracking system is usually used to generate a call log of each interface in the distributed system.
However, when the current open-source link tracking system generates the call log, since the user cannot modify the log generation manner in the link tracking system, the call log generated by the link tracking system includes more redundant information (i.e., information that the user does not need to pay attention to), the log generation requirement of the user cannot be met, and the call log is easily stored in a large storage space.
Disclosure of Invention
The application provides an interface calling method, an interface calling device, interface calling equipment and a storage medium, which are used for solving the problem that a calling log generated by using an open-source link tracking system comprises more redundant information when an interface in a system in the related art is called.
In a first aspect, the present application provides an interface calling method, including:
responding to the generation of a calling request for calling a first interface, and calling a second interface which corresponds to the first interface one by one; the calling request is used for indicating a request result for acquiring the first interface, and the calling request comprises a parameter value corresponding to a first keyword of the second interface;
on the basis of the second interface, aiming at each first keyword corresponding to the second interface, determining parameter values corresponding to the first keywords one by one in the calling request according to a first matching strategy corresponding to the first keywords; based on the second interface, taking each first keyword and the parameter value corresponding to each first keyword one to one as a call log of the first interface;
and if the parameter value corresponding to each first keyword corresponding to the second interface is found based on the second interface, calling the first interface, and generating a request result corresponding to the calling request based on the first interface.
In some embodiments, the first keyword corresponds to a plurality of first matching policies; the first matching strategy is provided with priority information which is used for indicating the execution sequence of the first matching strategy; 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, determining, in the invocation request, a parameter value corresponding to the first keyword one to one, including:
based on the second interface, for each first keyword corresponding to the second interface, repeating the following steps until a preset condition is reached: determining a first matching strategy to be executed currently according to the priority information of the first matching strategy corresponding to the first keyword based on the second interface; determining a matching result of the first keyword in the calling request according to the current to-be-executed first matching strategy based on the second interface; the preset conditions are as follows: determining that a matching result of the first keyword is not null based on the second interface;
and taking the matching result of the first keyword as the parameter value corresponding to the first keyword one by one.
In some embodiments, the first matching policy comprises: the system comprises a tag field and a first generation field, wherein the tag field is used for indicating request data in the call request; the first generation field is used for indicating a processing strategy of the request data; the determining, based on the second interface and according to the currently-to-be-executed first matching policy, a matching result of the first keyword in the call request includes:
based on the second interface, matching processing is carried out in the call request according to the expression of the tag field in the first matching strategy to be executed currently, and request data in the call request is obtained;
and processing the request data in the call request according to the expression of the first generation field in the first matching strategy to be executed currently based on the second interface, and taking the result obtained after processing as the matching result of the first keyword.
In some embodiments, the processing, based on the second interface, the request data in the invocation request according to a field value of a first generation field in the first matching policy to be executed currently, and taking a result obtained after the processing as a matching result of the first keyword includes:
based on the second interface, if the expression of the first generation field in the first matching strategy to be executed currently is determined to be null, taking the request data in the call request as the matching result of the first keyword;
based on the second interface, if it is determined that the expression of the first generation field in the first matching strategy to be executed currently is a jsonnpath expression, analyzing the request data in the calling request according to the jsonnpath expression, and taking the result obtained after analysis as the matching result of the first keyword;
based on the second interface, if it is determined that an expression of a first generation field in the first matching strategy to be executed currently is not null and is not a jsonnpath expression, determining an acquisition method of a parameter value indicated by the expression of the first generation field in the request data according to an introspection mode, and determining the parameter value indicated by the expression of the first generation field according to the acquisition method; and taking the parameter value indicated by the expression of the first generation field as a matching result of the first keyword.
In some embodiments, if it is determined that the expression of the first generation field in the first matching policy to be currently executed is a jsonnph expression based on the second interface, parsing the request data in the invocation request according to the jsonnph expression, and taking a result obtained after the parsing as the matching result of the first keyword, where the parsing includes:
based on the second interface, if it is determined that the preset position of the expression of the first generation field in the first matching strategy to be executed currently includes a preset symbol, the expression of the first generation field is a jsonnpath expression;
and analyzing the request data in the calling request according to the jsonnpath expression based on the second interface, and taking a result obtained after analysis as a matching result of the first keyword.
In some embodiments, the method further comprises:
responding to a request result corresponding to the calling request generated by the first interface, and calling a second interface corresponding to the first interface one by one; the request result comprises a parameter value corresponding to a second keyword of the second interface;
on the basis of the second interface, aiming at each second keyword corresponding to the second interface, determining parameter values corresponding to the second keywords one by one in the request result according to a second matching strategy corresponding to the second keywords; and based on the second interface, taking each second keyword and the parameter value corresponding to each second keyword one to one as a response log of the first interface.
In some embodiments, the second matching policy comprises: a second generated field; the second generation field is used for indicating the processing mode of the request result; the determining, based on the second interface and for each second keyword corresponding to the second interface, a parameter value corresponding to the second keyword in one-to-one correspondence in the request result according to a 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 an expression of a second generated field in a second matching policy corresponding to the second keyword is empty, taking the request result as a parameter value of the second keyword;
on the basis of the second interface, aiming at each second keyword corresponding to the second interface, if the expression of a second generation field in a second matching strategy corresponding to the second keyword is determined to be a jsonnph expression, analyzing the request result according to the jsonnph expression, and taking the result obtained after analysis as the parameter value of the second keyword;
on the basis of the second interface, for each second keyword corresponding to the second interface, if it is determined that an expression of a second generation field in a second matching policy corresponding to the second keyword is not null and is not a jsonnph expression, determining, according to an introspection manner, an obtaining method of a parameter value indicated by the expression of the second generation field in the request result, and determining, according to the obtaining method, a parameter value indicated by the expression of the second generation field; and taking the parameter value indicated by the expression of the second generation field as the parameter value of the second key.
In some embodiments, the invoking, in response to generation of a call request for invoking a first interface, a second interface in one-to-one correspondence with the first interface includes:
responding to the generation of a calling request for calling the first interface, and acquiring an interface name of the first interface;
and determining a second interface in one-to-one correspondence with the first interface based on the interface name of the first interface and a preset correspondence, and calling the second interface, wherein the preset correspondence is used for indicating the correspondence between the interface name of the first interface and the interface name of the second interface.
In a second aspect, the present application provides an interface calling apparatus, including:
the first calling unit is used for calling second interfaces which correspond to the first interfaces one by one in response to the generation of a calling request for calling the first interfaces; the calling request is used for indicating a request result of obtaining the first interface, and the calling request comprises a parameter value corresponding to a first keyword of the second interface;
a first determining unit, configured to determine, 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, a parameter value that corresponds to the first keyword one to one in the call request;
a second determining unit, configured to use each first keyword and a parameter value that corresponds to each first keyword one to one as a call log of the first interface based on the second interface;
and the second calling unit is used for calling the first interface and generating a request result corresponding to the calling request based on the first interface if the parameter value corresponding to each first keyword corresponding to the second interface is found based on the second interface.
In some embodiments, the first keyword corresponds to a plurality of first matching policies; the first matching strategy is provided with priority information which is used for indicating the execution sequence of the first matching strategy; the first determination unit includes:
based on the second interface, repeating the following first determining module and second determining module for each first keyword corresponding to the second interface until a preset condition is reached:
a first determining module, configured to determine, based on the second interface, a first matching policy to be currently executed according to priority information of the first matching policy corresponding to the first keyword;
a second determining module, configured to determine, based on the second interface, a matching result of the first keyword in the call request according to the first matching policy to be executed currently; the preset conditions are as follows: determining that a matching result of the first keyword is not null based on the second interface;
and the third determining module is used for taking the matching result of the first keyword as the parameter value corresponding to the first keyword one to one.
In some embodiments, the first matching policy comprises: the system comprises a tag field and a first generation field, wherein the tag field is used for indicating request data in the call request; the first generation field is used for indicating a processing strategy of the request data; the second determining module is specifically configured to:
based on the second interface, matching processing is carried out in the call request according to the expression of the tag field in the first matching strategy to be executed currently, and request data in the call request is obtained;
and processing the request data in the call request according to the expression of the first generation field in the first matching strategy to be executed currently based on the second interface, and taking the result obtained after processing as the matching result of the first keyword.
In some embodiments, the second determining module is specifically configured to:
based on the second interface, if the expression of the first generation field in the first matching strategy to be executed currently is determined to be null, taking the request data in the call request as the matching result of the first keyword;
based on the second interface, if it is determined that the expression of the first generation field in the first matching strategy to be executed currently is a jsonnpath expression, analyzing the request data in the calling request according to the jsonnpath expression, and taking the result obtained after analysis as the matching result of the first keyword;
based on the second interface, if it is determined that the expression of the first generation field in the first matching strategy to be executed currently is not null and is not a jsonnpath expression, determining an acquisition method of a parameter value indicated by the expression of the first generation field in the request data according to an introspection mode, and determining a parameter value indicated by the expression of the first generation field according to the acquisition method; and taking the parameter value indicated by the expression of the first generation field as a matching result of the first keyword.
In some embodiments, the second determining module is specifically configured to:
based on the second interface, if it is determined that the preset position of the expression of the first generation field in the first matching strategy to be executed currently includes a preset symbol, the expression of the first generation field is a jsonnpath expression;
and analyzing the request data in the calling request according to the jsonnpath expression based on the second interface, and taking a result obtained after analysis as a matching result of the first keyword.
In some embodiments, the apparatus further comprises:
the third calling unit is used for responding to a request result corresponding to the calling request generated by the first interface and calling the second interfaces corresponding to the first interfaces one by one; the request result comprises a parameter value corresponding to a second keyword of the second interface;
a third determining unit, configured to determine, based on the second interface, for each second keyword corresponding to the second interface, according to a second matching policy corresponding to the second keyword, a parameter value that is in one-to-one correspondence with the second keyword in the request result;
and a fourth determining unit, configured to use, based on the second interface, each second keyword and a parameter value corresponding to each second keyword in a one-to-one manner as a response log of the first interface.
In some embodiments, the second matching policy comprises: a second generated field; the second generation field is used for indicating the processing mode of the request result; the third determination unit includes:
a third determining module, configured to, based on the second interface, determine, for each second keyword corresponding to the second interface, if it is determined that an expression of a second generated field in a second matching policy corresponding to the second keyword is empty, use the request result as a parameter value of the second keyword;
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 a second generation field in a second matching policy corresponding to the second keyword is a jsonnph expression, perform analysis processing on the request result according to the jsonnph expression, and use a result obtained after the analysis processing as a parameter value of the second keyword;
a fifth determining module, configured to, based on the second interface, determine, for each second keyword corresponding to the second interface, if it is determined that an expression of a second generation field in a second matching policy corresponding to the second keyword is not null and is not a jsonnph expression, according to an introspection manner, an obtaining method of a parameter value indicated by the expression of the second generation field in the request result, and determine, according to the obtaining method, a parameter value indicated by the expression of the second generation field; and taking the parameter value indicated by the expression of the second generation field as the parameter value of the second key.
In some embodiments, the first calling unit includes:
the obtaining module is used for responding to the generation of a calling request for calling the first interface and obtaining the interface name of the first interface;
and the sixth determining module is used for determining a second interface in one-to-one correspondence with the first interface based on the interface name of the first interface and a preset correspondence, and calling the second interface, wherein the preset correspondence is used for indicating the correspondence between the interface name of the first interface and the interface name of the second interface.
In a third aspect, the present application provides an electronic device, comprising: a memory, a processor;
a memory; a memory for storing the processor-executable instructions;
wherein the processor is configured to perform the method according to any one of the first aspect according to the executable instructions.
In a fourth aspect, the present application provides a computer-readable storage medium having stored thereon computer-executable instructions for implementing the method according to any one of the first aspect when executed by a processor.
In a fifth aspect, the present application provides a computer program product comprising a computer program that, when executed by a processor, implements the method of any of the first aspects.
The interface calling method, the device, the equipment and the storage medium provided by the application comprise the following steps: responding to the generation of a calling request for calling a first interface, and calling second interfaces which correspond to the first interfaces one by one; the calling request is used for indicating a request result for acquiring the first interface, and the calling request comprises a parameter value corresponding to a first keyword of the second interface; on the basis of the second interface, aiming at each first keyword corresponding to the second interface, determining parameter values corresponding to the first keywords one by one in the calling request according to a first matching strategy corresponding to the first keywords; based on the second interface, taking each first keyword and the parameter value corresponding to each first keyword one to one as a call log of the first interface; if the parameter value corresponding to each first keyword corresponding to the second interface is found based on the second interface, calling the first interface, and generating a request result corresponding to the calling request based on the first interface. And obtaining the call logs of the first interfaces through the second interfaces by configuring a corresponding declarative second interface for each first interface. In this embodiment, the user may customize the first matching policy corresponding to the first keyword in the second interface, so that the user may filter out the information really needed by the user based on the first matching policy. In addition, in the embodiment of the application, the storage mode of key-value is adopted for storage, so that the efficiency of the user for subsequently inquiring the call log can be improved. In addition, in this embodiment, after determining that the second interface finds the parameter value corresponding to each first keyword in the second interface, the first interface is called, so as to avoid that when the calling request lacks a necessary parameter for calling the first interface, the calling of the first interface cannot be realized, or when the second interface fails, the calling log of the first interface cannot be obtained in real time, and thus failure monitoring of the first interface cannot be realized.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and together with the description, serve to explain the principles of the application.
Fig. 1 is a schematic flowchart of an interface calling method according to an embodiment of the present application;
fig. 2 is a schematic flowchart of another interface calling method according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of an interface invoking device according to an embodiment of the present disclosure;
fig. 4 is a schematic structural diagram of an interface invoking device according to an embodiment of the present disclosure;
fig. 5 is a schematic structural diagram of an electronic device provided in an embodiment of the present application.
Specific embodiments of the present application have been shown by way of example in the drawings and will be described in more detail below. These drawings and written description are not intended to limit the scope of the inventive concepts in any manner, but rather to illustrate the inventive concepts to those skilled in the art by reference to specific embodiments.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with aspects of the present application.
In the description of the present application, it is to be understood that the terms "first," "second," "third," and the like are used solely to distinguish one from another and are not necessarily used to describe a particular order or sequence, nor are they to be construed as indicating or implying relative importance. The specific meaning of the above terms in the present application can be understood by those of ordinary skill in the art as appropriate. Further, in the description of the present application, "a plurality" means two or more unless otherwise specified. "and/or" describes the association relationship of the associated object, indicating that there may be three relationships, for example, a and/or B, which may indicate: a exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship.
At present, in the process of system development and use, in order to monitor the operating state of each interface in a system in real time, a call log of each interface is generally obtained, and then fault monitoring is performed on the system based on the call logs of each interface.
In the related art, some open-source link tracking systems, such as a zipkin system, a skywalk system, etc., are commonly used for fault monitoring. However, when the current open-source link tracking system generates the call log, the log generation mode and the log generation format are already fixed by the developer of the link tracking system in the link tracking system, and the user cannot modify the call log, so that the call log generated by the link tracking system includes more redundant information which is not concerned by the user, the log generation requirement of the user cannot be met, and the generated call log also occupies more storage space, which wastes storage resources.
The interface calling method, device, equipment and storage medium provided by the application are used for solving the technical problem.
The following describes the technical solutions of the present application and how to solve the above technical problems with specific embodiments. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments. Embodiments of the present application will be described below with reference to the accompanying drawings.
Fig. 1 is a schematic flowchart of an interface calling method provided in an embodiment of the present application, and as shown in fig. 1, the method includes the following steps:
s101, responding to generation of a calling request for calling a first interface, and calling second interfaces corresponding to the first interfaces one by one; the calling request is used for indicating a request result for obtaining the first interface, and the calling request comprises a parameter value corresponding to the first keyword of the second interface.
For example, the interface in this embodiment is an application programming interface, and the interface calling method provided in this embodiment may be applied to a distributed system, for example, when an interface corresponding to each microservice included in the distributed system is called. It should be noted that the interface calling method provided in this embodiment is not limited to a distributed system, and all other systems provided with interfaces may use the interface calling method to complete interface calling and generate corresponding call logs.
The call request in this step is used for representing that the first interface needs to be called, and then the request result obtained after the first interface is called is obtained. It is understood that the call request of the first interface may be generated based on the operation instruction of the user, or may be generated by the remaining interfaces in the process that the system needs to be called continuously between the interfaces during operation.
In order to obtain the call log of the first interface, in this embodiment, when it is determined that a call request that needs to call the first interface is generated, first, a second interface corresponding to the first interface is called, where the first interface may be understood as an application programming interface (e.g., an order query function, a sales statistics function, etc.) for implementing a system service function in a system, and the second interface is an application programming interface for generating the call log of the first interface corresponding to the second interface.
In one example, to determine the second interfaces corresponding to the first interfaces one to one, an annotation may be added to the entry of the first interface, where the annotation includes a storage location corresponding to the second interface corresponding to the first interface.
S102, based on the second interface, for each first keyword corresponding to the second interface, according to a first matching strategy corresponding to the first keyword, determining parameter values corresponding to the first keyword one to one in the call request.
For example, in this embodiment, in order to generate a call log of a first interface, one or more first keywords and a first matching policy corresponding to each first keyword are written in a program of a second interface corresponding to the first interface in a one-to-one manner. The first matching strategy is used for indicating how to match parameter values of the first keywords corresponding to the first matching strategy in the calling request of the first interface. That is, based on the second interface, according to the first keywords set in the second interface and the first matching policies corresponding to the first keywords, the parameter value corresponding to each first keyword may be screened and matched in the invocation request.
In one example, it may be understood that, in addition to the parameters and the like that need to be input to the first interface when the first interface is called, the call request may also include remaining redundant information, for example, some protocol fields for communication between interfaces and other information that is not concerned by the user, and therefore, when the first matching policy corresponding to the first keyword is set, the user may use, as the first matching policy, a method for how to extract the parameters concerned by the user.
S103, based on the second interface, taking each first keyword and the parameter value corresponding to each first keyword one to one as a call log of the first interface.
For example, in this embodiment, after obtaining each first keyword and the parameter value corresponding to each first keyword, the parameter values corresponding to the first keyword and the first keyword are stored correspondingly, and are used as a call log of the first interface. That is, the call log generated in this embodiment is stored in a key-value manner, so as to be viewed by the user.
And S104, if the parameter value corresponding to each first keyword corresponding to the second interface is found based on the second interface, calling the first interface, and generating a request result corresponding to the calling request based on the first interface.
Exemplarily, when it is determined that the second interface finds the parameter value corresponding to each first keyword set in the second interface, the first interface may be called based on a call request that requires the first interface to be called, and then a call result corresponding to the call request is obtained based on the first call interface.
In an example, if it is determined that a parameter value corresponding to each first keyword corresponding to the second interface is not found based on the second interface, at this time, a prompt message may be sent to the user, where the prompt message may be used to indicate that generation of a call log of the current first interface fails, that the second interface fails in an operation process, or that a generated call request for calling the first interface lacks a parameter value required for calling the first interface.
In this embodiment, each first interface is configured with a corresponding declarative second interface, and then a parameter value corresponding to each first keyword is matched in a call request of the first interface through the second interface, and then a call log of the first interface is obtained according to the first keyword and the parameter value corresponding to each first keyword. In this embodiment, the user may customize the first matching policy corresponding to the first keyword in the second interface, so that the user may filter out the information really needed by the user based on the first matching policy. In addition, in the embodiment of the application, the storage mode of key-value is adopted for storage, so that the efficiency of the user for subsequently inquiring the call log can be improved. In addition, in this embodiment, after determining that the second interface finds the parameter value corresponding to each first keyword in the second interface, the first interface is called, so as to avoid that when the calling request lacks a necessary parameter for calling the first interface, the calling of the first interface cannot be realized, or when the second interface fails, the calling log of the first interface cannot be obtained in real time, and thus failure monitoring of the first interface cannot be realized.
Fig. 2 is a schematic flowchart of another interface invoking method provided in an embodiment of the present application, where as shown in fig. 2, the method includes the following steps:
s201, responding to generation of a calling request for calling the first interface, and obtaining an interface name of the first interface.
For example, when a call request for calling a first interface is generated, in order to determine a second interface corresponding to the first interface one by one, in this embodiment, first, an interface name of the first interface may be obtained. The calling request may include an interface name of the first interface to be called, or the calling request includes an interface address of the first interface to be called, and the interface name of the first interface is further determined based on the interface address.
S202, determining second interfaces in one-to-one correspondence with the first interfaces based on the interface names of the first interfaces and a preset correspondence, and calling the second interfaces, wherein the preset correspondence is used for indicating the correspondence between the interface names of the first interfaces and the interface names of the second interfaces.
For example, after the name of the first interface is obtained, the second interface to be called may be determined based on a preset corresponding relationship between the name of the first interface and the name of the second interface, and the call to the second interface is executed.
In one example, when determining to name each second interface, a corresponding relationship between the names of the first interfaces and the second interfaces may be set in a manner of adding a uniform suffix behind the name of the corresponding first interface, so that the second interface corresponding to the first interface to be called may be quickly determined.
It can be understood that, in this embodiment, different names need to be used between different interfaces in the same system, that is, the names of the interfaces have the characteristic of uniqueness, and the second interface corresponding to the first interface is determined according to the correspondence between the names of the interfaces, so that the accuracy of the obtained second interface is improved, and a call log of the first interface that needs to be obtained by a user is obtained.
After step S202, based on the second interface, repeating the following steps S203 and S204 for each first keyword corresponding to the second interface until a preset condition is reached: the preset conditions are as follows: determining that a matching result of the first keyword is not null based on the second interface; a plurality of first matching strategies corresponding to the first keywords; the first matching policy has priority information indicating an execution order of the first matching policy.
S203, based on the second interface, determining a first matching strategy to be executed currently according to the priority information of the first matching strategy corresponding to the first keyword.
For example, in this embodiment, each first keyword in the second interface may be provided with a plurality of first matching policies. It can be understood that the first interfaces may be used in different application scenarios, and in different application scenarios, the call request for indicating that the first interface is called may use different data encapsulation manners to encapsulate the parameter value corresponding to the first keyword, which needs to be obtained by the user, so that each first interface may set a plurality of first matching policies to correspond to methods for extracting the parameter value corresponding to the first keyword in the call request in different encapsulation manners.
In addition, in this embodiment, the first matching policy corresponding to the first keyword further has priority information, where the priority information of the first matching policy is used to indicate an execution order of the first matching policy when determining a 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, the priority information may be determined based on a call frequency of the first interface in different application scenarios, thereby improving efficiency of generating a call log.
S204, based on the second interface, determining a matching result of the first keyword in the call request according to a first matching strategy to be executed currently; the calling request comprises parameter values corresponding to the first keywords of the second interface.
For example, after the second interface needing to be called is determined, for each first keyword corresponding to the second interface, an execution order of the first matching policies may be determined according to priority information of the first matching policies corresponding to the first keyword. And then sequentially executing the first matching strategies based on the execution sequence of the first matching strategies. If the matching result of the first keyword matched in the call request indicates that the matching result is not empty based on a certain first matching policy, the execution of the remaining unexecuted first matching policies may be stopped at this time.
In some embodiments, the first matching policy comprises: the system comprises a tag field and a first generation field, wherein the tag field is used for indicating request data in a call request; the first generation field is used to indicate a processing policy of the requested data. Step S204 specifically includes the following steps:
the first step of step S204: and based on the second interface, performing matching processing in the call request according to the expression of the tag field in the first matching strategy to be executed currently to obtain the request data in the call request.
The second step of step S204: and processing the request data in the calling request according to the expression of the first generation field in the first matching strategy to be executed currently based on the second interface, and taking the result obtained after processing as the matching result of the first keyword.
Exemplarily, in this embodiment, a setting manner of the first matching policy is given. In the first matching policy, a tag field and a first generation field are included. It can be understood that, a plurality of request data are usually included in the call request, and each of the plurality of request data corresponds to a respective field identifier, so that, in the first matching policy, the expression of the tag field may be set, so that the request data to be obtained may be determined in the call request based on the expression of the tag field. That is to say, the expression corresponding to the signing field in the first matching policy is matched with each field identifier in the invocation request, and when the expression is successfully matched with a certain field identifier, the request data corresponding to the field identifier is the request data to be acquired.
In addition, the first matching policy is further provided with a first generation field, and the first generation field may be used to indicate a manner how to determine a parameter value corresponding to the first keyword in the request data, that is, a processing policy for the request data. For example, because the data encapsulation manners in different invocation requests are different, and the data encapsulation manners of parameter values corresponding to different first keywords that need to be determined in the same invocation request are also different, in this embodiment, different processing policies may be indicated by setting the first generation field in the first matching policy, so as to be suitable for extracting the parameter values of different first keywords.
For example, in a possible case, the expression corresponding to the first generation field is a policy identifier that can be used to characterize a processing policy that needs to be executed on the determined requested data, and the code segment of the processing policy corresponding to the policy identifier can be found through the policy identifier.
It can be understood that, in this embodiment, the tag field is set in the first matching policy to filter the request data in the call request, so that the efficiency of subsequently determining the parameter value corresponding to the first keyword can be improved. And setting a first generation field of a processing strategy for representing the request data corresponding to the first matching strategy in the first matching strategy, so that the first matching strategy can be applicable to the packaging mode of the request data determined by the first matching strategy, and the accuracy of the parameter value corresponding to the acquired first keyword is further improved.
In some embodiments, when performing the second step of step S204, it may be implemented by:
based on the second interface, if the expression of the first generation field in the first matching strategy to be executed currently is determined to be empty, the request data in the calling request is used as the matching result of the first keyword;
on the basis of the second interface, if the expression of the first generation field in the first matching strategy to be executed currently is determined to be a jsonnpath expression, analyzing the request data in the calling request according to the jsonnpath expression, and taking the result obtained after analysis as the matching result of the first keyword;
based on the second interface, if the expression of the first generation field in the first matching strategy to be executed currently is determined not to be empty and not to be a jsonnpath expression, determining an acquisition method of the parameter value indicated by the expression of the first generation field in the request data according to an introspection mode, and determining the parameter value indicated by the expression of the first generation field according to the acquisition method; and taking the parameter value indicated by the expression of the first generation field as a matching result of the first keyword.
For example, when processing call data in a call request determined based on a tag field in a first matching policy, a processing policy may first be determined based on a first generation field included in the first matching policy. Specifically, the following three cases can be classified:
in the first case: when the expression of the first generation field included in the first matching policy is empty, the first interface uses the request data in the call request generated by the first interface as the matching result of the first keyword corresponding to the first matching policy, that is, the request data in the call request generated by the first interface does not need to be processed at this time.
In the second case: when the expression of the first generation field included in the first matching policy is a jsonnpath expression, the first interface analyzes the request data in the call request generated by the first interface directly based on the jsonnpath expression corresponding to the first generation field, and further analyzes the parameter value indicated by the jsonnpath expression in the request data in the call request, and uses the searched parameter value as the matching result of the first keyword corresponding to the first matching policy.
In a third case: when the expression of the first generation field included in the first matching policy is not null and is not a jsonnph expression, at this time, the parameter value indicated by the expression of the first generation field may be determined in the request data in the invocation request in an introspection manner based on the expression of the first generation field. Specifically, an obtaining method of a parameter value corresponding to an expression of a first generation field may be determined first, and then a parameter value indicated by the expression of the first generation field is found in request data in a call request based on the determined obtaining method; and then, taking the determined parameter value as a matching result of the first keyword.
For example, the following is a schematic section of code for generating a call log in the second interface:
Figure BDA0003667317480000131
Figure BDA0003667317480000141
the expression after the key is used for representing a first keyword, wherein the code schematic segment comprises three first keywords, namely "dId", "uId" and "ipm". Each first key corresponds to a respective first matching policy (identified by Candidate). The first matching policy further includes a tag field (identified by paramName) and a first generation field (identified by expr), and priority indicates priority information of the first matching policy corresponding to the same first keyword. The expression of the first keyword "dId" corresponding to the tag field in the two first matching policies is identified by the following character "request" in the code segment, and the expression of the first generation field in the first matching policy is identified by the following character "deviceId" in the code segment, at this time, an obtaining method of the parameter value indicated by "deviceId" may be obtained based on an introspection manner, and a matching result corresponding to the first keyword "dId" is determined in the request data corresponding to the "request" based on the determined obtaining method, and if the matching result is empty, the next matching policy, that is, the policy of the expression of the first generation field identified by the following character "$. dId" in the code segment, is continuously executed. Since the symbol "$" is set at the first character in "$. dId", the expression representing the first generation field is a jsonnpath expression, and a matching result corresponding to the first keyword "dId" may be determined in the request result based directly on the jsonnpath expression.
For the first matching policy corresponding to the first keyword "ipm", in the first matching policy, the expression corresponding to the first generating field is empty, that is, the first generating field does not exist in the first matching policy, at this time, the request data corresponding to the expression "request" of the tag field in the call request may be directly used as the matching result corresponding to the first keyword "ipm".
In addition, in the actual application process, when the parameter value corresponding to the first keyword, which needs to be acquired in the request data in the call request, is a simple pojo type, the parameter value can be acquired in an introspection manner. When the parameter value corresponding to the first keyword required to be obtained from the request data in the call request is a complex java bean object, the parameter value is obtained by using a jsonnpath expression.
In this embodiment, different expressions of the first generation field may be set in the first matching policy corresponding to different first keywords, and then the expressions corresponding to different first generation fields are set according to different packaging manners of the parameter values, so as to improve the accuracy of the parameter value corresponding to the first keyword that is finally matched in the invocation request.
In some embodiments, when determining whether the expression of the first generation field in the first matching policy to be currently executed is a jsonnpath expression, at this time, it may be determined by: based on the second interface, if it is determined that the preset position of the expression of the first generation field in the first matching strategy to be executed currently includes a preset symbol, the expression of the first generation field is a jsonnpath expression.
For example, in the present embodiment, when determining whether the expression of the first generation field is a jsonnpath expression, it may be determined at this time whether a preset symbol is included in the expression of the first generation field at a preset position of the expression, for example, whether a first character of the expression is a "$" symbol, and if the first character is the "$" symbol, the expression of the first generation field is the jsonnpath expression.
It can be understood that, in this embodiment, by the determination manner of the jsonnpath expression, the accuracy of the determination result of the jsonnpath expression can be improved, and the accuracy of the obtained parameter value corresponding to the first keyword can be further improved.
S205, taking the matching result of the first keyword as a parameter value corresponding to the first keyword one by one.
For example, when the matching result of the first keyword indicates that the matching result is not empty, the matching result corresponding to the first keyword may be used as a parameter value corresponding to the first keyword.
It can be understood that, in this embodiment, priority information is set for each first matching policy corresponding to a first keyword, so that a parameter value corresponding to the first keyword can be quickly determined, and further, the generation efficiency of the call log of the first interface is improved. In addition, each first matching policy corresponding to the first keyword may be determined based on a data encapsulation manner 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.
S206, based on the second interface, taking each first keyword and the parameter value corresponding to each first keyword one to one as the call log of the first interface.
For example, this step may refer to step S103, and detailed description is omitted.
And S207, if the parameter value corresponding to each first keyword corresponding to the second interface is found based on the second interface, calling the first interface, and generating a request result corresponding to the calling request based on the first interface.
For example, this step may refer to step S104, and detailed description is omitted.
S208, responding to a request result corresponding to the call request generated by the first interface, and calling second interfaces corresponding to the first interfaces one by one; the request result includes parameter values corresponding to the second keywords of the second interface.
For example, in this embodiment, after the first interface generates the call log corresponding to the call request, at this time, a response log of the first interface may also be generated based on the second interface. Specifically, after determining that the first interface generates a request result corresponding to the call request, at this time, the call to the second interface corresponding to the first interface one to one is continuously performed.
S209, based on the second interface, determining parameter values corresponding to the second keywords in the request result according to a second matching strategy corresponding to the second keywords for each second keyword corresponding to the second interface; and based on the second interface, taking each second keyword and the parameter value corresponding to each second keyword one by one as a response log of the first interface.
For example, in this embodiment, a second keyword and a second matching policy corresponding to the second keyword may also be set in the second interface, where the second matching policy may be used to indicate how to determine a parameter value of the second keyword corresponding to the second matching policy in the invocation request. In addition, one or more second keywords may be set in the second interface, which is not limited in this embodiment. After determining the parameter values of the second keywords corresponding to the second interface based on the second interface, the parameter values of each second keyword and each second keyword may be stored in a key-value manner as a response log of the first interface.
It can be understood that a second keyword and a second matching policy corresponding to the second keyword may also be set in the second interface, so that after the call of the first interface is completed, based on the second matching policy set in the second interface, a parameter value of the second keyword corresponding to the second interface may be matched in a request result generated by the first interface, and then a response log of the first interface is obtained, so that a user may determine whether the first interface fails in a process of responding to the call based on the response log of the first interface through the above method. In addition, by simultaneously setting the first keywords in the call log and the second keywords in the response log of the same first interface in the second interface, the number of the second interfaces can be reduced and prevented from being set, and the storage space for storing the corresponding relation representing the first interface and the second interface can be reduced.
In some embodiments, the second matching policy comprises: a second generated field; the second generation field is used for indicating the processing mode of the request result; when the step "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, determining the parameter values corresponding to the second keywords in the request result" in step S209 is executed, the following steps may be implemented:
based on the second interface, aiming at each second keyword corresponding to the second interface, if the expression of a second generation field in a second matching strategy corresponding to the second keyword is determined to be empty, taking the request result as the parameter value of the second keyword;
on the basis of the second interface, aiming at each second keyword corresponding to the second interface, if the expression of the second generation field in the second matching strategy corresponding to the second keyword is determined to be a jsonnph expression, analyzing the request result according to the jsonnph expression, and taking the result obtained after analysis as the parameter value of the second keyword;
on the basis of the second interface, if the expression of the second generation field in the second matching strategy corresponding to the second keyword is determined not to be empty and not to be a jsonnpath expression, determining an acquisition method of the parameter value indicated by the expression of the second generation field in the request result according to an introspection mode, and determining the parameter value indicated by the expression of the second generation field according to the acquisition method; and taking the parameter value indicated by the expression of the second generation field as the parameter value of the second keyword.
In this embodiment, because the request result generated by the first interface usually includes only return data corresponding to one field identifier, compared to the first matching policy, the second matching policy does not need to set a tag field, and only needs to set a second generated field in the second matching policy, and the second generated field is used to characterize how to process the request result, so as to obtain a parameter value corresponding to the second keyword included in the request result.
Specifically, the following three cases can be classified:
in one case: when the expression of the second generation field included in the second matching policy is empty, at this time, the second interface uses the request result generated by the first interface as the parameter value of the second keyword corresponding to the second matching policy, that is, the request result generated by the first interface does not need to be processed at this time.
In the second case: when the expression of the second generation field included in the second matching strategy is a jsonnpath expression, at this time, the second interface directly analyzes the request result generated by the first interface based on the jsonnpath expression corresponding to the second generation field, and further analyzes the parameter value indicated by the jsonnpath expression in the request result, and takes the searched parameter value as the parameter value of the second keyword corresponding to the second matching strategy.
In a third case: when the expression of the second generation field included in the second matching policy is not null and is not a jsonnph expression, at this time, the parameter value indicated by the expression of the second generation field may be determined in the request result in an introspection manner based on the expression of the second generation field. Specifically, an obtaining method of a parameter value corresponding to an expression of the second generation field may be determined first, and then a parameter value indicated by the expression of the second generation field is found in the request result based on the determined obtaining method; and then, taking the determined parameter value as the parameter value of the second keyword. For example, the following is a code schematic segment for generating a response log in the second interface: retLog { @ TraceLog (key { @ code ", candidates { @ legal (expr ═ retCode") }),
@TraceLog(key="msg",candidates={@Candidate(expr="retInfo")})}
the expression after the key is used for representing a second keyword, wherein the code schematic section comprises two second keywords, namely "code" and "msg". Each second key corresponds to a respective second matching policy (identified by candidates). Furthermore, the second matching strategy also comprises a second generation field (identified by expr), and the expression of the second generation field in the second matching strategy corresponding to the second keyword "code" is identified by the following characters "$. If the symbol "$" is set at the first character in the "$. retCode", the expression representing the second generation field is a jsonnpath expression, and a parameter value corresponding to the second keyword "code" may be determined in the request result directly based on the jsonnpath expression. In addition, the expression of the second generation field in the second matching policy corresponding to the second keyword "msg" is identified by the following character "retInfo" in the above code segment, at this time, an obtaining method of the parameter value indicated by "retInfo" may be obtained based on an introspection manner, and the parameter value corresponding to the second keyword "msg" may be determined in the request result based on the determined obtaining method.
In some embodiments, after the response log is generated based on the second interface, the request result generated based on the first interface may be returned to the caller of the first interface to implement result feedback.
In this embodiment, different expressions of the second generation field may be set in the second matching policy corresponding to different second keywords. When the parameter value corresponding to the second keyword required to be obtained in the request result is a simple pojo type, the parameter value can be obtained in an introspection mode. When the parameter value corresponding to the second keyword required to be obtained in the request result is a complex java bean object, the parameter value is obtained by using a jsonnpath expression, and then the expressions corresponding to different second generation fields are set according to the packaging modes of different parameter values, so that the accuracy of the parameter value corresponding to the second keyword finally matched in the request result is improved.
Fig. 3 is a schematic structural diagram of an interface invoking device according to an embodiment of the present application, and as shown in fig. 3, the interface invoking device includes:
a first calling unit 31, configured to call, in response to generation of a call request for calling a first interface, second interfaces in one-to-one correspondence with the first interfaces; the calling request is used for indicating a request result for acquiring the first interface, and the calling request comprises a parameter value corresponding to a first keyword of the second interface;
a first determining unit 32, configured to determine, 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, a parameter value that corresponds to the first keyword one to one in the call request;
a second determining unit 33, configured to use each first keyword and a parameter value corresponding to each first keyword one to one as a call log of the first interface based on the second interface;
the second invoking unit 34 is configured to, 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, invoke the first interface, and generate a request result corresponding to the invocation request based on the first interface.
The apparatus provided in this embodiment is used to implement the technical solution provided by the above method, and the implementation principle and the technical effect are similar and will not be described again.
Fig. 4 is a schematic structural diagram of an interface invoking device according to an embodiment of the present application, where on the basis of the structure of the device shown in fig. 3, a plurality of first matching policies corresponding to a first keyword; the first matching strategy has priority information, and the priority information is used for indicating the execution sequence of the first matching strategy; a first determination unit 32, comprising:
based on the second interface, the following first determining module 321 and second determining module 322 are repeated for each first keyword corresponding to the second interface until a preset condition is reached:
a first determining module 321, configured to determine, based on the second interface, a first matching policy to be currently executed according to priority information of the first matching policy corresponding to the first keyword;
a second determining module 322, configured to determine, based on the second interface, a matching result of the first keyword in the call request according to the first matching policy to be currently executed; the preset conditions are as follows: determining that a matching result of the first keyword is not null based on the second interface;
and the third determining module 323 is configured to use the matching result of the first keyword as a parameter value corresponding to the first keyword.
In some embodiments, the first matching policy comprises: the system comprises a tag field and a first generation field, wherein the tag field is used for indicating request data in a call request; the first generation field is used for indicating the processing strategy of the request data; the second determining module 322 is specifically configured to:
based on the second interface, matching processing is carried out in the call request according to the expression of the tag field in the first matching strategy to be executed currently, and request data in the call request is obtained;
and processing the request data in the calling request according to the expression of the first generation field in the first matching strategy to be executed currently based on the second interface, and taking the result obtained after processing as the matching result of the first keyword.
In some embodiments, the second determining module 322 is specifically configured to:
based on the second interface, if the expression of the first generation field in the first matching strategy to be executed currently is determined to be empty, the request data in the calling request is used as the matching result of the first keyword;
on the basis of the second interface, if the expression of the first generation field in the first matching strategy to be executed currently is determined to be a jsonnpath expression, analyzing the request data in the calling request according to the jsonnpath expression, and taking the result obtained after analysis as the matching result of the first keyword;
based on the second interface, if the expression of the first generation field in the first matching strategy to be executed currently is determined not to be empty and not to be a jsonnpath expression, determining an acquisition method of the parameter value indicated by the expression of the first generation field in the request data according to an introspection mode, and determining the parameter value indicated by the expression of the first generation field according to the acquisition method; and taking the parameter value indicated by the expression of the first generation field as a matching result of the first key.
In some embodiments, the second determining module 322 is specifically configured to:
based on the second interface, if it is determined that the preset position of the expression of the first generation field in the first matching strategy to be executed currently comprises a preset symbol, the expression of the first generation field is a jsonnph expression;
and analyzing the request data in the call request according to the jsonnpath expression on the basis of the second interface, and taking a result obtained after analysis as a matching result of the first keyword.
In some embodiments, the apparatus further comprises:
a third calling unit 35, configured to respond to a request result corresponding to the call request generated by the first interface, and call a second interface corresponding to the first interface one to one; the request result comprises a parameter value corresponding to a second keyword of the second interface;
a third determining unit 36, configured to determine, based on the second interface, for each second keyword corresponding to the second interface, according to a second matching policy corresponding to the second keyword, a parameter value corresponding to the second keyword in the request result;
and a fourth determining unit 37, configured to use each second keyword and a parameter value corresponding to each second keyword in a one-to-one manner as a response log of the first interface based on the second interface.
In some embodiments, the second matching policy comprises: a second generated field; the second generation field is used for indicating the processing mode of the request result; a third determination unit 36, including:
a third determining module 361, configured to, based on the second interface, regarding each second keyword corresponding to the second interface, if it is determined that an expression of a second generation field in a second matching policy corresponding to the second keyword is empty, take a request result as a parameter value of the second keyword;
a fourth determining module 362, configured to, based on the second interface, for each second keyword corresponding to the second interface, if it is determined that an expression of a second generation field in a second matching policy corresponding to the second keyword is a jsonnpath expression, perform parsing on the request result according to the jsonnpath expression, and use a result obtained after the parsing as a parameter value of the second keyword;
a fifth determining module 363, configured to, based on the second interface, determine, for each second keyword corresponding to the second interface, if it is determined that an expression of a second generation field in a second matching policy corresponding to the second keyword is not null and is not a jsonnph expression, according to an introspection manner, a method for obtaining a parameter value indicated by the expression of the second generation field in the request result, and determine, according to the obtaining method, the parameter value indicated by the expression of the second generation field; and taking the parameter value indicated by the expression of the second generation field as the parameter value of the second key.
In some embodiments, the first calling unit 31 includes:
an obtaining module 311, configured to obtain an interface name of a first interface in response to generation of a call request for calling the first interface;
a sixth determining module 312, configured to determine, based on the interface name of the first interface and a preset corresponding relationship, a second interface corresponding to the first interface one to one, and call the second interface, where the preset corresponding relationship is used to indicate a corresponding relationship between the interface name of the first interface and the interface name of the second interface.
The apparatus provided in this embodiment is used to implement the technical solution provided by the above method, and the implementation principle and the technical effect are similar and will not be described again.
The application provides an electronic device, including: a memory, a processor;
a memory; a memory for storing processor-executable instructions;
the processor is used for executing the method according to the executable instruction.
Fig. 5 is a schematic structural diagram of an electronic device provided in an embodiment of the present application, and as shown in fig. 5, the electronic device includes:
a processor (processor)291, the electronic device further including a memory (memory) 292; a Communication Interface 293 and bus 294 may also be included. The processor 291, the memory 292, and the communication interface 293 may communicate with each other via the bus 294. Communication interface 293 may be used for the transmission of information. Processor 291 may call logic instructions in memory 294 to perform the methods of the embodiments described above.
Further, the logic instructions in the memory 292 may be implemented in software functional units and stored in a computer readable storage medium when sold or used as a stand-alone product.
The memory 292 is a computer-readable storage medium for storing software programs, computer-executable programs, such as program instructions/modules corresponding to the methods in the embodiments of the present application. The processor 291 executes the functional application and data processing by executing the software program, instructions and modules stored in the memory 292, so as to implement the method in the above method embodiments.
The memory 292 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required for at least one function; the storage data area may store data created according to the use of the terminal device, and the like. Further, the memory 292 may include a high speed random access memory and may also include a non-volatile memory.
The present application provides a computer-readable storage medium having stored thereon computer-executable instructions for implementing any of the methods when executed by a processor.
A computer program product comprising a computer program which, when executed by a processor, implements the method of any one of the claims.
Other embodiments of the present application will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the application being indicated by the following claims.
It will be understood that the present application is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the application is limited only by the appended claims.

Claims (12)

1. An interface calling method, comprising:
responding to the generation of a calling request for calling a first interface, and calling second interfaces which correspond to the first interfaces one by one; the calling request is used for indicating a request result of obtaining the first interface, and the calling request comprises a parameter value corresponding to a first keyword of the second interface;
on the basis of the second interface, aiming at each first keyword corresponding to the second interface, determining parameter values corresponding to the first keywords one by one in the calling request according to a first matching strategy corresponding to the first keywords; based on the second interface, taking each first keyword and the parameter value corresponding to each first keyword one to one as a call log of the first interface;
and if the parameter value corresponding to each first keyword corresponding to the second interface is found based on the second interface, calling the first interface, and generating a request result corresponding to the calling request based on the first interface.
2. The method of claim 1, wherein the first keyword corresponds to a plurality of first matching policies; the first matching strategy is provided with priority information which is used for indicating the execution sequence of the first matching strategy; 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, determining, in the invocation request, a parameter value corresponding to the first keyword one to one, including:
based on the second interface, for each first keyword corresponding to the second interface, repeating the following steps until a preset condition is reached: determining a first matching strategy to be executed currently according to the priority information of the first matching strategy corresponding to the first keyword based on the second interface; determining a matching result of the first keyword in the calling request according to the current to-be-executed first matching strategy based on the second interface; the preset conditions are as follows: determining that a matching result of the first keyword is not null based on the second interface;
and taking the matching result of the first keyword as the parameter value corresponding to the first keyword one to one.
3. The method of claim 2, wherein the first matching policy comprises: the system comprises a tag field and a first generation field, wherein the tag field is used for indicating request data in the call request; the first generation field is used for indicating a processing strategy of the request data; the determining, based on the second interface and according to the currently-to-be-executed first matching policy, a matching result of the first keyword in the call request includes:
based on the second interface, matching processing is carried out in the call request according to the expression of the tag field in the first matching strategy to be executed currently, and request data in the call request is obtained;
and processing the request data in the call request according to the expression of the first generation field in the first matching strategy to be executed currently based on the second interface, and taking the result obtained after processing as the matching result of the first keyword.
4. The method according to claim 3, wherein processing the request data in the invocation request according to a field value of a first generation field in the first matching policy to be executed currently based on the second interface, and using a result obtained after the processing as a matching result of the first keyword comprises:
based on the second interface, if the expression of the first generation field in the first matching strategy to be executed currently is determined to be null, taking the request data in the call request as the matching result of the first keyword;
based on the second interface, if it is determined that the expression of the first generation field in the first matching strategy to be executed currently is a jsonnpath expression, analyzing the request data in the calling request according to the jsonnpath expression, and taking the result obtained after analysis as the matching result of the first keyword;
based on the second interface, if it is determined that the expression of the first generation field in the first matching strategy to be executed currently is not null and is not a jsonnpath expression, determining an acquisition method of a parameter value indicated by the expression of the first generation field in the request data according to an introspection mode, and determining a parameter value indicated by the expression of the first generation field according to the acquisition method; and taking the parameter value indicated by the expression of the first generation field as a matching result of the first keyword.
5. The method according to claim 4, wherein if it is determined that the expression of the first generation field in the first matching policy to be currently executed is a jsonnph expression based on the second interface, parsing the request data in the invocation request according to the jsonnph expression, and taking a result obtained after parsing as the matching result of the first keyword, includes:
based on the second interface, if it is determined that the preset position of the expression of the first generation field in the first matching strategy to be executed currently includes a preset symbol, the expression of the first generation field is a jsonnpath expression;
and analyzing the request data in the calling request according to the jsonnpath expression based on the second interface, and taking a result obtained after analysis as a matching result of the first keyword.
6. The method of claim 1, further comprising:
responding to a request result corresponding to the calling request generated by the first interface, and calling a second interface corresponding to the first interface one by one; the request result comprises a parameter value corresponding to a second keyword of the second interface;
on the basis of the second interface, aiming at each second keyword corresponding to the second interface, determining parameter values corresponding to the second keywords in the request result according to a second matching strategy corresponding to the second keywords; and based on the second interface, taking each second keyword and the parameter value corresponding to each second keyword one to one as a response log of the first interface.
7. The method of claim 6, wherein the second matching policy comprises: a second generated field; the second generation field is used for indicating the processing mode of the request result; the determining, based on the second interface and for each second keyword corresponding to the second interface, a parameter value corresponding to the second keyword in one-to-one correspondence in the request result according to a 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 an expression of a second generated field in a second matching policy corresponding to the second keyword is empty, taking the request result as a parameter value of the second keyword;
on the basis of the second interface, aiming at each second keyword corresponding to the second interface, if the expression of a second generation field in a second matching strategy corresponding to the second keyword is determined to be a jsonnph expression, analyzing the request result according to the jsonnph expression, and taking the result obtained after analysis as the parameter value of the second keyword;
on the basis of the second interface, for each second keyword corresponding to the second interface, if it is determined that an expression of a second generation field in a second matching policy corresponding to the second keyword is not null and is not a jsonnph expression, determining, according to an introspection manner, an acquisition method for a parameter value indicated by the expression of the second generation field in the request result, and determining, according to the acquisition method, a parameter value indicated by the expression of the second generation field; and taking the parameter value indicated by the expression of the second generation field as the parameter value of the second key.
8. The method according to any one of claims 1 to 7, wherein the calling the second interface corresponding to the first interface in one-to-one correspondence in response to generation of a call request for calling the first interface comprises:
responding to the generation of a calling request for calling the first interface, and acquiring an interface name of the first interface;
and determining a second interface in one-to-one correspondence with the first interface based on the interface name of the first interface and a preset correspondence, and calling the second interface, wherein the preset correspondence is used for indicating the correspondence between the interface name of the first interface and the interface name of the second interface.
9. An interface invocation apparatus, comprising:
the first calling unit is used for calling second interfaces which correspond to the first interfaces one by one in response to the generation of a calling request for calling the first interfaces; the calling request is used for indicating a request result for acquiring the first interface, and the calling request comprises a parameter value corresponding to a first keyword of the second interface;
a first determining unit, configured to determine, 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, a parameter value that is in one-to-one correspondence with the first keyword in the call request;
a second determining unit, configured to use each first keyword and a parameter value corresponding to each first keyword one to one as a call log of the first interface based on the second interface;
and the second calling unit is used for calling the first interface and generating a request result corresponding to the calling request based on the first interface if the parameter value corresponding to each first keyword corresponding to the second interface is found based on the second interface.
10. An electronic device, comprising:
a memory, a processor, and a computer program;
wherein the processor is capable of processing instructions for execution within a computer system; the computer program is stored in the memory and configured to be executed by the processor to implement the method of any one of claims 1-8.
11. A computer-readable storage medium having computer-executable instructions stored therein, which when executed by a processor, are configured to implement the method of any one of claims 1-8.
12. A computer program product comprising a computer program which, when executed by a processor, implements the method of any one of claims 1-8.
CN202210590858.2A 2022-05-27 2022-05-27 Interface calling method, device, equipment and storage medium Pending CN115033397A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210590858.2A CN115033397A (en) 2022-05-27 2022-05-27 Interface calling method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210590858.2A CN115033397A (en) 2022-05-27 2022-05-27 Interface calling method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115033397A true CN115033397A (en) 2022-09-09

Family

ID=83120455

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210590858.2A Pending CN115033397A (en) 2022-05-27 2022-05-27 Interface calling method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115033397A (en)

Similar Documents

Publication Publication Date Title
CN111258725B (en) Data processing method, device, equipment and medium based on block chain
CN110661658B (en) Node management method and device of block chain network and computer storage medium
CN109150572B (en) Method, device and computer readable storage medium for realizing alarm association
CN111143087A (en) Interface calling method and device, storage medium and server
CN111475376A (en) Method and device for processing test data, computer equipment and storage medium
CN112035344A (en) Multi-scenario test method, device, equipment and computer readable storage medium
CN111858083A (en) Remote service calling method and device, electronic equipment and storage medium
CN111831365A (en) Interface route forwarding method, system, computer equipment and readable storage medium
CN111047434A (en) Operation record generation method and device, computer equipment and storage medium
CN113312675A (en) Attribute checking method and device, electronic equipment and storage medium
CN111158995B (en) Method and system for realizing cross-system log tracking query based on skywalk and ELK platform
CN115033397A (en) Interface calling method, device, equipment and storage medium
CN115934537A (en) Interface test tool generation method, device, equipment, medium and product
CN111475226B (en) Electronic device, micro-service calling method, and computer-readable storage medium
CN115357298A (en) Calling method of third-party interface, processor and storage medium
CN112199092B (en) Application development method and device and electronic equipment
CN112860398A (en) Data processing method, device, equipment and medium based on rule engine
CN113590352A (en) Data calling method, device, equipment and readable storage medium
CN112667323A (en) Application system page processing method and device, computer equipment and storage medium
CN112149951A (en) Risk control method and device, computer equipment and storage medium
CN111124923B (en) Running state query method and device, server equipment and storage medium
CN113901377B (en) Service calling method, device, storage medium and equipment of legacy system
GB2522433A (en) Efficient decision making
CN115022387B (en) Cross-domain pre-inspection request processing method, device, equipment and medium
CN117272278B (en) Decentralization management method and device for digital asset platform

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination