Interface switching method, device, server and system based on remote call component
By responding to interface switching requests, obtaining the information of the current remote calling interface and generating a new interface, the problem of manually modifying a large amount of code in the existing technology of switching remote calling components is solved, and efficient and seamless interface switching is achieved.
Patent Information
- Application Number
- CN202411789894.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-06
- Publication Date
- 2025-04-22
AI Technical Summary
The prior art requires manual modification of a large amount of code when switching between remote calling components, which is prone to errors and is inefficient.
It provides an interface switching method based on the remote calling component. By responding to the interface switching request, it obtains the interface information of the current remote calling interface, and generates a new interface according to the specifications of the remote calling component to be switched to realize interface switching.
Without affecting the normal operation of the business system, efficient switching of remote calling components reduces the need for code modification and improves interface switching efficiency.
Smart Images

Figure CN119862045A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to an interface switching method, device, server and system based on remote calling components. Background Art
[0002] Currently, the business systems of financial institutions usually use microservices to implement business functions, among which remote call components (such as Dubbo and Feignd) are one of the key technologies to realize communication between different services in the business system.
[0003] In business systems, different remote calling technologies may need to be used under different business requirements or technology stacks. Taking Dubbo and Feign as examples, Dubbo is a framework based on Remote Procedure Call (RPC), which allows remote services to be called like local methods, while Feign is a declarative Web service client that makes it easier to write Web service clients. It handles the generation of Hypertext Transfer Protocol (HTTP) requests and the parsing of responses, simplifying the interaction with Web services.
[0004] Currently, switching remote call components usually requires rewriting the remote call interface in the system, and developers have to manually modify a large amount of code, which is prone to errors and has low efficiency. Summary of the invention
[0005] The present application provides an interface switching method, device, server and system based on remote calling components to solve at least one of the above technical problems.
[0006] In a first aspect, the present application provides an interface switching method based on a remote call component, comprising:
[0007] Responding to an interface switching request for a business system, the interface switching request being generated based on current operation information of the business system and / or triggered by a user;
[0008] When it is determined that the interface switching request meets the preset interface switching condition, the interface information of the current first remote call interface of the business system is obtained; wherein the communication mechanism of the first remote call interface is implemented based on the first remote call component;
[0009] According to the specification of the second remote call component to be switched and the interface information, a second remote call interface based on the communication mechanism implemented by the second remote call component is generated; wherein the second remote call component is a component of a different type from the first remote call component;
[0010] The second remote call interface is output to the business system, so that the business system switches the first remote call interface to the second remote call interface.
[0011] In one implementation, generating a second remote call interface corresponding to the second remote call component according to the specification of the second remote call component to be switched and the interface information includes:
[0012] Parsing the specification of the second remote call component to obtain a parsing result, wherein the parsing result includes a uniform resource locator structure and / or a data format;
[0013] According to the analysis result, matching and designing the relevant information in the interface information to obtain new interface information, wherein the interface information includes a uniform resource locator corresponding to the uniform resource locator structure and / or parameters corresponding to the data format;
[0014] A second remote call interface corresponding to the second remote call component is generated according to the new interface information.
[0015] In one implementation, matching and designing the relevant information in the interface information according to the parsing result to obtain new interface information includes at least one of the following:
[0016] Generate a new uniform resource locator corresponding to the interface according to the uniform resource locator structure obtained by parsing and the path in the uniform resource locator in the interface information;
[0017] According to the data format obtained by parsing and the data type of the parameter in the interface information, the mandatory parameter items and the optional parameter items are determined, so as to generate parameters corresponding to the new interface according to the mandatory parameter items and the optional parameter items.
[0018] In one implementation, after generating the second remote call interface corresponding to the second remote call component according to the new interface information, the method further includes:
[0019] The second remote call interface is tested and verified through at least one of a unit test and an integration test, and the second remote call interface is output to the business system after the second remote call interface passes the verification.
[0020] In one implementation, the obtaining interface information of the current first remote call interface of the business system includes:
[0021] Sending an interface information acquisition request to a registration center for business system interface information, wherein the interface information acquisition request carries basic information of the business system;
[0022] The interface information of the first remote call interface is obtained from the registration center.
[0023] In one implementation, the determining that the interface switching request meets a preset interface switching condition includes:
[0024] Determining whether the underlying communication protocol and / or business function of the business system has changed according to the current operation information;
[0025] When the underlying communication protocol and / or service function changes, it is determined that the interface switching request meets a preset interface switching condition.
[0026] In one embodiment, the method further comprises:
[0027] After the second remote call interface is generated, the interface data corresponding to the second remote call interface is stored in a persistent data storage device.
[0028] In one implementation, the first remote call component is a Dubbo component, and the second remote call component is a Feign component.
[0029] According to a second aspect of the present application, there is provided an interface switching device based on a remote call component, comprising:
[0030] A response module, which is configured to respond to an interface switching request for a business system, wherein the interface switching request is generated based on current operation information of the business system and / or triggered by a user; an interface information acquisition module, which is configured to acquire interface information of a current first remote call interface of the business system when it is determined that the interface switching request meets a preset interface switching condition; wherein the communication mechanism of the first remote call interface is implemented based on a first remote call component;
[0031] An interface generation module, which is configured to generate a second remote call interface based on the communication mechanism implemented by the second remote call component according to the specification of the second remote call component to be switched and the interface information; wherein the second remote call component is a component of a different type from the first remote call component;
[0032] The interface output module is configured to output the second remote call interface to the business system, so that the business system switches the first remote call interface to the second remote call interface.
[0033] According to a third aspect of the present application, there is provided a server, comprising: a processor, and a memory communicatively connected to the processor;
[0034] The memory stores computer-executable instructions;
[0035] The processor executes the computer-executable instructions stored in the memory to implement the interface switching method based on remote call components as provided in any one of the first aspects above.
[0036] According to the fourth aspect of the present application, a computer-readable storage medium is provided, in which computer execution instructions are stored. When the computer execution instructions are executed by a processor, they are used to implement the interface switching method based on the remote call component as provided in any one of the first aspects above.
[0037] According to a fifth aspect of the present application, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the interface switching method based on remote call components as provided in any one of the first aspects above.
[0038] According to a sixth aspect of the present application, there is provided an interface switching system based on a remote call component, comprising an integrated system for executing an interface switching method based on a remote call component as provided in any one of the first aspects above, and a business system and a registration center electrically connected to the integrated system respectively; wherein,
[0039] The business system runs multiple microservices to execute related businesses, and the multiple microservices communicate with each other through remote call interfaces;
[0040] The registration center is used to receive and store the interface information of the business system, and send the interface information of the business system to the integration system when the integration system initiates an interface information acquisition request.
[0041] The interface switching method, device, server and system based on remote call component provided by the present application, by responding to the interface switching request for the business system, and when determining that the interface switching request meets the preset interface switching condition, obtaining the interface information of the current first remote call interface of the business system, the communication mechanism of the first remote call interface is implemented based on the first remote call component, according to the specification of the second remote call component to be switched, and the interface information, generating a second remote call interface based on the communication mechanism implemented by the second remote call component, the second remote call component is a component of a different type from the first remote call component, and outputting the second remote call interface to the business system so that the business system switches the first remote call interface to the second remote call interface. In this process, by obtaining the interface information of the current remote call interface, using the specification of the component to be switched and the current interface information to generate the interface of the component to be switched, and transmitting it to the business system for interface switching, instead of modifying the code to switch the interface, it can be efficiently switched from one remote call component to another remote call component without affecting the normal operation of the business system, and there is no need to write a lot of code, thereby improving the efficiency of interface switching. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] 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 present application.
[0043] Figure 1 A possible scenario diagram provided for an embodiment of the present application;
[0044] Figure 2 A flowchart of an interface switching method based on a remote call component provided in an embodiment of the present application;
[0045] Figure 3 A flowchart of another interface switching method based on a remote call component provided in an embodiment of the present application;
[0046] Figure 4 A schematic diagram of the structure of an interface switching device based on a remote call component provided in an embodiment of the present application;
[0047] Figure 5 One of the structural schematic diagrams of an interface switching system based on a remote call component provided in an embodiment of the present application;
[0048] Figure 6 A second structural diagram of an interface switching system based on a remote call component provided in an embodiment of the present application;
[0049] Figure 7 for Figure 6 One of the process flow diagrams of the integrated system 520;
[0050] Figure 8 for Figure 6 Processing flow chart 2 of the integrated system 520;
[0051] Fig. 9 for Figure 6 Processing flow chart 3 of the integrated system 520;
[0052] Fig.10 A schematic diagram of the structure of a server provided in an embodiment of the present application.
[0053] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0054] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0055] In the technical solution of this application, the collection, storage, use, processing, transmission, provision and disclosure of financial data or user data and other information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals. It should be noted that in the embodiments of this application, some existing solutions in the industry such as certain software, components, models, etc. may be mentioned, and they should be considered as exemplary. Their purpose is only to illustrate the feasibility of the implementation of the technical solution of this application, but it does not mean that the applicant has or will necessarily use the solution.
[0056] To facilitate understanding of the embodiments of the present application, the terms involved in the embodiments of the present application are first explained:
[0057] Microservices: A software architecture style that designs applications as a set of small, independently deployable services. These services are usually built around specific business functions and communicate through remote call interfaces.
[0058] Remote call component: also known as the remote call framework, a software module or tool used to implement and manage remote procedure calls. It implements the communication mechanism of the remote call interface and is responsible for communication between different services.
[0059] Dubbo: is a high-performance remote call component (or framework) used to build a distributed service architecture, especially in a microservice environment. Dubbo provides a complete solution to achieve service governance and inter-service communication. It is interface-oriented and implements service calls through interface proxies. The client only needs to call the local interface to call the remote service like calling a local method.
[0060] Feign: It can be regarded as a remote call component, especially used to simplify Hypertext Transfer Protocol (HTTP) communication between services when building a microservice architecture. As a declarative HTTP client, Feign provides a convenient way to call the interface (Application Programming Interface, API) of the remote service. It simplifies the remote call process by defining interfaces and using annotations to describe the details of HTTP requests, and automatically generating proxy objects that implement these interfaces.
[0061] The technical solutions of the present application and the technical solutions of the present application are described in detail below with specific embodiments in combination with application scenarios. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in combination with the accompanying drawings.
[0062] Figure 1 FIG. 1 is an application scenario diagram applicable to the method of the embodiment of the present application. Figure 1 As shown, the application scenario includes: a business system 110 and a server 120 electrically connected to the business system. Optionally, the business system can be a bank's business system, such as using a microservice framework to process transfer business. When different business needs or technology stacks are used, different remote call technologies may need to be used (taking the switch from Dubbo to Feign as an example, if the banking business system gradually migrates to the Spring Cloud ecosystem, Feign, as a native component of Spring Cloud, may be easier to integrate and use. At this time, the original remote call framework Dubbo needs to be switched to Feign). Optionally, the server 120 is used to obtain the interface information of the current remote call interface of the business system, and generate a new remote call interface for the business system to realize the automatic switching of the remote call interface.
[0063] In the related technology, when the business system needs to switch the remote call framework, since the remote call framework usually uses interface definitions to achieve communication between services, a large amount of code needs to be manually modified, and the remote call interface needs to be rewritten in the system. This method is prone to writing errors and the testing cycle is too long, which will affect business efficiency.
[0064] In view of this, the interface switching method, device, server and system based on the remote call component provided in the embodiment of the present application, by responding to the interface switching request for the business system, and when determining that the interface switching request meets the preset interface switching condition, the interface information of the current first remote call interface of the business system is obtained, the communication mechanism of the first remote call interface is implemented based on the first remote call component, and according to the specification of the second remote call component to be switched, and the interface information, a second remote call interface based on the communication mechanism implemented by the second remote call component is generated, and the second remote call component is a component of a different type from the first remote call component, and the second remote call interface is output to the business system so that the business system switches the first remote call interface to the second remote call interface. In this process, by obtaining the interface information of the current remote call interface, the interface of the component to be switched is generated using the specification of the component to be switched and the current interface information, and transmitted to the business system for interface switching, instead of modifying the code switching interface, it is possible to efficiently switch from one remote call component to another remote call component without affecting the normal operation of the business system, and there is no need to write a lot of code, thereby improving the efficiency of interface switching.
[0065] based on Figure 1 In the application scenario shown, the embodiment of the present application also provides an interface switching method based on a remote calling component, and the execution subject of the method can be the server 120. Figure 2 The flowchart of the interface switching method based on the remote call component provided in the embodiment of the present application is as follows. Figure 2 As shown, the method includes:
[0066] Step S201, responding to an interface switching request for a business system, the interface switching request is generated according to current operation information of the business system and / or triggered by a user. In this embodiment, the business system may be a bank's business system, such as a transfer system, which is usually composed of multiple microservices.
[0067] In one example, an interface switching request may be automatically generated based on the current operating information of the business system. For example, the business system collects and analyzes the operating data of the system in real time based on the existing monitoring mechanism. The operating data may include system logs, network communication traffic, API call records, configuration files, and other relevant system status information, etc. The interface call frequency, response time, error rate, system load, etc. may be obtained through these data. System administrators can set some rules for automatically generating interface switching requests based on prior data or business. For example, when the response time of an interface continues to exceed a threshold, or the error rate reaches a certain proportion, the system can automatically generate an interface switching request. Alternatively, the business system can use machine learning or other intelligent analysis tools to predict potential performance bottlenecks or failures, and generate interface switching requests in advance to avoid affecting the user experience.
[0068] In another example, the interface switching request may also be manually triggered by a user, for example, a user (which may be a developer, operation and maintenance personnel, or business user) identifies a situation where an interface switching is required based on their experience or feedback. For example, a user may find that a certain interface performs poorly or is unstable in a specific scenario, and manually submits an interface switching request through an interface or tool provided by the business system, which may carry the reason for the switching provided by the user, information about the target interface, and the expected switching time, etc.
[0069] It can be understood that in response to the conditions or states on which the executed operations depend, when the dependent conditions or states are met, one or more operations executed can be in real time or have a set delay; unless otherwise specified, there is no restriction on the order of execution of the multiple operations executed.
[0070] Step S202: when it is determined that the interface switching request meets the preset interface switching condition, the interface information of the current first remote call interface of the business system is obtained; wherein the communication mechanism of the first remote call interface is implemented based on the first remote call component.
[0071] Then, after receiving the interface switching request, the server may first determine whether the interface switching request meets the interface switching condition of the response, and the interface switching condition may be adaptively set by a person skilled in the art according to actual application or prior data, for example, the interface switching request is for conditions such as changes in the underlying communication protocol or changes in business functions, or other conditions such as call frequency, etc. It is understandable that in some embodiments, whether the interface switching request meets the switching condition may also be determined by other devices or servers.
[0072] The remote call interface is used to implement the communication interface between these services. The remote call interface defines the interaction mode between services, including the data format of requests and responses. When you need to switch remote call components (for example, from one framework to another), you usually need to switch to the corresponding interface according to the requirements of the new component to ensure that the communication between services can proceed normally.
[0073] It can be understood that the communication mechanism of the first remote call interface is implemented based on the first remote call component. The current remote call interface is implemented by a specific remote call component, which determines the communication mechanism of the interface, including the protocol used, data format, calling method, etc. This component provides infrastructure and tools for the implementation of the interface.
[0074] Instead of the related technology in which developers directly write code and modify the interface of the business system to achieve interface switching, this embodiment uses the server to obtain the interface information of the current remote call interface of the business system, and generates a new interface for the business system according to the specifications of the new component in combination with the subsequent process, thereby avoiding the receipt of a large amount of modification code to replace the remote call component, and realizing unified input, organization, conversion, and output of interface information, thereby achieving the effect of seamless replacement of different remote call components.
[0075] Exemplarily, the interface information of the business system may be obtained through the registration center. The above step S201 obtains the interface information of the current first remote call interface of the business system in the following manner:
[0076] Sending an interface information acquisition request to a registration center for business system interface information, wherein the interface information acquisition request carries basic information of the business system;
[0077] The interface information of the first remote call interface is obtained from the registration center.
[0078] In this embodiment, the registration center may be a centralized service management platform for maintaining and providing registration information for services. The interface information acquisition request may include basic information of the business system, which is used to identify and locate the corresponding interface information in the registration center. The basic information may include the name, unique identifier, version number, etc. of the business system.
[0079] After receiving the interface information acquisition request, the registration center will search for the corresponding interface information in its database based on the basic information of the business system provided in the request. The registration center stores detailed information about each registered service, including interface definition, method signature, parameter type, return value type, communication protocol, network address, etc.
[0080] In this way, the server can effectively obtain the currently used remote call interface information and provide data support for interface switching and other management operations.
[0081] By way of further example, the server can determine whether the underlying communication protocol or business function of the business system has changed through the current operation information of the business system, and obtain the current interface information when a change occurs, thereby dynamically generating a new interface. Specifically, the above steps of determining that the interface switching request meets the preset interface switching condition may include the following steps:
[0082] Determining whether the underlying communication protocol and / or business function of the business system has changed according to the current operation information;
[0083] When the underlying communication protocol and / or service function changes, it is determined that the interface switching request meets a preset interface switching condition.
[0084] In this embodiment, the server can dynamically monitor the operating status of the business system and automatically generate a new interface for it when the business system has a demand. Specifically, the server can include system logs, network communication traffic, API call records, configuration files and other related system status information, etc. by comprehensively collecting the operating information of the current business system, and these data provide a comprehensive view of the current operating status of the system. After obtaining the current operating information, the system analyzes this information to determine whether the underlying communication protocol and / or business function has changed, such as comparing the current communication protocol version with the known version. If the analysis result shows that the underlying communication protocol and / or business function has changed, the subsequent steps are executed. This change can be caused by system upgrades, external service updates or configuration adjustments, and these changes will cause the business system to need to switch remote call components to meet communication needs. After confirming the change, the server obtains the interface information of the current first remote call interface, such as a uniform resource locator (URL), etc., and obtains the interface information so that the subsequent process generates a new remote call interface, so that the new interface maintains compatibility with the old interface or provides enhanced functions to ensure the normal operation and seamless transition of the business system.
[0085] In some embodiments, in addition to determining the switching requirements of the remote call interface by identifying whether the underlying communication protocol and business functions have changed, the switching requirements of the remote call interface can also be determined by identifying information such as technology stack updates and security requirements changes, so as to timely obtain the interface information of the current interface and generate a new interface.
[0086] In some embodiments, the server can also obtain the interface information of the current first remote call interface of the business system by responding to the interface switching request information initiated by the business system. It can be understood that the response is used to indicate the conditions or states on which the executed operation depends. When the dependent conditions or states are met, the one or more operations executed can be real-time or have a set delay; unless otherwise specified, there is no restriction on the execution order of the multiple operations executed.
[0087] Step S203: Generate a second remote call interface based on the communication mechanism implemented by the second remote call component according to the specification of the second remote call component to be switched and the interface information; wherein the second remote call component is a component of a different type from the first remote call component.
[0088] Exemplarily, the first remote call component may be a Dubbo component, and the second remote call component may be a Feign component. It is understandable that both Dubbo and Feign are RPC frameworks for microservice architecture, but they have different configurations and usage methods.
[0089] In some examples, the first remote call component and the second remote call component may also be other different types of components. For example, the first remote call component may be a gRPC framework, and the second remote call component may be a REST framework. This embodiment does not specifically limit this.
[0090] In this embodiment, in order to make the newly generated interface adaptable to the current interface to avoid affecting the business system function, a new interface corresponding to the second remote call component is generated according to the specification of the second remote call component to be switched and the current interface information, wherein the specification of the second remote call component can be a specification document that describes the interface definition, communication protocol, data format, etc. of the framework in detail.
[0091] It should be noted that the first remote call interface and the second remote call interface in this embodiment are only used to describe similar objects and have no other special meanings. The first remote substitute interface and the second remote call interface can be the same interface or different interfaces.
[0092] Alternatively, taking the switching of Dubbo component to Feign component as an example, you can first define a general interface, which can include two methods, one for processing POST requests and the other for processing GET requests. Each method includes two parameters, one for the url of the interface to be called and the other for the parameters to be passed when calling. In this way, the same interface can be used to process different requests. Next, create a dynamic Feign client. This client can call the corresponding microservice interface according to the incoming microservice name (such as the business system name system) and interface url (the url can be a new url generated according to the url of the existing interface and the url structure corresponding to the Feign specification). In this way, different microservices can be called without changing the code. In the process of creating a dynamic Feign client, it can be implemented based on the factory class that defines the Feign client. The role of this factory class is to generate a corresponding Feign client instance according to the incoming microservice name, so as to create a new Feign client according to the demand.
[0093] Step S204: output the second remote call interface to the business system, so that the business system switches the first remote call interface to the second remote call interface.
[0094] Specifically, the server deploys the definition and implementation of the second remote call interface to the business system. Based on the original system, the business system can switch the interface by configuring the system's remote call interface information (url, parameters, etc.) according to the received remote call interface. In the process of using the remote call interface in the business system, the above example is continued as an illustration. The DynamicClient object can be obtained through the Spring tool class, and the executePostApi method can be called to pass in the microservice name, interface URL and parameters to dynamically call the interface. For example, the "newURL" interface of the "miniService" microservice can be called and some parameters can be passed in.
[0095] Through this method, you can efficiently switch from one remote call component to another without affecting the normal operation of the business system and without writing a lot of code.
[0096] Figure 31 is a flow chart of another interface switching method based on a remote call component provided by an embodiment of the present application. On the basis of the above embodiment, this embodiment illustrates a process of generating a new interface. Specifically, the above step S203 generates a second remote call interface corresponding to the second remote call component according to the specification of the second remote call component to be switched and the interface information, including steps S2031-S2033:
[0097] Step S2031: parse the specification of the second remote call component to be switched to obtain a parsing result, wherein the parsing result includes a uniform resource locator structure and / or a data format.
[0098] In this embodiment, parsing the specification of the second remote call component can be a process of parsing the communication protocol in the specification, for example, by analyzing the communication protocol, understanding the communication protocol (such as HTTP / 2) used by the framework, and parsing the relevant request and response formats to determine the URL structure, including the host name, path, query parameters, etc. Alternatively, by analyzing the serialization method of the specification to obtain its data format, such as JSON, XML, etc., including field names, types, nested structures, etc.
[0099] Step S2032: According to the parsing result, matching and designing are performed on the relevant information in the interface information to obtain new interface information, wherein the interface information includes a uniform resource locator corresponding to the uniform resource locator structure and / or parameters corresponding to the data format.
[0100] Taking the switch from Dubbo to Feign as an example, the process is to convert Dubbo's RPC call model to Feign's HTTP request model. Specifically, the method name and parameters of the current Dubbo interface are mapped to Feign's URL path and request parameters, and Feign's HTTP method type is determined to match the semantics of the Dubbo method, and Dubbo's data format (such as serialized objects) is converted to a format supported by Feign (such as JSON, XML), etc. New interfaces can be defined using Feign annotations to ensure that the signature of the Feign interface method matches the functionality of the Dubbo method.
[0101] In one example, the above step S2032 may be performed in the following manner:
[0102] A new uniform resource locator corresponding to the interface is generated according to the uniform resource locator structure obtained by parsing and the path in the uniform resource locator in the interface information.
[0103] In this example, the structural parts of the URL to be generated are parsed so that these parts can be correctly reorganized when generating a new URL. Among them, the path in the current interface information is the relative path of the interface, and this path defines the access method and hierarchical structure of the resource. By combining the URL structure obtained by parsing with the path in the interface information, that is, replacing or appending the new path part to the path part of the existing URL, after completing the merging of the path and structure, a complete URL corresponding to the new interface is generated, so that the merged URL is syntactically correct and can correctly point to the new interface resource.
[0104] In another example, the above step S2032 can also be implemented as follows: according to the parsed data format and the data type of the parameters in the interface information, the required parameters and optional parameters are determined to generate parameters corresponding to the new interface according to the required parameters and optional parameters.
[0105] For example, by querying the parameters marked as required in the old interface, and according to the format requirements of the new interface, determine whether these parameters are still required; accordingly, by querying the parameters marked as optional in the old interface, and according to the requirements of the new interface, evaluate whether these parameters are still optional. Based on the above analysis results, define the parameter list of the new interface, specify the data type, default value (if applicable), required or not, etc. for each parameter, so as to ensure that the parameter design of the new interface meets the data format requirements and business logic.
[0106] It is understood that mandatory fields are indicated in the definition of the data format. For example, in JSON Schema, the required keyword can be used to specify mandatory fields, and optional fields correspond to any fields that are not marked as required and can usually be considered optional.
[0107] In some examples, the above two examples may be combined to generate new interface information, or new interface information may be generated based on other information, such as security information, such as data encryption.
[0108] Step S2033: Generate a second remote call interface corresponding to the second remote call component according to the new interface information.
[0109] Through the above interface generation process, it is possible to dynamically generate a new remote call interface based on the existing remote call interface without the need to frequently modify the code, and the adaptability is higher, so that the new remote call component can ensure that the microservice can call the business process normally, and then switch to the old remote call component without affecting the business operation.
[0110] In some embodiments, in order to ensure the availability of the second remote call interface, this embodiment transmits the generated second remote call interface to the business system after testing the interface. Specifically, after the second remote call interface corresponding to the second remote call component is generated according to the new interface information in the above step S204, the following steps may also be included:
[0111] The second remote call interface is tested and verified through at least one of a unit test and an integration test, and the second remote call interface is output to the business system after the second remote call interface passes the verification.
[0112] Taking unit testing as an example, you can write unit test cases for each function of the remote call interface. The test cases should cover normal situations, boundary situations, and abnormal situations, and use the existing test framework to perform unit testing to check whether the test results meet expectations. If the test fails, analyze the cause and regenerate a new second remote call interface. If the verification is successful, the second remote call interface is output to the business system for operation.
[0113] It is understandable that unit testing is a test that verifies the smallest testable unit (usually a function or method) in the software. Its purpose is to ensure that each unit works as expected in an isolated environment. Integration testing is to test multiple units or modules in the software together to verify their ability to work together as a whole. In this embodiment, the second remote call interface can be tested and verified using unit testing or integration testing. In some embodiments, in addition to using unit testing or integration testing verification, other testing methods can also be used for verification, and this application does not make any special restrictions on this.
[0114] In the alternative related art, a new interface is generated by manually modifying the code. Since the code modification method is prone to errors and the testing process is more complicated, this embodiment also effectively improves the testing efficiency based on the above-mentioned interface replacement method and testing process.
[0115] In some embodiments, the method provided in this embodiment may further include the following steps:
[0116] After the second remote call interface is generated, the interface data corresponding to the second remote call interface is stored in a persistent data storage device.
[0117] Exemplarily, a suitable persistent data storage (such as a database, NoSQL storage) can be selected to save the interface data, and the interface data can include data before the interface call and data after the interface call, which is not particularly limited in this embodiment. For example, a data model and table structure can be defined to store the relevant data of the interface call (such as request parameters, response results, call time, etc.). In addition, after the interface call, the necessary data can also be stored in the persistent storage.
[0118] Through the above method, the interface data in the process of persistent storage interface generation can be used to effectively enhance data management and analysis capabilities.
[0119] Figure 4 is a structural diagram of an interface switching device based on a remote call component provided in an embodiment of the present application, such as Figure 4 As shown, the device 400 includes an interface information acquisition module 401, an interface generation module 402 and a switching module 403; wherein,
[0120] A response module 401, which is configured to respond to an interface switching request for a business system, wherein the interface switching request is generated according to current operation information of the business system and / or is triggered by a user;
[0121] The interface information acquisition module 402 is configured to acquire the interface information of the current first remote call interface of the business system when it is determined that the interface switching request meets the preset interface switching condition; wherein the communication mechanism of the first remote call interface is implemented based on the first remote call component;
[0122] An interface generation module 403, which is configured to generate a second remote call interface based on the communication mechanism implemented by the second remote call component according to the specification of the second remote call component to be switched and the interface information; wherein the second remote call component is a component of a different type from the first remote call component;
[0123] The interface output module 404 is configured to output the second remote call interface to the business system, so that the business system switches the first remote call interface to the second remote call interface.
[0124] In one implementation, the interface generation module 403 includes:
[0125] A parsing unit, configured to parse the specification of the second remote call component to obtain a parsing result, wherein the parsing result includes a uniform resource locator structure and / or a data format;
[0126] a matching unit, configured to match and design the relevant information in the interface information according to the parsing result to obtain new interface information, wherein the interface information includes a uniform resource locator corresponding to the uniform resource locator structure and / or parameters corresponding to the data format;
[0127] A generating unit is configured to generate a second remote calling interface corresponding to the second remote calling component according to the new interface information.
[0128] In one embodiment, the matching unit includes at least one of the following:
[0129] A first matching subunit, which is configured to generate a new uniform resource locator corresponding to the interface according to the uniform resource locator structure obtained by parsing and the path in the uniform resource locator in the interface information;
[0130] The second matching subunit is configured to determine mandatory parameters and optional parameters according to the parsed data format and the data type of the parameters in the interface information, so as to generate parameters corresponding to a new interface according to the mandatory parameters and the optional parameters.
[0131] In one embodiment, the device further comprises:
[0132] A testing module is configured to test and verify the second remote call interface through at least one of a unit test and an integration test, and output the second remote call interface to the business system after the second remote call interface passes the verification.
[0133] In one implementation, the interface information acquisition module 402 includes:
[0134] A request unit, configured to send an interface information acquisition request to a registration center for business system interface information, wherein the interface information acquisition request carries basic information of the business system;
[0135] An acquiring unit is configured to acquire interface information of the first remote call interface from the registration center.
[0136] In one implementation, the interface information acquisition module 402 includes:
[0137] a determination unit, configured to obtain current operation information of the business system, and determine whether an underlying communication protocol and / or business function of the business system has changed according to the current operation information;
[0138] When the underlying communication protocol and / or service function changes, it is determined that the interface switching request meets a preset interface switching condition.
[0139] In one embodiment, the device further comprises:
[0140] After the second remote call interface is generated, the interface data corresponding to the second remote call interface is stored in a persistent data storage device.
[0141] In one implementation, the first remote call component is a Dubbo component, and the second remote call component is a Feign component.
[0142] The above-mentioned device provided in the embodiment of the present application can be used to execute the technical solution of the interface switching method based on the remote calling component in the above-mentioned embodiment. Its implementation principle and technical effect are similar and will not be repeated here.
[0143] It should be noted that it should be understood that the division of the various modules of the above device is only a division of logical functions. In actual implementation, they can be fully or partially integrated into one physical entity, or they can be physically separated. And these modules can all be implemented in the form of software calling through processing elements; they can also be all implemented in the form of hardware; some modules can also be implemented in the form of software calling through processing elements, and some modules can be implemented in the form of hardware. For example, the interface generation module 403 can be a separately established processing element, or it can be integrated in a chip of the above device for implementation. In addition, it can also be stored in the memory of the above device in the form of program code, and called and executed by a processing element of the above device. The function of the above interface generation module 403. The implementation of other modules is similar. In addition, all or part of these modules can be integrated together, or they can be implemented independently. The processing element here can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each module above can be completed by an integrated logic circuit of hardware in the processor element or instructions in the form of software.
[0144] The embodiment of the present application also provides an interface switching system based on a remote calling component. Figure 5 As shown, it includes an integrated system 520 for executing the interface switching method based on remote call components provided in the above method embodiment, a business system 510 and a registration center 530 electrically connected to the integrated system 520 respectively; wherein,
[0145] The business system 510 runs multiple microservices to execute related businesses, and the multiple microservices communicate with each other through remote call interfaces. For example, before generating a new remote call interface (i.e., the second remote call interface, such as the interface corresponding to feign), the old remote call interface (i.e., the first remote call interface, such as the interface corresponding to dubbo) is used for communication;
[0146] The registration center 530 is used to receive and store the interface information of the business system, and send the interface information of the business system to the integrated system when the integrated system initiates an interface information acquisition request. The interface information is the interface information of the remote call interface. In addition, the registration center can also be used to register and manage the remote call interface information of the business system.
[0147] like Figure 6 As shown, the system may also include a data base (DB) 540; the DB 540 is electrically connected to the integrated system 520 and is used to persistently store the relevant interface data.
[0148] The integrated system 520 includes a remote call interface information module 521 (corresponding to the interface information acquisition module 401 in the device embodiment) and a remote call interface conversion module 522 (corresponding to the interface generation module 402 and the interface output module 403 in the device embodiment), wherein the remote call interface information module 521 is used to obtain the interface information (url, parameters, etc.) of the old remote call interface from the registration center 530, and the remote call interface conversion module 522 is used to generate a new remote call interface according to the new remote call component specification and the interface information of the original remote call interface, and output it to the business system 510 to implement the switching of the old remote call interface. Exemplarily, the integrated system 520 can be an integrated application using springboot as a web server container.
[0149] The process of storing relevant interface data in db540 may include storing original interface information and storing generated interface information:
[0150] For example, the process of the integration system 520 obtaining the interface information from the registration center 530 may be as follows: Figure 7 As shown, after receiving the interface information, the integrated system 520 may store the received interface information in db540.
[0151] As a further example, the integration system 520 generates a new remote call interface according to the new remote call component specification and the interface information of the original system, such as Figure 8 As shown, after generating a new remote call interface, the integration system 520 stores the interface information of the remote call interface in db540. Fig. 9 It shows that after the integration system 520 generates a new remote call interface, it outputs it to the business system (the remote call interface is replaced) and ends the process.
[0152] Through the above technical solution, a large amount of modification code received for remote call component replacement is effectively avoided. The integrated system is used to uniformly input, organize, convert and output interface information, achieving the effect of seamless replacement of different remote call components.
[0153] Fig.10 is a schematic diagram of the structure of a server provided in an embodiment of the present application, such as Figure 8 As shown, the server includes: a transceiver 1001 , a processor 1002 , and a memory 1003 .
[0154] The processor 1002 executes the computer-executable instructions stored in the memory, so that the processor 1002 executes the scheme in the above method embodiment. The processor 1002 can be a general-purpose processor, including a central processing unit CPU, a network processor (NP), etc.; it can also be a digital signal processor DSP, an application-specific integrated circuit ASIC, a field programmable gate array FPGA or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.
[0155] The memory 1003 is connected to the processor 1002 via a system bus and completes communication between them. The memory 1003 is used to store computer program instructions.
[0156] The transceiver 1001 may be used to communicate with external devices.
[0157] The system bus can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The system bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. The transceiver is used to realize the communication between the database access device and other computers (such as clients, read-write libraries, and read-only libraries). The memory may include random access memory (RAM) and may also include non-volatile memory.
[0158] The above-mentioned server provided in the embodiment of the present application can be used to execute the technical solution of the interface switching method based on the remote call component in the above-mentioned embodiment. Its implementation principle and technical effect are similar and will not be repeated here.
[0159] The embodiment of the present application also provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are executed by a processor, they are used to implement the interface switching method based on the remote call component as provided in the above method embodiment.
[0160] The above-mentioned medium provided in the embodiment of the present application can be used to execute the technical solution of the interface switching method based on the remote calling component in the above-mentioned embodiment. Its implementation principle and technical effect are similar and will not be repeated here.
[0161] An embodiment of the present application also provides a computer program product, including a computer program, which, when executed by a processor, implements the interface switching method based on the remote call component as provided in any one of the first aspects above.
[0162] The above-mentioned program product provided in the embodiment of the present application, the computer program product includes a computer program, which is stored in a computer-readable storage medium. At least one processor can read the computer program from the computer-readable storage medium. When at least one processor executes the computer program, it can be used to execute the technical solution of the interface switching method based on the remote call component in the above-mentioned embodiment. Its implementation principle and technical effects are similar and will not be repeated here.
[0163] An embodiment of the present application also provides a chip for running instructions, which is used to execute the technical solution of the interface switching method based on the remote calling component in the above embodiment, and the relevant description will not be repeated here.
[0164] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules is only a logical function division, and there may be other division methods in actual implementation, such as multiple modules can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or modules, which can be electrical, mechanical or other forms.
[0165] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to implement the solution of this embodiment.
[0166] In addition, each functional module in each embodiment of the present application can be integrated into one processing unit, or each module can exist physically separately, or two or more modules can be integrated into one unit. The above-mentioned module-composed unit can be implemented in the form of hardware or in the form of hardware plus software functional units.
[0167] The above-mentioned integrated module implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a storage medium, including a number of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to perform some steps of the methods of various embodiments of the present application.
[0168] It should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the invention may be directly implemented as being executed by a hardware processor, or may be implemented by a combination of hardware and software modules in the processor.
[0169] The memory may include a high-speed RAM memory, and may also include a non-volatile storage NVM, such as at least one disk memory, and may also be a USB flash drive, a mobile hard disk, a read-only memory, a magnetic disk or an optical disk, etc.
[0170] The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of the present application is not limited to only one bus or one type of bus.
[0171] The above storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The storage medium can be any available medium that can be accessed by a general or special purpose computer.
[0172] An exemplary storage medium is coupled to a processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an application specific integrated circuit (ASIC). Of course, the processor and the storage medium can also exist as discrete components in an electronic control unit or a main control device.
[0173] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.
[0174] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. An interface switching method based on remote call component, characterized in that: include: Responding to an interface switching request for a business system, the interface switching request being generated based on current operation information of the business system and / or triggered by a user; When it is determined that the interface switching request meets the preset interface switching condition, the interface information of the current first remote call interface of the business system is obtained; wherein the communication mechanism of the first remote call interface is implemented based on the first remote call component; According to the specification of the second remote call component to be switched and the interface information, a second remote call interface based on the communication mechanism implemented by the second remote call component is generated; wherein the second remote call component is a component of a different type from the first remote call component; The second remote call interface is output to the business system, so that the business system switches the first remote call interface to the second remote call interface.
2. The method according to claim 1, characterized in that The step of generating a second remote call interface corresponding to the second remote call component according to the specification of the second remote call component to be switched and the interface information includes: Parsing the specification of the second remote call component to obtain a parsing result, wherein the parsing result includes a uniform resource locator structure and / or a data format; According to the analysis result, matching and designing the relevant information in the interface information to obtain new interface information, wherein the interface information includes a uniform resource locator corresponding to the uniform resource locator structure and / or parameters corresponding to the data format; A second remote call interface corresponding to the second remote call component is generated according to the new interface information.
3. The method according to claim 2, characterized in that According to the analysis result, matching and designing the relevant information in the interface information to obtain new interface information includes at least one of the following: Generate a new uniform resource locator corresponding to the interface according to the uniform resource locator structure obtained by parsing and the path in the uniform resource locator in the interface information; According to the data format obtained by parsing and the data type of the parameter in the interface information, the mandatory parameter items and the optional parameter items are determined, so as to generate parameters corresponding to the new interface according to the mandatory parameter items and the optional parameter items.
4. The method according to claim 2 or 3, characterized in that: After generating a second remote call interface corresponding to the second remote call component according to the new interface information, the method further includes: The second remote call interface is tested and verified through at least one of a unit test and an integration test, and the second remote call interface is output to the business system after the second remote call interface passes the verification.
5. The method according to any one of claims 1 to 4, characterized in that: The step of obtaining the interface information of the current first remote call interface of the business system includes: Sending an interface information acquisition request to a registration center for business system interface information, wherein the interface information acquisition request carries basic information of the business system; The interface information of the first remote call interface is obtained from the registration center.
6. The method according to any one of claims 1 to 4, characterized in that: The determining that the interface switching request meets a preset interface switching condition includes: Determining whether the underlying communication protocol and / or business function of the business system has changed according to the current operation information of the business system; When the underlying communication protocol and / or service function changes, it is determined that the interface switching request meets a preset interface switching condition.
7. The method according to any one of claims 1 to 4, characterized in that: Also includes: After the second remote call interface is generated, the interface data corresponding to the second remote call interface is stored in a persistent data storage device.
8. The method according to any one of claims 1 to 4, characterized in that: The first remote call component is a Dubbo component, and the second remote call component is a Feign component.
9. An interface switching device based on a remote call component, characterized in that: include: A response module, which is configured to respond to an interface switching request for a business system, wherein the interface switching request is generated based on current operation information of the business system and / or triggered by a user; an interface information acquisition module, which is configured to acquire interface information of a current first remote call interface of the business system when it is determined that the interface switching request meets a preset interface switching condition; wherein the communication mechanism of the first remote call interface is implemented based on a first remote call component; An interface generation module, which is configured to generate a second remote call interface based on the communication mechanism implemented by the second remote call component according to the specification of the second remote call component to be switched and the interface information; wherein the second remote call component is a component of a different type from the first remote call component; The interface output module is configured to output the second remote call interface to the business system, so that the business system switches the first remote call interface to the second remote call interface.
10. A server, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the interface switching method based on remote call components as described in any one of claims 1-8.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the interface switching method based on remote call components as described in any one of claims 1 to 8.
12. A computer program product, characterized in that The invention comprises a computer program, which, when executed by a processor, implements the interface switching method based on remote calling component described in any one of claims 1 to 8.
13. An interface switching system based on remote call components, characterized in that: It comprises an integrated system for executing the interface switching method based on remote call components as claimed in any one of claims 1 to 8, a business system and a registration center electrically connected to the integrated system respectively; wherein, The business system runs multiple microservices to execute related businesses, and the multiple microservices communicate with each other through remote call interfaces; The registration center is used to receive and store the interface information of the business system, and send the interface information of the business system to the integration system when the integration system initiates an interface information acquisition request.