Gateway device, control method, electronic device and computer program product
The gateway system designed with a layered architecture solves the flexibility and scalability issues of existing gateway systems in complex business scenarios, achieves efficient resource utilization and dynamic rule updates, and adapts to multi-protocol conversion needs.
Patent Information
- Application Number
- CN202510748337.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-05
- Publication Date
- 2025-09-05
AI Technical Summary
Existing gateway systems lack flexibility and scalability in complex business scenarios, have low resource utilization, are complex to maintain, and have difficulty supporting multi-protocol conversion and dynamic routing rule updates.
It adopts a layered architecture design, including the connection layer, analysis layer, filtering layer, routing distribution layer and data monitoring layer. Each layer has clear responsibilities, supports multi-protocol processing and dynamic rule updates, and realizes hierarchical collaboration and independent maintenance.
It improves the scalability and flexibility of the gateway system, reduces maintenance costs, improves resource utilization, and supports efficient processing in complex business scenarios.
Smart Images

Figure CN120602265A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a gateway device, a control method, an electronic device, and a computer program product. Background Art
[0002] The gateway integrates functions such as request parsing, authentication, access control, routing and forwarding, opens a unified entry point for the same type of requests, routes the requests to the corresponding services, and returns the response results to the requester.
[0003] Currently, Spring Cloud Gateway relies on configuration files to define routing rules and filter logic. KongAPI Gateway adopts a plug-in design and extends its functionality by installing different types of plug-ins.
[0004] However, the Spring Cloud gateway framework is too heavy and lacks flexibility. When the business is complex, the configuration files are lengthy, and independent gateway instances need to be deployed, resulting in resource duplication and complex operation and maintenance. The Kong API gateway plug-in is strongly bound to the gateway core, with high coupling between components and difficulty in plug-in development, which limits the gateway's scalability. Moreover, in complex business scenarios, multiple instances or complex plug-in combinations are required, resulting in resource waste and configuration redundancy. Summary of the Invention
[0005] According to various embodiments of the present application, a gateway device, a control method, an electronic device, and a computer program product are provided; the scalability, flexibility, and resource utilization of the gateway system can be improved.
[0006] In the first aspect, the present application provides a gateway device, including: a connection layer, a parsing layer, a filtering layer, a routing distribution layer and a data monitoring layer; the connection layer is used to receive a business request sent by a client and transmit the business request to the parsing layer; the parsing layer is used to perform multi-protocol parsing on the received business request based on a preset parsing chain, and transmit the request object obtained by the parsing process to the filtering layer; the filtering layer is used to filter the received request object based on a preset filter chain, and transmit the filtered request object to the routing distribution layer; the routing distribution layer is used to perform routing matching on the received request object based on the routing rules, and distribute the request object to the server based on the matching results; the data monitoring layer is used to monitor changes in rule data on the registration center side, and update the routing rules of the routing distribution layer or the verification rules of the filtering layer based on the changed rule data.
[0007] Through the above method, the architecture of the gateway device is divided into connection layer, parsing layer, filtering layer, routing distribution layer and data monitoring layer. The responsibilities of each layer are clearly divided, which reduces the complexity of development; and the business requests of multi-protocol scenarios can be processed collaboratively between the layers. Based on the hierarchical division, each layer is maintained independently, which reduces the scope and complexity of maintenance work and improves maintenance efficiency; dynamic rule updates reduce maintenance costs; decoupling between the layers facilitates system expansion and improves the scalability and flexibility of the system; based on the layered architecture, function reuse can be achieved, system resource consumption can be reduced, and system resource utilization can be improved; it has strong ease of use and practicality.
[0008] In a possible implementation of the first aspect, the connection layer is configured with multiple ports and a connector matching each port; the port is used to communicate with the client and receive business requests of different network protocols sent by the client; the connector is used to package the business requests of different network protocols separately and send the packaged business requests to the parsing layer.
[0009] In a possible implementation of the first aspect, the parsing layer is configured with multiple parsers; each parser is provided with a parser identifier and a first execution order associated with the parser identifier, and the first execution order is used to determine the parsing chain; the parser is used to perform protocol parsing and data conversion on the business request based on the parsing chain, obtain the request object, and transmit the request object to the filtering layer.
[0010] In a possible implementation of the first aspect, the filtering layer is configured with multiple filters; each filter is provided with a filter identifier and a second execution order associated with the filter identifier, and the second execution order is used to determine the filter chain; the filter is used to perform authentication verification and filtering processing on the request object based on the configured filter chain, and to add additional information, and transmit the filtered request object to the routing distribution layer.
[0011] In a possible implementation of the first aspect, the routing distribution layer is configured with a routing distributor; the routing distributor establishes an association relationship with the connector of the connection layer, the resolution chain, and the filter of the filtering layer; the routing distributor is used to perform routing matching on the request object based on the characteristics of the request object, the association relationship, and the load balancing strategy, and distribute the request object to the server based on the matching result.
[0012] In a possible implementation manner of the first aspect, the filter chain is configured with the filter list and the route distributor.
[0013] In a possible implementation of the first aspect, the data listening layer is configured with a data listener; the data listener is communicatively connected to the registration center; the data listener is used to listen to and obtain the rule data updated by the registration center, and trigger the routing distribution layer to update the routing rules and the filtering layer to update the verification rules based on the updated rule data; the data listener is also used to cache the updated rule data to a local storage unit.
[0014] In a possible implementation of the first aspect, the routing distribution layer is further used to receive response information fed back by the server based on the business request, and transmit the response information to the parsing layer; the parsing layer is further used to encode the response information based on the network protocol, and transmit the processed response information to the connection layer; the connection layer is further used to send the response information to the client; wherein, the response information is the result returned by the server based on the business request.
[0015] In a possible implementation of the first aspect, the routing distribution layer is further configured to receive exception information fed back by the server when a business processing exception occurs, convert the exception information into response information, and forward the response information to the parsing layer.
[0016] In a second aspect, the present application provides a method for controlling a gateway device, wherein the gateway device includes a connection layer, a parsing layer, a filtering layer, a routing distribution layer, and a data monitoring layer; the control method includes:
[0017] The connection layer receives the business request sent by the client and transmits the business request to the parsing layer; the parsing layer performs multi-protocol parsing on the received business request based on a preset parsing chain, and transmits the request object obtained by the parsing to the filtering layer; the filtering layer filters the received request object based on a preset filter chain, and transmits the filtered request object to the routing distribution layer; the routing distribution layer performs routing matching on the received request object based on routing rules, and distributes the request object to the server based on the matching result; the data monitoring layer monitors changes in the rule data of the registration center, and updates the routing rules of the routing distribution layer or the verification rules of the filtering layer based on the changed rule data.
[0018] In a third aspect, the present application provides an electronic device, comprising the gateway device described in the first aspect.
[0019] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the method in the second aspect when executed by a processor.
[0020] In a fifth aspect, the present application provides a computer program product, which, when executed on a device, enables the device to execute the method in the second aspect.
[0021] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0023] Figure 1 A schematic diagram of the architecture of a gateway device provided in an embodiment of the present application;
[0024] Figure 2 A schematic diagram of the configuration of each layer of the gateway device provided in an embodiment of the present application;
[0025] Figure 3 A schematic diagram of the data processing flow at each layer provided in an embodiment of the present application;
[0026] Figure 4 A schematic diagram of route matching and distribution provided in an embodiment of the present application;
[0027] Figure 5 A schematic diagram of the rule update process provided in an embodiment of the present application;
[0028] Figure 6 A schematic diagram of feedback response information provided in an embodiment of the present application;
[0029] Figure 7 A schematic diagram of the implementation flow of the control method for the gateway device provided in an embodiment of the present application;
[0030] Figure 8 A schematic diagram of the structure of the gateway device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0031] The following embodiments of the technical solution of the present application will be described in detail with reference to the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present application and are therefore only examples and are not intended to limit the scope of protection of the present application.
[0032] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which this application belongs; the terms used herein are only for the purpose of describing specific embodiments and are not intended to limit this application; the terms "including" and "having" and any variations thereof in the specification and claims of this application and the above-mentioned figure descriptions are intended to cover non-exclusive inclusions.
[0033] In the description of the embodiments of this application, the technical terms "first" and "second" are used only to distinguish different objects and should not be understood to indicate or imply relative importance or implicitly specify the quantity, specific order, or primary and secondary relationship of the indicated technical features. In the description of the embodiments of this application, the meaning of "plurality" is more than two, unless otherwise clearly and specifically defined.
[0034] References herein to "embodiments" mean that a particular feature, structure, or characteristic described in connection with the embodiments may be included in at least one embodiment of the present application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it constitute an independent or alternative embodiment that is mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0035] In the description of the embodiments of this application, the term "and / or" is simply a description of the association relationship between associated objects, indicating that three relationships can exist. For example, A and / or B can represent the following three situations: A exists alone, A and B exist simultaneously, and B exists alone. In addition, the character " / " in this document generally indicates that the associated objects are in an "or" relationship.
[0036] Traditional gateways rely on configuration files to define routing rules and filter logic, or use plug-in designs to expand their functionality. When business becomes complex, configuration files become lengthy and difficult to maintain. Routing rules cannot be modified dynamically based on configuration files, and support for underlying network connections and conversion between different protocols is difficult. The gateway architecture is rigid and overly complex, making it difficult to meet the needs of complex business scenarios and lacking flexibility. Plug-in-based designs are difficult to develop, limiting the gateway's scalability and increasing maintenance costs. Complex business scenarios require multiple instances or complex plug-in combinations, which can lead to resource waste and configuration redundancy.
[0037] In response to the above technical problems, an embodiment of the present application provides a gateway device, which may include a connection layer, a parsing layer, a filtering layer, a routing distribution layer, and a data monitoring layer; each layer has a clear function, and the layers can interact through interfaces to adapt to the needs of different business scenarios; based on a modular design of a layered architecture, the independence of the functions of each layer is achieved, and the scalability and flexibility of the system are improved; based on the layered architecture, resource reuse and sharing can be achieved, thereby improving system resource utilization.
[0038] The specific architecture of the gateway device is introduced below through embodiments.
[0039] See Figure 1 , Figure 1 This is a schematic diagram of the gateway structure provided in the embodiment of this application. Figure 1 As shown, the gateway device includes a connection layer, a parsing layer, a filtering layer, a routing distribution layer, and a data monitoring layer.
[0040] In some embodiments, the connection layer is used to receive business requests sent by the client and transmit the business requests to the parsing layer. As the entrance to the business request, the connection layer is a bridge for data interaction between the client and the server, and is responsible for establishing and maintaining the network connection with the client. The connection layer establishes a communication connection with the client by providing ports for multiple network protocols, so that it can receive business requests issued by the client based on different network protocols. Among them, the ports for multiple network protocols may include ports for protocols such as Hypertext Transfer Protocol (HTTP), Hypertext Transfer Protocol Secure (HTTPS), Google Remote Procedure Call (GRPC) or WebSocket.
[0041] For example, Figure 2 As shown, the connection layer is configured with multiple connectors (such as connector 1, connector 2 and connector 3); each connector is bound to a port, such as port 1 bound to connector 1, port 2 bound to connector 2, and port 3 bound to connector 3, and each port can provide an Internet Protocol (IP) address.
[0042] like Figure 3As shown in the figure, the connection layer listens for client service requests through ports and establishes a data transmission channel with the client based on the transport layer protocol. It receives service requests from clients using different network protocols. The connector packages the service requests from different network protocols separately and sends the packaged service requests to the parsing layer. The transport layer protocols may include the Transmission Control Protocol (TCP), the User Datagram Protocol (UDP), or the HTTP protocol.
[0043] Exemplarily, the connection layer is configured with asynchronous input / output I / O ports. For high concurrency scenarios, after the business thread submits an I / O request, it can immediately release resources and execute other requests, achieving non-blocking execution through collaboration (such as callbacks, event loops, coroutines, etc.); and the connection layer is also configured with non-blocking I / O ports, and the business thread polls to check the status of the I / O port to avoid blocking.
[0044] Accordingly, if Figure 3 As shown in the figure, after receiving a service request, the connection layer converts the original byte stream of the service request into a unified structured data that can be processed by the parsing layer, and transmits the service request to the parsing layer through synchronous or asynchronous transmission. Service requests of different protocol types (such as TCP / UDP / HTTP) are encapsulated and forwarded to the parsing layer. For example, for service requests of the HTTP protocol, the connector converts the service request into a structured object by adding a protocol header tag, encapsulating the request method, path, protocol version, etc.
[0045] In some embodiments, the parsing layer performs multi-protocol parsing on received service requests based on a pre-defined parsing chain and transmits the resulting parsed request objects to the filtering layer. The parsing layer is responsible for converting the service request data stream sent by the connection layer, such as by decoding, decompressing, and aggregating the service data.
[0046] For example, Figure 2 As shown, the parsing layer is configured with multiple parsers. Each parser is provided with a parser identifier and a first execution order associated with the parser identifier. The first execution order is used to determine the parsing chain. Based on the first execution order corresponding to the parsing chain, the parser performs protocol parsing and data conversion on the service request, obtains the request object, and transmits the request object to the filtering layer.
[0047] Exemplarily, a parsing chain is a data processing chain consisting of multiple parsers, each responsible for specific operations such as decoding, decompression, and data conversion. Parsers can include common parsers (such as loggers and decompressors), encoders, decoders, and request processing dispatchers. Each parser is assigned a corresponding identifier or name. The order in which parsers perform data processing in the parsing chain is defined based on the parser name, with the output of the previous parser serving as the input for the next parser.
[0048] Accordingly, each resolver in the resolution layer can be set up as an independent module. During the resolution chain configuration process, the resolution chain composed of resolvers can be dynamically configured based on the needs of the actual application scenario. That is, the resolvers can be configured to different execution orders. For example, according to the type of business request, corresponding resolution chains can be set up for different types of business requests. By calling the resolvers of different resolution chains, different business requests can be processed. In addition, for different types of business requests, the gateway device can also initialize the resolution chain based on the order of the resolvers to build a process for processing business requests.
[0049] Exemplarily, the resolution chain may further include a request chain and a response chain, wherein the request chain and the response chain respectively include different resolvers and correspond to different execution orders.
[0050] For example, the last parser in the parsing chain is the request processing dispatcher. When defining the parsers in the parsing chain, for the parsers in the parsing chain other than the request processing dispatcher, define their corresponding parser names and parser orders; Figure 3 As shown, the business request is decoded, decompressed, aggregated, etc. by other parsers to convert the business request into a request object, and the request processing distributor transmits the request object to the filtering layer; wherein, in the process of transmitting the request object from the request processing distributor to the filtering layer for filtering, the data type of the request object is no longer converted.
[0051] For example, the parsing layer decodes and converts service requests into request objects supported by the filtering and routing layers. Decoding refers to converting the raw data of service requests received by the connection layer into a format understandable by the processor, while encoding refers to encoding the response data according to the protocol content. The response data is the data returned by the server after service processing.
[0052] like Figure 2As shown, the parser configured in the parsing layer supports processing business requests of TCP or UDP protocols, and supports extensions of multiple protocols; for example, parser 1 supports the underlying standard transport layer protocol (such as TCP or UDP) to handle operations such as connection establishment and data packet transmission; above the transport layer, parser 1 can also process application layer data of custom or enhanced protocols, such as high-level protocols based on TCP / UDP encapsulation (transport custom data protocol (TCDP)), to achieve extension of the basic protocol, and enhancement or customization of the transport layer by the application layer.
[0053] Exemplarily, parser 1 first processes the transport layer protocol and parses the transport layer protocol header in the service request to obtain application layer data. For example, the TCP parser parses the TCP header of the data packet to obtain application layer data; the application layer data is passed to the upper layer protocol parser (such as TCDP parser) for further parsing to obtain a request object in a standardized internal format that can be supported by the filtering layer and the routing distribution layer.
[0054] Accordingly, if Figure 2 As shown, parser 2 of the parsing layer also supports parsing of TPDS protocol data that relies on TCP or UDP protocol, and parser 3 also supports parsing of TCSP protocol data that relies on HTTPS protocol.
[0055] By configuring different parsers, the parsing layer not only supports the common HTTP protocol, but also can flexibly expand support for multiple protocols such as TCP and UDP. It can also perform necessary conversion processing on business requests before requesting the dispatcher, meeting the needs of interaction between different protocols. The parsing layer performs layered parsing processing on the protocol, which can efficiently utilize standard transport layer protocols (such as TCP protocol and UDP protocol), and can also support business logic processing of the application layer (TDCP), flexibly supporting multiple protocol extensions and customized needs in vertical fields.
[0056] In some embodiments, as Figure 3 As shown, the filtering layer filters the received request object based on the preset filter chain, and transmits the filtered request object to the routing distribution layer.
[0057] Exemplarily, the filtering layer is configured with multiple filters; each filter is provided with a filter identifier and a second execution order associated with the filter identifier, and the second execution order is used to determine the filter chain; the filter performs authentication verification on the request object based on the configured filter chain and adds filtering processing of additional information, and transmits the filtered request object to the routing distribution layer.
[0058] Exemplarily, before processing the request object, the gateway device performs authentication verification on the request object, such as certificate verification, session verification, and permission verification, and adds additional information to the request body of the request object, such as user information or timeout information. By adding filters to flexibly filter the request object, users can configure various filters based on actual application needs, and form a corresponding filter chain through flexible combination of various filters. Before the data reaches the processor, filtering verification is performed based on business needs to implement complex business logic, and enable the gateway device to have comprehensive management and control from basic security to business logic.
[0059] like Figure 2 As shown, the filtering layer is configured with multiple filters, such as filter 1, filter 2, and filter 3; each filter is set to a different verification function. For example, filter 1 is set to token-based authentication, i.e., token verification, filter 2 is set to device verification (verifying the legitimacy of the device from which the business request originated), and filter 3 is set to permission verification (verifying the identity and permissions of the user or device corresponding to the business request). Based on the actual application scenario requirements, the filtering layer can also be configured with filters with other functions and set to other filtering functions, such as parameter verification, rate limiting, sensitive data filtering, etc.
[0060] Exemplarily, the filter chain is a processing flow chain based on the execution order of each filter configured in the filter layer. For example, the request object is first token-checked, and then device verification, rate limiting, permission verification, and parameter verification are performed in sequence. Finally, sensitive data is filtered and the filtered request object is output.
[0061] Among them, users can also flexibly configure the filters of the filtering layer and the execution order of the filter chain based on the needs of actual application scenarios. The various filters of the filtering layer can be defined and set in a modular way, and filters suitable for complex business scenarios can be added and expanded based on modular writing.
[0062] The filtering layer configured in the gateway device provided in the embodiment of the present application allows developers to freely add various filters according to business needs to intercept and process requests, such as authentication verification, adding additional information, etc., and the execution order of the filters can be flexibly configured to support the implementation of complex business logic.
[0063] In some embodiments, as Figure 3 As shown, the routing distribution layer performs routing matching on the received request objects based on the routing rules, and distributes the request objects to the server based on the matching results.
[0064] Exemplarily, the routing distribution layer is configured with a routing distributor; the routing distributor establishes an association relationship with the connector of the connection layer, the resolution chain and the filter of the filtering layer; the routing distributor performs routing matching on the request object based on the characteristics, association relationship and load balancing strategy of the request object, and distributes the request object to the server based on the matching result.
[0065] Exemplarily, the routing distribution layer performs routing matching on business requests, forwards the business requests to the server, obtains the server's response information or exception information, and returns the response information or the corresponding response information to the resolution layer. The routing distributor binds the connector name to the connector, the resolution chain, and the filter chain to implement a complete end-to-end processing flow for business requests, ensuring that the entire chain from access to forwarding is controllable, scalable, and efficient.
[0066] For example, a connector is responsible for receiving service requests for a specific protocol (such as HTTP / HTTPS, TCP / UDP, etc.). By binding to the connector, the route distributor can determine the protocol type of the current service request and correctly match the corresponding routing rules. The parsing chain is responsible for converting the service request into structured data (such as an HTTP request object). After the filter chain completes the verification of the request object, the route distributor performs path or port matching on the request object to implement route distribution.
[0067] In actual applications, the gateway device can also encapsulate the filter list and the route distributor into the filter chain. Each filter in the filter list acts as a pre-filter to perform verification operations, and after the verification passes, the route distributor routes and forwards it to the server.
[0068] For example, the routing distribution layer is provided with routing rules, which include rules for different servers, such as Figure 4 The server A corresponding to routing rule 1, the server B corresponding to routing rule 2, and the server C corresponding to routing rule 3 are shown; different servers correspond to different types of processors.
[0069] Exemplarily, routing rules may include information such as Uniform Resource Locator (URL) pattern, protocol type, request method, target service, and load balancing strategy. The specific content of this information forms routing rules corresponding to different business types and servers; the routing distributor performs routing matching on the characteristics of the request object forwarded by the filtering layer based on the routing rules, and after determining the routing rule that matches the request object, distributes it to the server according to the target server and load balancing strategy in the routing rules.
[0070] Accordingly, the characteristics of the request object may include information such as request type, request header information, request body content, query parameters, source address, and protocol version; among them, the request type may include HTTP request, RPC request, and message queue request, etc.; the routing distributor may match the characteristics of the request object with the routing rules to determine the corresponding server; the type of the server may include HTTP processor, RPC processor, and queue processor, etc.
[0071] For example, the routing rules in the routing distributor also include load balancing strategies, and the types of load balancing strategies may include round-robin, random, and least number of connections. Based on the load balancing strategies corresponding to the matching routing rules, the routing distributor rationally distributes request objects to different backend service processors, achieving accurate matching of service requests and diversified load balancing, thereby optimizing the allocation and utilization of network resources.
[0072] In some embodiments, the data monitoring layer monitors changes in rule data at the registration center, updates routing rules at the routing distribution layer or verification rules at the filtering layer based on the changed rule data, and caches the updated rule data in a local storage unit.
[0073] like Figure 2 As shown, the data monitoring layer is also configured with data monitors, such as data monitor 1 and data monitor 2. Figure 3 As shown, data listener 1 monitors the update of routing rules on the registration center side, and after the routing rules are changed, updates the routing rules of the routing distributor based on the changed routing rules; data listener 2 monitors the update of verification rules on the registration center side, and after the verification rules are changed, updates the verification rules of the filtering layer based on the changed verification rules.
[0074] like Figure 5 As shown, the business service can update the routing rules (i.e., routing rules) and verification rules (verification rules of the filtering layer) to the registration center. The data monitoring layer can monitor the changes in the rule data of the registration center, such as regular polling, sending request information to the registration center, obtaining the version information of the rule data, and requesting the new version of the rule data if the version information is inconsistent with that stored in the data monitoring layer (such as the version of the registration center is higher than the version stored in the data monitoring layer); or, after obtaining the updated rule data, the registration center sends a notification to the data monitoring layer to notify the data monitoring layer of the information change; after obtaining the updated rule data, the data monitoring layer sends the updated routing rules to the routing distribution layer to update the routing rules of the routing distribution layer, and sends the verification rules to the filtering layer to update the verification rules of the filtering layer.
[0075] The data monitoring layer monitors changes in the rule data of the registration center in real time and automatically updates the locally cached routing rules, verification rules and other configuration information without restarting the gateway service. This enables dynamic modification and real-time effectiveness of the configuration, ensuring the dynamic and real-time nature of the gateway configuration.
[0076] In some embodiments, the routing distribution layer receives response information from the server based on the business request feedback, and forwards the response information to the parsing layer; the parsing layer encodes the response information based on the network protocol, and transmits the processed response information to the connection layer; the connection layer sends the response information to the client; wherein the response information is the result returned by the server based on the business request.
[0077] For example, Figure 6 As shown in the figure, the server returns the response information to the routing distribution layer, and the routing distribution layer transmits the response information to the parsing layer according to the preset routing rules (such as load balancing and business type); the parsing layer encodes and compresses the response information, encodes the response information according to the network protocol (such as HTTP, TCP, etc.), and transmits the encoded response information to the connection layer; the connection layer sends the processed response information to the client through the underlying network protocol (such as TCP, UDP).
[0078] In some embodiments, when business processing is abnormal, the routing distribution layer receives the abnormal information fed back by the server, converts the abnormal information into a corresponding error response and forwards it to the parsing layer, which encodes and compresses it and sends it to the connection layer, which then sends it to the client.
[0079] Corresponding to the architecture of the above-mentioned gateway device, the embodiment of the present application provides a control method for a gateway device, which is based on the same implementation principle as the above-mentioned embodiment and will not be described in detail here. Figure 7 As shown, the method may include the following steps:
[0080] S701: The connection layer receives a service request sent by a client and transmits the service request to the parsing layer.
[0081] S702: The parsing layer performs multi-protocol parsing on the received service request based on a preset parsing chain, and transmits the parsed request object to the filtering layer.
[0082] S703: The filtering layer filters the received request object based on a preset filter chain, and transmits the filtered request object to the routing distribution layer.
[0083] S704: The routing distribution layer performs routing matching on the received request object based on the routing rules, and distributes the request object to the server based on the matching result.
[0084] S705: The data monitoring layer monitors the change of the rule data of the registration center, and updates the routing rules of the routing distribution layer or the verification rules of the filtering layer based on the changed rule data.
[0085] In the embodiment of the present application, the architecture of the gateway device is divided into a connection layer, a parsing layer, a filtering layer, a routing distribution layer, and a data monitoring layer. Each layer has clear responsibilities and cooperates with each other, thereby improving the scalability, flexibility, and resource utilization of the system.
[0086] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0087] Figure 8 A schematic diagram of the hardware structure of the gateway device 80 is shown.
[0088] like Figure 8 As shown, the gateway device 80 of this embodiment includes: at least one processor 801 ( Figure 8 Only one is shown), a memory 802, wherein the memory 802 stores a computer program 803 that can be run on the processor 801. When the processor 801 executes the computer program 803, the steps in the above method embodiment are implemented, for example Figure 7 Alternatively, when the processor 801 executes the computer program 803, the functions of the modules / units in the above-mentioned device embodiments are realized.
[0089] It should be understood that the structure illustrated in the embodiments of the present application does not constitute a specific limitation on the gateway device 80. In other embodiments of the present application, the gateway device 80 may include more or fewer components than shown, or may combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0090] The gateway device 80 may include, but is not limited to, a processor 801 and a memory 802. Those skilled in the art will appreciate that Figure 8 This is merely an example of the gateway device 80 and does not constitute a limitation of the gateway device 80 . The gateway device 80 may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the server may also include an input sending device, a network access device, a bus, etc.
[0091] The processor 801 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.
[0092] Processor 801 may also include a memory for storing instructions and data. In some embodiments, the memory in processor 801 is a cache memory. This memory can store instructions or data that have just been used or are being recycled by processor 801. If processor 801 needs to use the same instruction or data again, it can directly access the memory. This avoids duplicate accesses, reduces the waiting time of processor 801, and thus improves system efficiency.
[0093] In some embodiments, the memory 802 may be an internal storage unit of the gateway device 80, such as a hard disk or memory of the gateway device 80. The memory 802 may also be an external storage device of the gateway device 80, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the gateway device 80. Furthermore, the memory 802 may also include both an internal storage unit of the gateway device 80 and an external storage device. The memory 802 is used to store an operating system, an application program, a boot loader (BootLoader), data, and other programs, such as program code of a computer program. The memory 802 may also be used to temporarily store data that has been sent or is to be sent.
[0094] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0095] It should be noted that the structure of the above-mentioned gateway device is only an example. Based on different application scenarios, it may also include other physical structures. The physical structure of the gateway device is not limited here.
[0096] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant description of other embodiments.
[0097] The present application provides an electronic device, including the aforementioned gateway device.
[0098] An embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it can implement the steps in the above-mentioned various method embodiments.
[0099] An embodiment of the present application provides a computer program product. When the computer program product runs on a server, the server can implement the steps in the above-mentioned method embodiments when executing the computer program product.
[0100] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the process in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form, etc. Computer-readable media may include: any entity or device that can carry computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc.
[0101] The gateway device, computer storage medium, and computer program product provided in the above-mentioned embodiments of the present application are all used to execute the methods provided above. Therefore, the beneficial effects that can be achieved can refer to the corresponding beneficial effects of the methods provided above, and will not be repeated here.
[0102] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0103] It should be understood that the above is only to help those skilled in the art better understand the embodiments of the present application, and is not intended to limit the scope of the embodiments of the present application. Based on the above examples given, those skilled in the art can obviously make various equivalent modifications or changes. For example, certain steps in each embodiment of the above detection method may be unnecessary, or certain new steps may be added. Or a combination of any two or any multiple embodiments described above. Such modifications, changes, or combined solutions also fall within the scope of the embodiments of the present application.
[0104] It should also be understood that the division of the modes, situations, categories and embodiments in the embodiments of the present application is only for the convenience of description and should not constitute a special limitation. The features of various modes, categories, situations and embodiments can be combined without contradiction.
[0105] It should also be understood that in the various embodiments of the present application, unless otherwise specified or there is a logical conflict, the terms and / or descriptions between different embodiments are consistent and can be referenced to each other, and the technical features in different embodiments can be combined to form new embodiments according to their internal logical relationships.
[0106] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0107] In the embodiments provided in this application, it should be understood that the disclosed devices / network equipment and methods can be implemented in other ways. For example, the device / network equipment embodiments described above are merely illustrative. For example, the division of the modules or units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components 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 through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0108] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0109] The above-described embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. 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 make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present application, and should all be included in the scope of protection of the present application.
[0110] Finally, it should be noted that the above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.
Claims
1. A gateway device, characterized in that: The gateway device includes: a connection layer, a parsing layer, a filtering layer, a routing distribution layer and a data monitoring layer; The connection layer is used to receive a service request sent by a client and transmit the service request to the parsing layer; The parsing layer is configured to perform multi-protocol parsing on the received service request based on a preset parsing chain, and transmit the request object obtained by the parsing process to the filtering layer; The filtering layer is configured to filter the received request object based on a preset filter chain, and transmit the filtered request object to the routing distribution layer; The routing distribution layer is used to perform routing matching on the received request object based on routing rules, and distribute the request object to the server based on the matching result; The data monitoring layer is used to monitor changes in the rule data of the registration center, and update the routing rules of the routing distribution layer or the verification rules of the filtering layer based on the changed rule data.
2. The gateway device according to claim 1, wherein: The connection layer is configured with a plurality of ports and a connector matching each port; The port is used to communicate with the client and receive service requests of different network protocols sent by the client; The connector is used to package the service requests of different network protocols respectively and send the packaged service requests to the parsing layer.
3. The gateway device according to claim 1, wherein: The parsing layer is configured with a plurality of parsers; each of the parsers is provided with a parser identifier and a first execution order associated with the parser identifier, the first execution order being used to determine the parsing chain; The parser is used to perform protocol parsing and data conversion on the service request based on the parsing chain, obtain the request object, and transmit the request object to the filtering layer.
4. The gateway device according to claim 1, wherein: The filter layer is configured with a plurality of filters; each filter is provided with a filter identifier and a second execution order associated with the filter identifier, the second execution order being used to determine the filter chain; The filter is used to perform authentication verification on the request object based on the configured filter chain and filter processing to add additional information, and transmit the request object after filtering to the routing distribution layer.
5. The gateway device according to claim 1, wherein: The routing distribution layer is configured with a routing distributor; the routing distributor establishes an association relationship with the connector of the connection layer, the resolution chain and the filter of the filtering layer; The routing distributor is used to perform routing matching on the request object based on the characteristics of the request object, the association relationship and the load balancing strategy, and distribute the request object to the server based on the matching result.
6. The gateway device according to claim 5, characterized in that The filter chain is configured with the list of filters and the route dispatcher.
7. The gateway device according to claim 1, characterized in that The data monitoring layer is configured with a data monitor; the data monitor is in communication connection with the registration center end; The data listener is used to listen to and obtain the rule data updated by the registration center, and trigger the routing distribution layer to update the routing rules and the filtering layer to update the verification rules based on the updated rule data; The data listener is further configured to cache the updated rule data in a local storage unit.
8. The gateway device according to any one of claims 1 to 7, characterized in that: The routing distribution layer is further configured to receive response information fed back by the server based on the service request, and forward the response information to the resolution layer; The parsing layer is further configured to encode the response information based on a network protocol and transmit the processed response information to the connection layer; The connection layer is further configured to send the response information to the client; The response information is the result returned by the server based on the service request.
9. The gateway device according to claim 8, characterized in that The routing distribution layer is further configured to receive abnormal information fed back by the server when a business process is abnormal, convert the abnormal information into response information, and forward the response information to the parsing layer.
10. A method for controlling a gateway device, characterized in that: The gateway device includes a connection layer, a parsing layer, a filtering layer, a routing distribution layer, and a data monitoring layer; the control method includes: The connection layer receives the service request sent by the client and transmits the service request to the parsing layer; The parsing layer performs multi-protocol parsing on the received service request based on a preset parsing chain, and transmits the request object obtained by the parsing process to the filtering layer; The filtering layer filters the received request object based on a preset filter chain, and transmits the filtered request object to the routing distribution layer; The routing distribution layer performs routing matching on the received request object based on routing rules, and distributes the request object to the server based on the matching result; The data monitoring layer monitors changes in the rule data of the registration center, and updates the routing rules of the routing distribution layer or the verification rules of the filtering layer based on the changed rule data.
11. An electronic device, characterized in that: The gateway device comprises the gateway device according to any one of claims 1 to 9.
12. A computer program product, characterized in that When the computer program product is run on a device, the device is caused to execute the method according to claim 10 .