Interface calling system based on reverse proxy

A technology of interface calling and reverse proxy, applied in the field of interface calling, can solve problems such as repeated development, interface version confusion, interface performance bottlenecks, etc., and achieve the effect of avoiding breakpoint interference

Pending Publication Date: 2021-07-13
CHENGDU JIUZHOU ELECTRONIC INFORMATION SYSTEM CO LTD
9 Cites 0 Cited by

AI-Extracted Technical Summary

Problems solved by technology

[0002] Due to the complexity of the business, the construction of large-scale software systems often needs to rely on multiple iterations, which can easily lead to various problems such as inter...
View more

Method used

[0032] Utilize the TCP communication mode to separate the gateway and the execution node, allowing multiple nodes to process the same function, thereby...
View more

Abstract

The invention discloses an interface calling system based on reverse proxy, which is applied to the field of computers. Aiming at the problem that the existing interface calling technology cannot adapt to a large-scale software system, the system is designed to be composed of a gateway and execution nodes; the gateway is based on a reverse proxy mode, wherein distributed architecture is realized by requesting a gateway to reversely call nodes, and load balancing is formed, so that the execution pressure is dispersed; then transparent transmission is carried out through JSON when an interface is called, version information is attached to the interface, the same interface allows multiple versions, and the version exchange function in iterative development is achieved; the interface design comprises a development group concept, a plurality of calling parties are allowed to be classified into one group, data and scheduling among the groups do not interfere with each other, and the problem of interruption point interference during multi-person collaborative development is avoided; besides, due to the fact that the restful is adopted as a transmission protocol, an interface is irrelevant to languages, and cross-language collaborative development can be achieved.

Application Domain

Network connections

Technology Topic

JSONInterface design +9

Image

  • Interface calling system based on reverse proxy
  • Interface calling system based on reverse proxy
  • Interface calling system based on reverse proxy

Examples

  • Experimental program(1)

Example Embodiment

[0031] In order to facilitate those skilled in the art to understand the technical content of the present invention, the content of the present invention will be further explained below in conjunction with the accompanying drawings.
[0032] Using the TCP communication method, the gateway and the execution node are separated, allowing multiple nodes to process the same function, thereby reducing the pressure on the server, regardless of the development language, and realizing the iterative mixed development requirements of the system.
[0033] In the design, the gateway service serves as a unified entrance and exit, dispatching client application requests to the back-end execution nodes for processing according to certain rules, and responding to the client with data after receiving the processing results, thus forming a reverse proxy mechanism . At this time, the source of the request (the requesting client) is clear, but it is not clear which server the request is processed by. The client is not aware of the existence of the proxy, and the reverse proxy is transparent to the outside world, and the visitor does not I don't know that I am visiting a proxy. Because the client can access without any configuration.
[0034] like figure 1 As shown, the system of the present invention includes: a gateway service and an execution node, data transmission is performed through TCP, and the gateway service provides calling functions in the form of RESTFUL.
[0035] like figure 2 As shown, the gateway service design is composed of API registration service, API buffer pool, and API caller. SpringBoot is used as the underlying container to provide a unified RESTFUL call interface.
[0036] The gateway service listens to the registration port after startup, and the execution node registers the provided functions with the gateway in TCP mode after startup to form an API list; other applications request the registered API functions through the RESTFUL interface.
[0037] SpringBoot framework: The gateway service provides a RESTFUL unified request interface, so SpringBoot is used as the underlying container, and the standard POST request function is used as the only transparent interface. Its prototype is:
[0038] @ResponseBody
[0039] @RequestMapping(path="/getResult", method=RequestMethod.POST)
[0040] public ResultModel getResult(
[0041] @RequestBody Argument invokeArgs,
[0042] HttpServletRequest request)
[0043] Among them, invokeArgs is used as a request input parameter, and its data type is JSON, including the requested IP address, function name, function version number, and parameters received by the function or other parameter information. Its definition is as follows:
[0044]
[0045]
[0046] The return value (response) data model includes: the requested function name, the version number of the function, the function access return code, and the function response return value. In order to better adapt to various parameter transfers, the return value type is wrapped in Object, and its data type Rely on datatype for definition, including: String, int, double, bool, JsonArray, JsonObject, etc., which are defined as follows
[0047]
[0048] API registration service: monitor the function registration port in TCPServer mode, receive the function registration from the execution node, and save the execution node information and the called function to the API buffer pool.
[0049] API cache pool: In order to quickly find calling functions and nodes, all registered functions are saved to the cache pool. In order to ensure the collaborative development of multiple users and the accuracy of breakpoint debugging, a development group is introduced into the design. When the execution node registers the API, it also submits the development group information to which it belongs, forms a development list on the API registration service, and forms an API cache pool. The function prototype of the development group is as follows:
[0050]
[0051] Interface functions are registered in the development group of the API cache pool, such as image 3 As shown, the development team defines the function mapping relationship and node mapping relationship in the form of HashMap. Among them, the function mapping relationship is determined by the IP port ( image 3 IP:PORT in ) as key, function list ( image 3 Func1, Func2, ..., Funcn) in the value to form a correspondence; the node mapping is based on the function name ( image 3 Func in ) is the key, call node ( image 3 Node1, Node2, ..., Noden in ) form correspondences for values.
[0052]API caller: When performing function search, obtain the corresponding development group from the group parameter of the requested Url address, obtain the API list of the development group, and then obtain the execution node list in the function mapping relationship through the method parameter, and pass the configured The load balancing algorithm obtains the corresponding nodes, executes function calculations, and returns data. The logic process is as follows Figure 4 shown.
[0053] The execution node is composed of API collector, node service and executor.
[0054] API Collector: A set of function annotations is defined on the execution node to mark function information. When developers write interface functions, they need to annotate classes and interface functions through annotations. The annotation process is similar to that of SpringBoot interface functions.
[0055]
[0056]
[0057] When the execution node starts, the API collector traverses and reflects the loaded classes, obtains class instances through annotations, extracts function annotation information, and forms a function list to register with the gateway service. The function list exists in the form of JSON, including the full name, description, parameters, return value and other information of the function.
[0058] Node service: In the execution node, it listens to the called port as a TCPServer, and connects to the gateway service as a TcpClient to register the API function.
[0059] Executor: When the node service receives a request from the gateway service, it calls the executor to execute the specified function logic. The executor analyzes the received function description, performs function reflection according to the complete path name, forms a function instance, calls the local function in a reflection manner, and transmits the return value to the gateway service.
[0060]
[0061] Working principle of the present invention is:
[0062] like Figure 5 As shown, the overall working process of the system operation is divided into the registration phase and the calling phase. The registration phase is mainly the startup and initialization of each service, and the execution node registers the local function with the gateway service; the call phase is to receive the request through the gateway service, dispatch it to the execution node, realize the function operation and respond to the caller process.
[0063] The system is initially started, and the gateway service monitors the gateway port, waiting for node registration and interface calls.
[0064] When the execution node is started, it first monitors the adjusted port according to the configuration, and then forms an API list by collecting local API interface functions, and registers the node information with the gateway service. The node information includes: node IP, adjusted port number, API function list; gateway After receiving the registration information, the service caches the "interface function-execution node list" of the API list in the form of key-value pairs, forming a mapping relationship between interface functions and multiple execution nodes.
[0065] When the application calls the API, such as Image 6 As shown, the call function will be requested to the gateway service, and the gateway service will filter according to the list of execution nodes corresponding to the call function, and determine and select the execution node through the load balancing algorithm (mainly including: round robin, random, task optimal), and the gateway service Actively connect to the adjusted port of the execution node through TCP, and pass the call information as a parameter to the execution node. The execution node forms a class instance in the form of reflection by calling the full interface path (package name + class name + function name) in the information, executes the function, and outputs the execution result to the gateway service through TCP. After the gateway service receives the data, it forms a response stream in the form of a restful interface and outputs the data to the calling program, and finally the calling program displays the result through the interface.
[0066] Those skilled in the art will appreciate that the embodiments described here are to help readers understand the principles of the present invention, and it should be understood that the protection scope of the present invention is not limited to such specific statements and embodiments. Various modifications and variations of the present invention will occur to those skilled in the art. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention shall be included within the scope of the claims of the present invention.

PUM

no PUM

Description & Claims & Application Information

We can also present the details of the Description, Claims and Application information to help users get a comprehensive understanding of the technical details of the patent, such as background art, summary of invention, brief description of drawings, description of embodiments, and other original content. On the other hand, users can also determine the specific scope of protection of the technology through the list of claims; as well as understand the changes in the life cycle of the technology with the presentation of the patent timeline. Login to view more.
Who we serve
  • R&D Engineer
  • R&D Manager
  • IP Professional
Why Eureka
  • Industry Leading Data Capabilities
  • Powerful AI technology
  • Patent DNA Extraction
Social media
Try Eureka
PatSnap group products