CN113238817A - Interface transparent transmission method and device, electronic equipment and storage medium - Google Patents

Interface transparent transmission method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN113238817A
CN113238817A CN202110552151.8A CN202110552151A CN113238817A CN 113238817 A CN113238817 A CN 113238817A CN 202110552151 A CN202110552151 A CN 202110552151A CN 113238817 A CN113238817 A CN 113238817A
Authority
CN
China
Prior art keywords
interface
transparent transmission
party
request
sending
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
CN202110552151.8A
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.)
Shanghai Krypton Information Technology Co ltd
Original Assignee
Shanghai Krypton Information Technology 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 Shanghai Krypton Information Technology Co ltd filed Critical Shanghai Krypton Information Technology Co ltd
Priority to CN202110552151.8A priority Critical patent/CN113238817A/en
Publication of CN113238817A publication Critical patent/CN113238817A/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/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4488Object-oriented
    • G06F9/449Object-oriented method invocation or resolution
    • 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/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files
    • 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
    • G06F9/546Message passing systems or structures, e.g. queues

Abstract

The application discloses an interface transparent transmission method, an interface transparent transmission device, electronic equipment and a storage medium, wherein the method comprises the following steps: configuring an interface configuration file according to the interface transparent transmission requirement; the interface configuration file is a pre-established interface transparent transmission specification; when an interface transparent transmission request of a calling party is received, checking a configured interface configuration file, and determining an interface address of a third party corresponding to the interface transparent transmission request; analyzing the interface transparent transmission request according to the interface address of the third party to obtain a request parameter, and sending the request parameter to the third party; and receiving a return result of the third party and sending the return result to the calling party. According to the method, codes do not need to be compiled, only interface configuration files need to be configured, transparent transmission is further achieved, when a plurality of interface transparent transmission requests are received, the codes do not need to be compiled one by one, transparent transmission can be achieved only by configuring the configuration files, convenience and high efficiency are achieved, and development difficulty is reduced.

Description

Interface transparent transmission method and device, electronic equipment and storage medium
Technical Field
The present disclosure relates to the field of interface transparent transmission technologies, and in particular, to an interface transparent transmission method and apparatus, an electronic device, and a storage medium.
Background
At present, in an interface transparent transmission implementation method, a public software client needs to compile codes to call a third-party interface, transparent transmission logic packaging and transparent transmission functions are compiled together, code development amount is large, and because each transparent transmission interface needs to compile a corresponding transparent transmission logic scheme, when the number of third-party interfaces to be called by service requirements is large, thousands of transparent transmission interfaces need to be compiled one by one, and code development difficulty is large.
Disclosure of Invention
The application aims to provide an interface transparent transmission method, an interface transparent transmission device, electronic equipment and a storage medium, the transparent transmission function can be realized only based on a configuration form without writing codes, convenience and high efficiency are achieved, and development difficulty is reduced. The specific scheme is as follows:
in a first aspect, the present application discloses an interface transparent transmission method, including:
configuring an interface configuration file according to the interface transparent transmission requirement; the interface configuration file is a pre-established interface transparent transmission specification;
when an interface transparent transmission request of a calling party is received, checking a configured interface configuration file, and determining an interface address of a third party corresponding to the interface transparent transmission request;
analyzing the interface transparent transmission request according to the interface address of the third party to obtain a request parameter, and sending the request parameter to the third party;
and receiving a return result of the third party, and sending the return result to the calling party.
Optionally, configuring the interface configuration file according to the interface transparent transmission requirement includes:
and configuring an interface address, a request method type and an externally exposed address of a third party in the interface configuration file according to the interface transparent transmission requirement.
Optionally, after analyzing the interface transparent transmission request according to the interface address of the third party to obtain a request parameter and sending the request parameter to the third party, the method further includes:
judging whether the request parameters are successfully transmitted to the third party or not;
if not, executing a retry mechanism, and continuously sending the request parameters to the third party;
and when detecting that the number of times of resending the request parameters reaches a preset threshold value, stopping sending the request parameters and returning error information.
Optionally, before analyzing the interface transparent transmission request to obtain a request parameter and sending the request parameter to the third party, the method further includes:
scanning each class in the item, and judging whether a value containing a specification class annotation on each class has a target class matched with the interface address of the third party;
if so, if the method marked by the pre-annotation in the target class is detected, after pre-logic processing is carried out, the interface passthrough request is analyzed to obtain a request parameter, and the request parameter is sent to the third party;
if not, executing the step of analyzing the interface transparent transmission request to obtain a request parameter and sending the request parameter to the third party;
correspondingly, the receiving the returned result of the third party and sending the returned result to the caller includes:
if the method marked by the postannotation in the target class is detected, after the return result of the third party is received, performing postlogic processing on the return result, and sending the processed return result to the calling party.
Optionally, before each class in the scan item, the method further includes:
and configuring the interface address of the third party with the same transparent transmission interface service logic in the value of the same class.
Optionally, the method further includes:
when the transparent transmission interface service logic changes, determining a class with the changed transparent transmission interface service logic in the project;
and modifying the logic in the method marked by the front annotation and/or the back annotation in the class with the changed transparent transmission interface service logic according to the change information corresponding to the changed transparent transmission interface service logic.
Optionally, before analyzing the interface transparent transmission request to obtain a request parameter and sending the request parameter to the third party, the method further includes:
judging whether the type of the returned result after the preposed logic processing is an interrupt request result processing type or not;
if yes, returning error information to the calling party;
if not, executing the step of analyzing the interface transparent transmission request to obtain a request parameter and sending the request parameter to the third party;
correspondingly, before the sending the processed return result to the caller, the method further includes:
translating the returned result of the third party into the returned result of the public returned class;
judging whether the return result of the common return class is the interrupt request result processing class or not;
if yes, returning information to the calling party according to a preset rule;
and if not, executing the step of sending the processed return result to the calling party.
In a second aspect, the present application discloses an interface pass-through device, comprising:
the configuration module is used for configuring interface configuration files according to the interface transparent transmission requirements; the interface configuration file is a pre-established interface transparent transmission specification;
the determining module is used for checking a configured interface configuration file when receiving an interface transparent transmission request of a calling party and determining an interface address of a third party corresponding to the interface transparent transmission request;
the sending module is used for analyzing the interface transparent transmission request according to the interface address of the third party to obtain a request parameter and sending the request parameter to the third party;
and the receiving module is used for receiving the return result of the third party and sending the return result to the calling party.
In a third aspect, the present application discloses an electronic device, comprising:
a memory for storing a computer program;
and the processor is used for realizing the steps of the interface transparent transmission method when executing the computer program.
In a fourth aspect, the present application discloses a computer-readable storage medium, on which a computer program is stored, which, when executed by a processor, implements the steps of the interface passthrough method as described above.
The application provides an interface transparent transmission method, which comprises the following steps: configuring an interface configuration file according to the interface transparent transmission requirement; the interface configuration file is a pre-established interface transparent transmission specification; when an interface transparent transmission request of a calling party is received, checking a configured interface configuration file, and determining an interface address of a third party corresponding to the interface transparent transmission request; analyzing the interface transparent transmission request according to the interface address of the third party to obtain a request parameter, and sending the request parameter to the third party; and receiving a return result of the third party, and sending the return result to the calling party.
Therefore, the interface configuration file is configured only according to the interface transparent transmission requirement, when the interface transparent transmission request of the calling party is received, the interface address of the third party in the interface configuration file is checked, the request parameter obtained by analyzing the interface transparent transmission request can be sent to the third party, and the return result sent by the third party is returned to the calling party, so that transparent transmission can be realized; according to the method and the device, codes do not need to be compiled, only interface configuration files need to be configured, transparent transmission is achieved, when a plurality of interface transparent transmission requests are received, the codes do not need to be compiled one by one, transparent transmission can be achieved only by configuring the configuration files, the purpose that a calling party needs to compile large-scale codes to achieve that an interface transparent transmission function calls a third party in the related art is avoided, the defect that development difficulty is large is overcome, the transparent transmission function can be achieved only by a configuration-based form without compiling the codes, convenience and high efficiency are achieved, and development difficulty is reduced.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, it is obvious that the drawings in the following description are only embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
Fig. 1 is a flowchart of an interface transparent transmission method according to an embodiment of the present disclosure;
fig. 2 is a flowchart of another interface transparent transmission method according to an embodiment of the present application;
fig. 3 is a life cycle diagram of a transparent transmission process provided by an embodiment of the present application;
FIG. 4 is a schematic diagram of a request flow layer provided by an embodiment of the present application;
FIG. 5 is a block diagram of a system architecture according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of an interface transparent transmission device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The logic packaging processing of the interface transparent transmission scheme in the related technology is mainly mixed in functions of transparent transmission to be compiled, only one set of processing logic can be compiled for one transparent transmission interface, once the transparent transmission interface is changed, all the functions need to be modified correspondingly, the change amount is large, and codes of the transparent transmission interface need to be compiled by a calling party. Based on the above technical problems, this embodiment provides an interface pass-through method, which can implement a pass-through function only based on a configuration form without writing codes, is convenient and efficient, and reduces development difficulty, and specifically please refer to fig. 1, where fig. 1 is a flowchart of an interface pass-through method provided in this embodiment of the present application, and specifically includes:
s101, configuring an interface configuration file according to the interface transparent transmission requirement; the interface configuration file is a pre-established interface transparent transmission specification.
The interface configuration file in this embodiment is a pre-established interface transparent transmission specification, and this embodiment does not limit the specific content of the interface configuration file, and may include a third party address to be transparent transmitted, an external exposure address of a transparent transmission interface, and a request type of a caller. It can be understood that the transparent transmission function can be realized only by configuring the interface configuration file according to the transparent transmission requirement of the interface. The embodiment does not limit the specific content of the interface unvarnished transmission requirement, and may include a request parameter, a request type, an address for calling a third-party interface, and the like. The request type is not specifically limited in this embodiment, and may be a post type, a get type, an update type, and a delete type; wherein, post: submitting data to a server; delete: deleting a certain resource; get: sending a request to obtain a resource on the server; update: and sending data to the server side so as to change the information.
The embodiment does not limit the specific content of the interface configuration file. In a specific embodiment, configuring the interface configuration file according to the interface transparent transmission requirement may include:
and configuring an interface address, a request method type and an externally exposed address of a third party in the interface configuration file according to the interface transparent transmission requirement.
In this embodiment, an address to be transparently transmitted, that is, an interface address of a third party, a request method type, and an externally exposed address in an interface configuration file are configured according to an interface transparent transmission requirement.
S102, when an interface unvarnished transmission request of a calling party is received, checking a configured interface configuration file, and determining an interface address of a third party corresponding to the interface unvarnished transmission request.
In this embodiment, when the interface pass-through request of the caller is received, the third party interface that the caller wants to call, that is, the interface address of the third party corresponding to the interface pass-through request, can be determined by viewing the interface configuration file. For example, part of the code of the interface profile is as follows:
Figure BDA0003075895300000061
the interface address of the third party that the caller wants to invoke can be determined by looking at Url. Wherein, the ' OutUrl '/search ' is middleware, namely an address exposed outside by the transparent transmission interface; the address type method is a POST type.
S103, according to the interface address of the third party, the interface transparent transmission request is analyzed to obtain a request parameter, and the request parameter is sent to the third party.
In this embodiment, after the interface address of the third party is determined, the request parameter is obtained by analyzing the interface transparent transmission request, and then the request parameter is sent to the third party, so that the third party performs service logic processing according to the specific request parameter. The present embodiment does not limit the specific content of the request parameter, and may be set according to the specific service requirement.
In a specific embodiment, in order to improve the success rate of transparent transmission, in this embodiment, after analyzing the interface transparent transmission request according to the interface address of the third party to obtain the request parameter and sending the request parameter to the third party, the method may further include:
judging whether the request parameters are successfully transmitted to a third party or not;
if not, executing a retry mechanism, and continuously sending the request parameters to a third party;
and when the number of times of resending the request parameters is detected to reach a preset threshold value, stopping sending the request parameters, and returning error information.
That is, after the request parameter is sent to the third party, the present embodiment further determines whether the request parameter is successfully sent, i.e., the transparent transmission is performed. If the transparent transmission is not successful, the request parameters are retransmitted to the third party, namely, a retry mechanism is executed, and the continuous transmission is stopped until the request parameters are successfully transmitted to the third party or the retransmission times exceed a preset threshold value; and when the sending times exceed the preset threshold value, namely the sending fails, returning error information. The embodiment does not limit the specific content of the error information, and may be information that is not successfully transmitted in the transparent manner, or other information, and may be set according to the actual situation. The specific size of the preset threshold is not limited in this embodiment, and may be 3 times, or may be 4 times, and may be set according to actual situations. By executing the retry mechanism, the embodiment can effectively improve the transparent transmission success rate under the condition that the transparent transmission is unsuccessful due to accidental conditions such as a network.
And S104, receiving a return result of the third party, and sending the return result to the calling party.
In this embodiment, after the request parameter is transmitted to the third party, the third party may perform service logic processing according to the specific request parameter, and then generate a return result to the transparent transmission interface of the intermediate party, and the transparent transmission interface transmits the return result to the calling party. It should be noted that the functions implemented in the above embodiments are only to implement the transparent transmission function.
Based on the technical scheme, codes do not need to be compiled, only interface configuration files need to be configured, transparent transmission is further achieved, when a plurality of interface transparent transmission requests are received, the codes do not need to be compiled one by one, transparent transmission can be achieved only by configuring the configuration files, convenience and high efficiency are achieved, development difficulty is reduced, the purpose that a calling party needs to compile large-scale codes to achieve the purpose that an interface transparent transmission function calls a third party in the related technology is avoided, and the defect that the development difficulty is large is overcome.
Based on the foregoing embodiment, in order to implement logic packaging in the transparent transmission process and improve update efficiency of the transparent transmission logic, this embodiment provides an interface transparent transmission method, and specifically please refer to fig. 2, where fig. 2 is a flowchart of another interface transparent transmission method provided in this embodiment of the present application, and includes:
s201, configuring an interface configuration file according to the interface transparent transmission requirement; the interface configuration file is a pre-established interface transparent transmission specification.
S202, when an interface unvarnished transmission request of a calling party is received, checking a configured interface configuration file, and determining an interface address of a third party corresponding to the interface unvarnished transmission request.
Steps S101 and S102 may be referred to in steps S201 and S202, and are not described in detail in this embodiment.
S203, scanning each class in the item, and judging whether a value containing a specification class note on each class has a target class matched with an interface address of a third party;
if yes, go to step S204; if not, the process proceeds to step S205.
It is understood that the value stores the interface address of the third party. In this embodiment, the number of the third-party interface addresses stored in the value is not limited, and may be 1 or more. When the transparent transmission logic package comprises a plurality of interface addresses of third parties, one-to-many logic processing can be realized, namely when the transparent transmission logic package changes, the transparent transmission logic package can be adapted to all adapted third party interfaces after being modified, the work of developers can be effectively reduced, the interface addresses of the third parties are only added into values, the transparent transmission logic package can be adapted to the corresponding third party interfaces after being changed, code compiling and modifying are not needed one by one, and the updating efficiency after the transparent transmission logic changes is greatly improved.
In a specific embodiment, in order to effectively reduce the work of developers and greatly improve the efficiency of updating after the transparent transmission logic is changed, before scanning each class in the project, the method may further include:
and configuring the interface address of the third party with the same transparent transmission interface service logic in the value of the same class.
In this embodiment, the interface addresses of the third parties with the same transparent interface service logic are configured in the values of the same class. When the package logic changes during transparent transmission, only one modification is needed, the method is suitable for all adaptive transparent transmission interfaces, code compiling and modifying are not needed one by one, updating efficiency after the transparent transmission logic changes is greatly improved, and work of developers can be effectively reduced.
And S204, if a target class matched with the interface address of the third party exists, detecting that the method marked by the preposed annotation exists in the target class, and performing preposed logic processing.
S205, according to the interface address of the third party, the interface transparent transmission request is analyzed to obtain a request parameter, and the request parameter is sent to the third party.
It can be understood that the class includes a pre-processing logic and a post-processing logic in the transparent transmission logic, wherein the class is a carrier implemented by Java and is used for acquiring various information related to the class, storing structure information of the class, and taking out corresponding information by a method of a class object, thereby providing a related method for acquiring class information; the annotation can be regarded as an extended template of a class/method, each class/method annotates different parameters for the class/method according to the rules in the annotation class, and various parameters and values annotated in different classes/methods can be obtained where used. It can also be understood that the preprocessing is that before the transparent transmission interface realizes the transparent transmission function, the logic package of the transparent transmission interface changes (for example, request intervention, request interrupt or request rewriting in the transparent transmission process needs to be performed), which is called transparent transmission preprocessing; correspondingly, the post-processing is that after the transparent transmission interface realizes the transparent transmission function, the logical package of the transparent transmission interface changes (for example, the returned content needs to be interrupted, rewritten, appended, and the like), and is called as transparent transmission post-processing. The class matching the interface address of the third party is referred to as a target class in this embodiment. It is understood that the target class in this embodiment may only include the pre-annotation, may only include the post-annotation, and may also include both the pre-annotation and the post-annotation. In this embodiment, when it is detected that there is a method marked by a pre-annotation, pre-logic processing is performed, and then, after the pre-logic processing is performed, a request parameter obtained by analyzing an interface transparent transmission request is sent to a third party according to an interface address of the third party. The present embodiment does not limit the specific content of the pre-logic processing, and may be set according to the actual situation, for example, request intervention, request interrupt, request rewriting, and the like in the transparent transmission process need to be performed.
It can be understood that the request interrupt can be performed if the interface transparent transmission request sent by the calling party is illegal. In a specific embodiment, in order to improve the rationality of the transparent transmission process, before analyzing the interface transparent transmission request, obtaining the request parameter, and sending the request parameter to the third party, the method may further include:
judging whether the type of the returned result after the preposed logic processing is an interrupt request result processing type or not;
if yes, returning error information to the calling party;
and if not, executing the analysis interface transparent transmission request to obtain a request parameter, and sending the request parameter to a third party.
In this embodiment, by determining whether the type of the returned result processed by the pre-logic is an interrupt request result processing class, it can be understood that the interrupt request processing class belongs to a special class for determining whether an interface transparent transmission request sent by the caller is illegal or unreasonable, and if so, directly returning an error message to the caller. The present embodiment does not limit the specific content of the error information, and can be set according to the actual situation. And if the request is not the interrupt request result processing type, executing the analysis interface transparent transmission request to obtain the request parameter, and sending the request parameter to a third party. In this embodiment, transparent transmission intervention is performed, that is, whether the interrupt request result processing class belongs to is determined, so that the rationality of the transparent transmission process can be guaranteed.
And S206, receiving a return result of the third party and sending the return result to the calling party.
It can be understood that if the target class does not contain the postannotation, the received return result of the third party is directly sent to the caller. If the method marked by the postannotation in the target class is detected, after the returned result of the third party is received, performing postlogic processing on the returned result, and sending the processed returned result to the calling party. The present embodiment does not limit the specific content of the post-logic processing, and may be, for example, an operation such as interruption, rewriting, or addition of the return content.
It can be understood that, in the embodiment, because the front logic processing part, i.e. the corresponding front annotation, and the rear logic processing part, i.e. the corresponding rear annotation, in the target class are separated, for developers, the corresponding parts can be found more intuitively and clearly; therefore, if the transparent transmission logic package changes, namely the transparent transmission preposition logic and/or the transparent transmission postposition logic changes, the code part can be quickly and directly positioned for modification and updating, the efficiency of transparent transmission logic updating is effectively improved, and the defects that the codes of the transparent transmission preposition and postposition and the transparent transmission function are compiled together in the related technology, when the transparent transmission logic package changes, the code change amount is large, the part of the codes needing to be updated is difficult to position, and the development difficulty of developers is increased are overcome. In a specific embodiment, the method may further include:
when the service logic of the transparent transmission interface changes, determining a class with the changed service logic of the transparent transmission interface in the project;
and modifying the logic in the method marked by the front annotation and/or the back annotation in the class with the changed transparent transmission interface business logic according to the change information corresponding to the changed transparent transmission interface business logic.
In the embodiment, the class with the changed business logic of the transparent transmission interface is found, and the corresponding pre-annotation and/or post-annotation part is directly modified according to the changed change information, so that the code to be modified is quickly and efficiently inquired and updated, and the updating efficiency of the transparent transmission logic is improved.
Corresponding to the specific embodiment in the foregoing step, in a specific embodiment, in order to improve the rationality of the transparent transmission process, before sending the processed return result to the caller, the method may further include:
translating the return result of the third party into a return result of the public return class;
judging whether the return result of the common return class is an interrupt request result processing class or not;
if yes, returning information to the calling party according to a preset rule;
and if not, executing the step of sending the processed return result to the calling party.
Similarly, before the processed return result is sent to the caller, the return result of the third party is translated into the return result of the public return class, and then whether the return result is the interrupt request result processing class is judged, if yes, the information is returned to the caller according to the preset rule. The embodiment does not limit the specific content of the preset rule, and may directly return an error message, or return a prompt message to prompt the caller to resend the interface transparent transmission request, or may adopt other forms. If the processing class is not the interrupt request result processing class, the operation of sending the processed return result to the calling party is executed.
Based on the technical scheme, the interface address, the request method type, the external exposure and leakage address and the like which need to be transparently transmitted are written in the interface configuration file, code writing is not needed, and a framework, namely the interface configuration file, automatically carries out transparent transmission logic equipment so as to complete transparent transmission. If the request intervention, the request interruption, the request rewriting and the interruption of the returned content, the rewriting and the addition in the transparent transmission process need to be carried out, the whole process of the transparent transmission preposition processing logic and the transparent transmission postposition processing logic can be completed only by writing in the corresponding method according to the mode provided by the framework. According to the method and the device, codes do not need to be written, transparent transmission can be achieved only by configuring the interface files, when a plurality of interface transparent transmission requests are received, many-to-one transparent transmission can be achieved only by configuring the plurality of configuration files corresponding to the same transparent transmission address, the method and the device are convenient and efficient, and development complexity is reduced.
Specific embodiments of an interface pass-through method are provided below. The method can realize a set of compiling method and specification of corresponding logic to a plurality of transparent transmission interfaces, so that the packaging logic during transparent transmission is changed, only one modification is needed, the method can be suitable for all adaptive transparent transmission interfaces, and codes called by the transparent transmission interfaces can be automatically assembled to complete the complete function of an exposable transparent transmission logic without compiling codes, namely transparent transmission zero codes. The method comprises the following steps:
1. configuring an interface address needing to be transparently transmitted, namely an interface address of a third party, a request method type and an external exposure address;
2. creating a method for performing front-end and back-end logic processing provided by a framework and configuring an interface address needing transparent transmission;
3. when the pre-processing and the post-processing of the transparent transmission are needed, the writing is only needed to be carried out in a method specified by a framework, and the written logic processing content can be run when the automatically configured relation is mapped to all the configured transparent transmission interfaces.
Assume that there are 10 transparent interfaces that need to perform corresponding interface request encapsulation, mapping of exposed addresses and writing return objects. If request intervention, request interruption, request rewriting and interruption of content return in the transparent transmission process, rewriting and addition need to be performed with corresponding logic writing, and the code amount is huge. In the embodiment, the interface address to be transparently transmitted, the request method type, the external exposure address and the like are written in the interface configuration file, code writing is not needed, and a framework, namely the interface configuration file can automatically carry out transparent transmission logic equipment to complete transparent transmission. If the request intervention, the request interruption, the request rewriting and the interruption of the returned content, the rewriting and the addition in the transparent transmission process need to be carried out, the whole process of the transparent transmission preposition processing logic and the transparent transmission postposition processing logic can be completed only by writing in the corresponding method according to the mode provided by the framework.
Fig. 3 is a life cycle diagram of a transparent transmission process provided in this embodiment, including processes of request encapsulation, pre-processing, http request, post-processing, and return to end. Fig. 4 is a schematic diagram of a request flow layer provided in the present embodiment. Among them, Spring is a framework widely used for Java development; the Spring MVC is one of Spring frames and is parallel to the transparent transmission frame provided by the application; DB is a database. Fig. 5 is a schematic diagram of a system architecture provided in the present embodiment, in which Apollo is a common off-system common centralized configuration tool.
The following is a partial Spring integration mode code provided in this embodiment.
Figure BDA0003075895300000111
Figure BDA0003075895300000121
Referring to fig. 6, fig. 6 is a schematic structural diagram of an interface transparent transmission device provided in an embodiment of the present application, where the interface transparent transmission device described below and the interface transparent transmission method described above are referred to in a mutually corresponding manner, and the relevant modules are all disposed therein, and the interface transparent transmission device provided in the embodiment of the present application includes:
in some specific embodiments, the method specifically includes:
the configuration module 601 is configured to configure an interface configuration file according to the interface transparent transmission requirement; the interface configuration file is a pre-established interface transparent transmission specification;
the determining module 602 is configured to, when an interface unvarnished transmission request of a calling party is received, check a configured interface configuration file, and determine an interface address of a third party corresponding to the interface unvarnished transmission request;
the sending module 603 is configured to analyze the interface transparent transmission request according to the interface address of the third party to obtain a request parameter, and send the request parameter to the third party;
the receiving module 604 is configured to receive a return result of the third party, and send the return result to the caller.
In some specific embodiments, the configuration module 601 includes:
and configuring an interface address, a request method type and an externally exposed address of a third party in the interface configuration file according to the interface transparent transmission request.
In some specific embodiments, the method further comprises:
the first judgment module is used for judging whether the request parameters are successfully transmitted to the third party;
the retry module is used for executing a retry mechanism and continuously sending the request parameters to a third party if the request parameters are not the same as the request parameters;
and the stopping module is used for stopping sending the request parameters and returning error information when detecting that the times of resending the request parameters reach a preset threshold value.
In some specific embodiments, the method further comprises:
the scanning unit is used for scanning each class in the items and judging whether a value containing a specification class note on each class has a target class matched with the interface address of the third party or not;
if yes, if the method marked by the preposed annotation in the target class is detected, and if the method marked by the preposed annotation in the target class is detected, after the preposed logic processing is carried out, an analysis interface passthrough request is executed, a request parameter is obtained, and the request parameter is sent to a third party;
accordingly, a receiving module comprises:
and the post-transparent transmission unit is used for performing post-logic processing on the returned result after receiving the returned result of the third party and sending the processed returned result to the calling party if the method marked by the post-annotation is detected to exist in the target class.
In some specific embodiments, the method further comprises:
and the second configuration module is used for configuring the interface address of the third party with the same transparent transmission interface service logic in the value of the same class.
In some specific embodiments, the method further comprises:
the second determining module is used for determining the class with the changed transparent transmission interface service logic in the project when the transparent transmission interface service logic is changed;
and the modification module is used for modifying the logic in the method marked by the front annotation and/or the back annotation in the class with the changed transparent transmission interface business logic according to the change information corresponding to the changed transparent transmission interface business logic.
In some specific embodiments, the method further comprises:
the second judgment module is used for judging whether the type of the returned result after the preposed logic processing is the interrupt request result processing type;
the first returning module is used for returning error information to the calling party if the calling party is in the calling state;
correspondingly, the method also comprises the following steps:
the translation module is used for translating the return result of the third party into the return result of the public return class;
the third judging module is used for judging whether the return result of the common return class is the interrupt request result processing class or not;
and the second returning module is used for returning the information to the calling party according to the preset rule if the calling party is the calling party.
Since the embodiment of the interface transparent transmission apparatus part corresponds to the embodiment of the interface transparent transmission method part, please refer to the description of the embodiment of the interface transparent transmission method part for the embodiment of the interface transparent transmission apparatus part, which is not repeated here.
In the following, an electronic device provided by the embodiment of the present application is introduced, and the electronic device described below and the interface passthrough method described above may be referred to correspondingly.
The application also discloses an electronic device, including:
a memory for storing a computer program;
and the processor is used for realizing the steps of the interface transparent transmission method when executing the computer program.
Since the embodiment of the electronic device portion corresponds to the embodiment of the interface transparent transmission method portion, please refer to the description of the embodiment of the interface transparent transmission method portion for the embodiment of the electronic device portion, which is not repeated here.
In the following, a computer-readable storage medium provided by an embodiment of the present application is described, and the computer-readable storage medium described below and the interface passthrough method described above may be referred to correspondingly.
The application also discloses a computer readable storage medium, on which a computer program is stored, and the computer program realizes the steps of the interface transparent transmission method when being executed by a processor.
Since the embodiment of the computer-readable storage medium portion corresponds to the embodiment of the interface transparent transmission method portion, please refer to the description of the embodiment of the interface transparent transmission method portion for the embodiment of the computer-readable storage medium portion, which is not repeated here.
The embodiments are described in a progressive manner in the specification, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
The above detailed description is provided for an interface transparent transmission method, an interface transparent transmission device, an electronic device, and a computer-readable storage medium. The principles and embodiments of the present application are explained herein using specific examples, which are provided only to help understand the method and the core idea of the present application. It should be noted that, for those skilled in the art, it is possible to make several improvements and modifications to the present application without departing from the principle of the present application, and such improvements and modifications also fall within the scope of the claims of the present application.

Claims (10)

1. An interface transparent transmission method, comprising:
configuring an interface configuration file according to the interface transparent transmission requirement; the interface configuration file is a pre-established interface transparent transmission specification;
when an interface transparent transmission request of a calling party is received, checking a configured interface configuration file, and determining an interface address of a third party corresponding to the interface transparent transmission request;
analyzing the interface transparent transmission request according to the interface address of the third party to obtain a request parameter, and sending the request parameter to the third party;
and receiving a return result of the third party, and sending the return result to the calling party.
2. The interface transparent transmission method according to claim 1, wherein the configuring the interface configuration file according to the interface transparent transmission requirement includes:
and configuring an interface address, a request method type and an externally exposed address of a third party in the interface configuration file according to the interface transparent transmission requirement.
3. The interface unvarnished transmission method according to claim 1, wherein after the analyzing the interface unvarnished transmission request according to the interface address of the third party to obtain a request parameter and sending the request parameter to the third party, the method further comprises:
judging whether the request parameters are successfully transmitted to the third party or not;
if not, executing a retry mechanism, and continuously sending the request parameters to the third party;
and when detecting that the number of times of resending the request parameters reaches a preset threshold value, stopping sending the request parameters and returning error information.
4. The interface unvarnished transmission method according to any one of claims 1 to 3, wherein before the analyzing the interface unvarnished transmission request to obtain a request parameter and sending the request parameter to the third party, the method further includes:
scanning each class in the item, and judging whether a value containing a specification class annotation on each class has a target class matched with the interface address of the third party;
if so, if the method marked by the pre-annotation in the target class is detected, after pre-logic processing is carried out, the interface passthrough request is analyzed to obtain a request parameter, and the request parameter is sent to the third party;
if not, executing the step of analyzing the interface transparent transmission request to obtain a request parameter and sending the request parameter to the third party;
correspondingly, the receiving the returned result of the third party and sending the returned result to the caller includes:
if the method marked by the postannotation in the target class is detected, after the return result of the third party is received, performing postlogic processing on the return result, and sending the processed return result to the calling party.
5. The interface pass-through method of claim 4, further comprising, prior to each class in the scan item:
and configuring the interface address of the third party with the same transparent transmission interface service logic in the value of the same class.
6. The interface pass-through method of claim 4, further comprising:
when the transparent transmission interface service logic changes, determining a class with the changed transparent transmission interface service logic in the project;
and modifying the logic in the method marked by the front annotation and/or the back annotation in the class with the changed transparent transmission interface service logic according to the change information corresponding to the changed transparent transmission interface service logic.
7. The interface unvarnished transmission method according to claim 4, wherein before the analyzing the interface unvarnished transmission request to obtain a request parameter and sending the request parameter to the third party, the method further comprises:
judging whether the type of the returned result after the preposed logic processing is an interrupt request result processing type or not;
if yes, returning error information to the calling party;
if not, executing the step of analyzing the interface transparent transmission request to obtain a request parameter and sending the request parameter to the third party;
correspondingly, before the sending the processed return result to the caller, the method further includes:
translating the returned result of the third party into the returned result of the public returned class;
judging whether the return result of the common return class is the interrupt request result processing class or not;
if yes, returning information to the calling party according to a preset rule;
and if not, executing the step of sending the processed return result to the calling party.
8. An interface pass-through device, comprising:
the configuration module is used for configuring interface configuration files according to the interface transparent transmission requirements; the interface configuration file is a pre-established interface transparent transmission specification;
the determining module is used for checking a configured interface configuration file when receiving an interface transparent transmission request of a calling party and determining an interface address of a third party corresponding to the interface transparent transmission request;
the sending module is used for analyzing the interface transparent transmission request according to the interface address of the third party to obtain a request parameter and sending the request parameter to the third party;
and the receiving module is used for receiving the return result of the third party and sending the return result to the calling party.
9. An electronic device, comprising:
a memory for storing a computer program;
a processor for implementing the steps of the interface pass-through method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, having stored thereon a computer program which, when being executed by a processor, carries out the steps of the interface pass-through method according to any one of claims 1 to 7.
CN202110552151.8A 2021-05-20 2021-05-20 Interface transparent transmission method and device, electronic equipment and storage medium Pending CN113238817A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110552151.8A CN113238817A (en) 2021-05-20 2021-05-20 Interface transparent transmission method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110552151.8A CN113238817A (en) 2021-05-20 2021-05-20 Interface transparent transmission method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113238817A true CN113238817A (en) 2021-08-10

Family

ID=77137943

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110552151.8A Pending CN113238817A (en) 2021-05-20 2021-05-20 Interface transparent transmission method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113238817A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114051058A (en) * 2021-09-27 2022-02-15 北京旷视科技有限公司 Interface calling method, platform, electronic equipment and computer storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108462758A (en) * 2018-04-02 2018-08-28 平安科技(深圳)有限公司 Bank-corporate express communication means, device, equipment and computer readable storage medium
CN110381135A (en) * 2019-07-18 2019-10-25 北京奇艺世纪科技有限公司 Interface creation method, service request method, device, computer equipment and medium
CN110413354A (en) * 2019-08-01 2019-11-05 苏州浪潮智能科技有限公司 It is a kind of to realize the method, equipment and storage medium interacted with third-party platform
CN111064621A (en) * 2019-12-25 2020-04-24 南京三百云信息科技有限公司 Service data docking method and device
CN111638983A (en) * 2020-05-28 2020-09-08 深圳壹账通智能科技有限公司 Interface calling method, interface calling device and terminal equipment
CN112559212A (en) * 2020-12-18 2021-03-26 北京航天云路有限公司 Service call chain implementation method based on self-research framework

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108462758A (en) * 2018-04-02 2018-08-28 平安科技(深圳)有限公司 Bank-corporate express communication means, device, equipment and computer readable storage medium
CN110381135A (en) * 2019-07-18 2019-10-25 北京奇艺世纪科技有限公司 Interface creation method, service request method, device, computer equipment and medium
CN110413354A (en) * 2019-08-01 2019-11-05 苏州浪潮智能科技有限公司 It is a kind of to realize the method, equipment and storage medium interacted with third-party platform
CN111064621A (en) * 2019-12-25 2020-04-24 南京三百云信息科技有限公司 Service data docking method and device
CN111638983A (en) * 2020-05-28 2020-09-08 深圳壹账通智能科技有限公司 Interface calling method, interface calling device and terminal equipment
CN112559212A (en) * 2020-12-18 2021-03-26 北京航天云路有限公司 Service call chain implementation method based on self-research framework

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114051058A (en) * 2021-09-27 2022-02-15 北京旷视科技有限公司 Interface calling method, platform, electronic equipment and computer storage medium
CN114051058B (en) * 2021-09-27 2024-03-26 北京旷视科技有限公司 Interface calling method, platform, electronic equipment and computer storage medium

Similar Documents

Publication Publication Date Title
CA3152829A1 (en) Method and apparatus for processing business data
CN110069297A (en) Abnormality eliminating method, device, computer equipment and storage medium based on Spring MVC
CN114925084B (en) Distributed transaction processing method, system, equipment and readable storage medium
US20040261022A1 (en) System and method for dynamic selection of stateless/stateful software components
CN112035110B (en) Parameter adjusting method, device, client and storage medium
CN113127108A (en) Service request processing method and device, storage medium and electronic equipment
CN113076153A (en) Interface calling method and device
CN113238817A (en) Interface transparent transmission method and device, electronic equipment and storage medium
CN114237594A (en) Form interface generation method, device and system and readable storage medium
CN111767229A (en) Performance test method, device and equipment
EP3974960B1 (en) Method and system for automated testing of web service apis
CN114579194A (en) Spring remote call-based exception handling method and system
CN110633162B (en) Remote call implementation method and device, computer equipment and storage medium
CN111459492A (en) Method, device, storage medium and equipment for detecting compatibility of Dubbo service interface
CN111414154A (en) Method and device for front-end development, electronic equipment and storage medium
CN111373377A (en) Error handling
CN112286767B (en) Redis cache analysis method
CN110990000B (en) Data request processing method, device and equipment of MVC pattern design model layer
CN113468446A (en) Method, system and equipment for supporting identification of third-party two-dimensional code data
CN108959508B (en) SQL data generation method and device
CN113434435A (en) Test case logic automatic generation method and device
US20190196945A1 (en) Entity performance and usability analysis framework
CN113467860B (en) Service logic execution method and device of program source code
CN117472367B (en) Heterogeneous resource intelligent identification and access method, device, equipment and storage medium
FI111566B (en) Procedure for inverting program control flow

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