Message forwarding method and device, computer equipment and storage medium
By implementing the message forwarding method in the data plane of the microservice architecture, selecting the target route based on the target environment domain name and description information and forwarding API requests, the resource waste and configuration complexity caused by independent environment deployment in the microservice architecture is solved, and resource conservation and system stability are achieved.
Patent Information
- Application Number
- CN202510384681.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-28
- Publication Date
- 2025-06-17
AI Technical Summary
In a microservice architecture, deploying independent gateway instances for different environments results in waste of resources and high configuration repetition, increasing workload and potentially leading to system instability.
By implementing the message forwarding method in the data plane of the microservice architecture, receiving the client's API request, selecting the target route from the candidate route based on the target environment domain name and description information, and forwarding the request to the bound candidate environment server.
This solution reduces the resource overhead of deploying gateway instances independently for each environment, reduces hardware and operation and maintenance costs, and reduces the workload of multi-environment maintenance, ensuring independence and system stability of different environments.
Smart Images

Figure CN120166089A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of software development, and particularly to a message forwarding method, apparatus, computer device, and storage medium. Background Art
[0002] With the wide application of microservice architecture and cloud native technology, the application gateway, as an important component connecting the client and the backend service, undertakes key functions such as traffic management, load balancing, authentication, etc. To ensure the service quality at different stages, enterprises usually deploy independent gateway instances for different environments such as development, testing, and production to ensure that the configurations, plugins, and traffic processing of each environment do not interfere with each other.
[0003] However, deploying independent gateway instances for different environments respectively brings significant resource waste, and the gateway instances in different environments often need to be configured with routing, plugins, security policies, etc. separately. This duplication of configuration greatly increases the workload and is very likely to cause configuration inconsistencies between environments due to human errors, thus bringing potential risks of system instability. Summary of the Invention
[0004] Based on this, it is necessary to provide a message forwarding method, apparatus, computer device, and storage medium for the above technical problems.
[0005] In a first aspect, this application provides a message forwarding method, which is applied to the data plane of a microservice architecture and includes:
[0006] Receiving an application programming interface (API) request sent by a client;
[0007] Obtaining matching information from the API request; wherein, the matching information includes at least one of a target environment domain name and target environment description information, and each candidate environment docked by the microservice architecture corresponds to a candidate environment domain name and candidate environment description information;
[0008] Selecting a target route from the candidate routes on the data plane according to the matching information; wherein, each candidate route is bound with a candidate environment identifier, candidate environment domain name, and candidate environment description information of a candidate environment;
[0009] Forwarding the API request to the server of the candidate environment bound by the target route through the target route.
[0010] In one embodiment, the matching information includes a target environment domain name or target environment description information;
[0011] The step of selecting a target route from the candidate routes on the data plane according to the matching information includes:
[0012] From the candidate routes, select a candidate router whose bound candidate environment domain name is the same as the target environment domain name as the target router; or,
[0013] From the candidate routes, select a candidate router whose bound candidate environment description information is the same as the target environment description information as the target router.
[0014] In one embodiment, the matching information includes a target environment domain name and target environment description information;
[0015] The step of selecting a target route from the candidate routes of the data plane according to the matching information includes:
[0016] From the candidate routes, select a candidate router whose bound candidate environment domain name is the same as the target environment domain name and whose bound candidate environment description information is the same as the target environment description information as the target router.
[0017] In one embodiment, each candidate route is further bound with at least one plugin of a candidate environment. Before forwarding the API request to the server of the candidate environment bound by the target route through the target route, the method further includes:
[0018] Preprocess the API request through at least one plugin of the candidate environment bound by the target route;
[0019] If the preprocessing is passed, forward the API request to the server of the candidate environment bound by the target route through the target route.
[0020] In one embodiment, each candidate route is further bound with at least one plugin of a candidate environment, and the method further includes:
[0021] For each candidate route, obtain the binding information of the candidate route from the control plane; wherein, the binding information includes the route name of the candidate route and the candidate environment identifier of the candidate environment bound by the candidate route;
[0022] According to the candidate environment identifier, obtain the candidate environment domain name, candidate environment description information and at least one plugin corresponding to the candidate environment identifier from the storage system associated with the data plane;
[0023] Bind the candidate environment domain name, the candidate environment description information, at least one plugin with the candidate environment identifier bound by the candidate route.
[0024] In one embodiment, the method further includes:
[0025] Receive the candidate environment domain name, candidate environment description information, and at least one plugin corresponding to the candidate environment identifier sent by the control plane through the API maintenance tool;
[0026] Write the candidate environment domain name, candidate environment description information, and at least one plugin corresponding to the candidate environment identifier into the storage system associated with the data plane.
[0027] In one embodiment, the candidate environments include a development environment, a test environment, and a production environment.
[0028] In a second aspect, the present application further provides a message forwarding device, including:
[0029] A request receiving module, configured to receive an application programming interface (API) request sent by a client;
[0030] An information obtaining module, configured to obtain matching information from the API request; wherein, the matching information includes at least one of a target environment domain name and target environment description information, and each candidate environment docked with the microservice architecture corresponds to a candidate environment domain name and candidate environment description information;
[0031] A routing matching module, configured to select a target route from the candidate routes of the data plane according to the matching information; wherein, each candidate route is bound with a candidate environment identifier, candidate environment domain name, and candidate environment description information of a candidate environment;
[0032] A request forwarding module, configured to forward the API request to the server of the candidate environment bound by the target route through the target route.
[0033] In a third aspect, the present application further provides a computer device, including a memory and a processor, where the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0034] Receive an application programming interface (API) request sent by a client;
[0035] Obtain matching information from the API request; wherein, the matching information includes at least one of a target environment domain name and target environment description information, and each candidate environment docked with the microservice architecture corresponds to a candidate environment domain name and candidate environment description information;
[0036] Select a target route from the candidate routes of the data plane according to the matching information; wherein, each candidate route is bound with a candidate environment identifier, candidate environment domain name, and candidate environment description information of a candidate environment;
[0037] Forward the API request to the server of the candidate environment bound by the target route through the target route.
[0038] In a fourth aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented:
[0039] Receive an Application Programming Interface (API) request sent by a client;
[0040] Obtain matching information from the API request; wherein the matching information includes at least one of a target environment domain name and target environment description information, and each candidate environment docked with the microservice architecture corresponds to a candidate environment domain name and candidate environment description information;
[0041] Select a target route from the candidate routes on the data plane according to the matching information; wherein each candidate route is bound with a candidate environment identifier, candidate environment domain name, and candidate environment description information of a candidate environment;
[0042] Forward the API request to the server of the candidate environment bound by the target route through the target route.
[0043] In a fifth aspect, the present application further provides a computer program product, including a computer program. When the computer program is executed by a processor, the following steps are implemented:
[0044] Receive an Application Programming Interface (API) request sent by a client;
[0045] Obtain matching information from the API request; wherein the matching information includes at least one of a target environment domain name and target environment description information, and each candidate environment docked with the microservice architecture corresponds to a candidate environment domain name and candidate environment description information;
[0046] Select a target route from the candidate routes on the data plane according to the matching information; wherein each candidate route is bound with a candidate environment identifier, candidate environment domain name, and candidate environment description information of a candidate environment;
[0047] Forward the API request to the server of the candidate environment bound by the target route through the target route.
[0048] The above message forwarding method, device, computer device, and storage medium receive an API request sent by a client through a control plane of a microservices architecture. Since the API request contains matching information of at least one of a target environment domain name and target environment description information, and each candidate environment connected to the microservices architecture corresponds to a candidate environment domain name and candidate environment description information, and a target route is selected from candidate routes on the data plane according to the matching information; since each candidate route is bound with a candidate environment identifier, candidate environment domain name, and candidate environment description information of a candidate environment, that is, each candidate route is bound with a candidate environment, it is possible to divert API requests from different candidate environments according to the target environment domain name and / or target environment description information, and the API requests of each candidate environment can be independently routed to their respective servers through the bound independent candidate routes, so that different candidate environments can run in parallel. In the above solution, by managing multiple candidate environments in the same control plane (i.e., gateway instance), the resource overhead of independently deploying gateway instances for each candidate environment is reduced, the hardware and operation and maintenance costs are reduced, and at the same time, the workload of multi-environment maintenance is reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the following will briefly introduce the drawings required for use in the description of the embodiments or related technologies. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0050] Figure 1 It is an application environment diagram of the message forwarding method in an embodiment;
[0051] Figure 2 It is a flowchart of the message forwarding method in an embodiment;
[0052] Figure 3 It is a flowchart of forwarding an API request in an embodiment;
[0053] Figure 4 It is a flowchart of binding a candidate route with a candidate environment in an embodiment;
[0054] Figure 5 It is a flowchart of writing the environment information of a candidate environment into the storage system on the data plane in an embodiment;
[0055] Figure 6 It is a microservices architecture diagram in an embodiment;
[0056] Figure 7 It is a structural diagram of the data plane of the microservices architecture in an embodiment;
[0057] Figure 8 It is a schematic flowchart of a message forwarding method in another embodiment;
[0058] Figure 9 It is a structural block diagram of a message forwarding device in an embodiment;
[0059] Figure 10 It is an internal structure diagram of a computer device in an embodiment. Detailed implementation manners
[0060] In order to make the objectives, technical solutions and advantages of the present application more clear and understandable, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0061] The message forwarding method provided by the embodiments of the present application can be applied to an application environment as Figure 1 shown. Among them, the client 101 can be any terminal serving customers; the server 102 is the server of the client, used to provide various services for the client; the microservices architecture is an architecture mode that splits a large application into multiple small and independent service units. Each service runs in its own process and collaborates through lightweight communication mechanisms (such as HTTP RESTful API or message queue). The control plane 103 of the microservices architecture is responsible for handling all management tasks related to the Application Programming Interface (API), including API management, API grouping management, plugin management, domain name configuration, and environment management; the data plane 104 of the microservices architecture, that is, the APISIX gateway, provides functions such as traffic management and plugin extension. Optionally, the data plane 104 receives an application programming interface API request sent by the client 101 and obtains matching information from the API request; among them, the matching information includes at least one of the target environment domain name and the target environment description information; each candidate environment docked by the microservices architecture corresponds to a candidate environment domain name and candidate environment description information; the data plane 104 selects a target route from the candidate routes of the data plane 104 according to the matching information; among them, each candidate route is bound with a candidate environment identifier, a candidate environment domain name, and candidate environment description information of a candidate environment; further, through the target route, the API request is forwarded to the server 102 of the candidate environment bound by the target route.
[0062] In an exemplary embodiment, as Figure 2 shown, a message forwarding method is provided. Taking the method applied to the data plane of the microservices architecture in Figure 1 as an example for description, it specifically includes the following steps:
[0063] S201, Receive an Application Programming Interface (API) request sent by a client.
[0064] Among them, the API request is usually sent by the client, through the network to the API endpoint on the server side. The request contains a series of parameters and data, aiming to let the server side execute a certain operation and return the corresponding data.
[0065] Optionally, the user can send an API request to the server side through the client.
[0066] S202, Obtain matching information from the API request.
[0067] Among them, the matching information is used to match a route for the API request; the matching information includes at least one of the target environment domain name and the target environment description information. Each candidate environment docked by the microservice architecture corresponds to a candidate environment domain name and candidate environment description information. The candidate environments include, but are not limited to, development environments, test environments, production environments, etc.
[0068] It should be noted that in the embodiments of the present application, the candidate environment domain name of the candidate environment is used to represent the name of the candidate environment, and the candidate environment domain name can be a string of names separated by dots. The candidate environment description information is used to describe the candidate environment, and it can be the candidate environment identifier of the candidate environment. In the embodiments of the present application, the candidate environment description information can be written into the request header of the API request from the candidate environment. The target environment domain name is the candidate environment domain name of the candidate environment involved in the API request; the target environment description information is the candidate environment description information of the candidate environment involved in the API request.
[0069] Optionally, after receiving the API request, the target environment domain name can be obtained from the information carried in the API request, or the target environment description information can be obtained from the request header of the API request, and the target environment domain name and / or the target environment domain name are used as the matching information.
[0070] S203, Select a target route from the candidate routes on the data plane according to the matching information.
[0071] Among them, each candidate route is bound with a candidate environment identifier, a candidate environment domain name, and candidate environment description information of a candidate environment, and each candidate route is also bound with at least one plugin of a candidate environment. The plugin can be used to implement the functional requirements and security policies of each candidate environment, and different candidate environments can customize and configure the plugin according to the actual requirements of the candidate environment. The candidate route is a basic component of the control plane and is used to define the routing rules for API requests. It matches the API request to the corresponding server according to the attributes of the API request (such as path, method, domain name, etc.). The candidate route can be bound with multiple plugins and domain names to expand functions such as traffic control, authentication, and rate limiting of requests.
[0072] It can be understood that in order to achieve unified management of multiple candidate environments through a gateway instance, that is, the control plane, it is necessary to bind a candidate route to each candidate environment so that the API requests of each candidate environment can be independently routed to their respective servers through the bound candidate route.
[0073] Optionally, according to the routing matching rules set by the user through the control plane, based on the target environment domain name and / or target environment domain name in the matching information, and the candidate environment domain name and / or candidate environment description information bound to each candidate route, the target route can be selected from the candidate routes on the data plane.
[0074] S204, forward the API request to the server of the candidate environment bound to the target route through the target route.
[0075] Optionally, after the target route is matched, the candidate environment corresponding to the API request can be determined according to the candidate environment identifier bound to the target route, and then the API request can be forwarded to the server of the candidate environment bound to the target route through the target route.
[0076] In the above message forwarding method, through a control plane of a microservices architecture, an application programming interface (API) request sent by a client is received. Since the API request contains matching information of at least one of a target environment domain name and target environment description information, and each candidate environment connected to the microservices architecture corresponds to a candidate environment domain name and candidate environment description information, and a target route is selected from candidate routes on the data plane according to the matching information; since each candidate route is bound with a candidate environment identifier, candidate environment domain name, and candidate environment description information of a candidate environment, that is, each candidate route is bound with a candidate environment, it is possible to shunt API requests from different candidate environments according to the target environment domain name and / or target environment description information, and the API requests of each candidate environment can be independently routed to their respective servers through the bound independent candidate routes, so that different candidate environments can run in parallel. In the above solution, by managing multiple candidate environments in the same control plane (i.e., gateway instance), the resource overhead of independently deploying gateway instances for each candidate environment is reduced, the hardware and operation and maintenance costs are reduced, and at the same time, the workload of multi-environment maintenance is reduced.
[0077] In an embodiment of the present application, based on different route matching rules, three methods for selecting a target route from candidate routes on the data plane are provided. The first method is that if the matching information includes a target environment domain name, a candidate router whose bound candidate environment domain name is the same as the target environment domain name is selected from the candidate routes as the target router. It can be understood that if the matching information includes a target environment domain name, it means that the route matching rule is to only verify the environment domain name. At this time, only a router whose bound candidate environment domain name is the target environment domain name needs to be selected from the candidate routers as the target router.
[0078] The second method is that if the matching information includes target environment description information, a candidate router whose bound candidate environment description information is the same as the target environment description information is selected from the candidate routes as the target router. It can be understood that if the matching information includes target environment description information, it means that the route matching rule is to only verify the request header (i.e., environment description information). At this time, only a router whose bound candidate environment description information is the target environment description information needs to be selected from the candidate routers as the target router.
[0079] The third method is that if the matching information includes the target environment domain name and the target environment description information, then among the candidate routes, select the candidate router whose bound candidate environment domain name is the same as the target environment domain name and whose bound candidate environment description information is the same as the target environment description information as the target router. It can be understood that if the matching information includes the target environment domain name and the target environment description information, it means that the routing matching rule is to verify the request header (i.e., the environment description information) and the environment domain name. At this time, it is necessary to select, from the candidate routers, the router whose bound candidate environment description information is the target environment description information and whose bound candidate environment domain name is the target environment domain name as the target router.
[0080] It should be noted that which specific method to adopt can be determined according to the routing matching rules set by the user through the control plane.
[0081] Optionally, in order to ensure that the functional requirements and security policies of each candidate environment do not interfere with each other, independent gateway plugins can be configured for different candidate environments, that is, each candidate route is also bound to at least one plugin of a candidate environment. The at least one plugin includes, but is not limited to, authentication plugins, identification plugins, etc.; in this case, in one embodiment, as Figure 3 shown, a method for forwarding an API request to the server of a candidate environment is provided, which specifically includes the following steps:
[0082] S301, preprocess the API request through at least one plugin of the candidate environment bound by the target route.
[0083] Optionally, according to the plugin type of the plugin bound by the target route, the plugin can be used to preprocess the API request. Exemplarily, if the plugin bound by the target route is an identification plugin, then identify the API request.
[0084] S302, if the preprocessing is passed, then forward the API request to the server of the candidate environment bound by the target route through the target route.
[0085] Optionally, in the case where the preprocessing is passed, then forward the API request to the server of the candidate environment bound by the target route through the target route. Exemplarily, if the plugin is an identification plugin, then in the case where the API request is identified and processed by the identification plugin and passed, forward the API request to the server of the candidate environment bound by the target route through the target route.
[0086] In this embodiment, by configuring independent gateway plugins (such as traffic limiting, authentication, logging, etc.) for different candidate environments, it is ensured that the functional requirements and security policies of each candidate environment do not interfere with each other. In this way, each candidate environment can customize the plugin configuration according to actual needs, simplifies the configuration management, and avoids cross-environment conflicts.
[0087] Optionally, each candidate route is also bound to at least one plugin of a candidate environment. In this case, in one embodiment, as Figure 4 shown, a method for binding a candidate route to a candidate environment is provided, specifically including the following steps:
[0088] S401, for each candidate route, obtain the binding information of the candidate route from the control plane.
[0089] Among them, the binding information is the information of the candidate environment bound by the candidate route. In the embodiments of the present application, the binding information includes the route name of the candidate route, the candidate environment identifier of the candidate environment bound by the candidate route, etc.
[0090] Optionally, in the embodiments of the present application, the binding information of the candidate route pre-configured by the user can be obtained from the control plane. It should be noted that in the embodiments of the present application, the user can configure the corresponding candidate route for each candidate environment through the control plane to change the route information.
[0091] S402, according to the candidate environment identifier, obtain the candidate environment domain name, candidate environment description information, and at least one plugin corresponding to the candidate environment identifier from the storage system associated with the data plane.
[0092] Optionally, in the embodiments of the present application, a new storage system is introduced in the control plane to store the candidate environment domain name, candidate environment description information, and at least one plugin corresponding to the candidate environment identifier of the candidate environment. Furthermore, the candidate environment domain name, candidate environment description information, and at least one plugin corresponding to the candidate environment identifier can be obtained from the storage system associated with the data plane according to the candidate environment identifier.
[0093] S403, bind the candidate environment domain name, candidate environment description information, at least one plugin to the candidate environment identifier bound by the candidate route.
[0094] Optionally, in order to bind a unique candidate route to each candidate environment, it is also necessary to bind the candidate environment domain name and candidate environment description information to the candidate environment identifier bound by the candidate route.
[0095] In this embodiment, by obtaining the binding information of each candidate route from the control plane and, according to the binding information, binding the candidate environment domain name, candidate environment description information, and at least one plugin to the candidate environment identifier bound by the candidate route, a candidate environment can be accurately assigned to the candidate route.
[0096] Optionally, in one embodiment, as Figure 5 shown, a method for writing the environment information of a candidate environment into the storage system of the data plane is provided, specifically including the following steps:
[0097] S501 receives the candidate environment domain name, candidate environment description information, and at least one plugin corresponding to the candidate environment identifier sent by the control plane through the API maintenance tool.
[0098] It should be noted that in the embodiments of the present application, the user can implement the grouping process of the API through the control plane. Each API group can contain multiple APIs, and different APIs can be configured and managed, including name, path, request method, etc. The user can also bind at least one plugin to each API group or a single API through the control plane to achieve targeted function expansion. The plugin supports multi-environment isolation to ensure independent configuration and use in different environments. The user can also configure the corresponding environment domain name for each API group through the control plane, and the domain name configuration also supports multi-environment isolation, so as to realize requests for different environment domain names and route them to different environments. In addition, three candidate environments, namely the development environment, test environment, and production environment, are supported by default, and can also be custom-added. Each API group and API can bind plugins and domain names in their respective different environments to ensure the independence between environments and avoid mutual influence.
[0099] Furthermore, after the user completes the API configuration through the control plane, the control plane will call the API maintenance tool, such as Admin API, to write the candidate environment domain name, candidate environment description information, and at least one plugin corresponding to the candidate environment identifier into the storage system of the data plane.
[0100] S502 writes the candidate environment domain name, candidate environment description information, and at least one plugin corresponding to the candidate environment identifier into the storage system associated with the data plane.
[0101] It should be noted that the control plane will add environment information such as the candidate environment domain name and candidate environment description information of the candidate environment to the vars of the candidate route bound to the candidate environment according to the candidate environment identifier of the candidate environment. The vars will be used as the route matching condition to accurately route each request to the bound candidate environment. Finally, the candidate environment domain name, candidate environment description information, and at least one plugin corresponding to the candidate environment identifier are written into the storage system associated with the data plane.
[0102] In this embodiment, by obtaining the candidate environment domain name, candidate environment description information, and at least one plugin corresponding to the candidate environment identifier from the control plane and writing them into the storage system of the data plane, the configuration synchronization between the control plane and the data plane is ensured.
[0103] Optionally, to more intuitively describe the microservice architecture involved in the message forwarding method provided in the embodiments of the present application, as Figure 6As shown in the figure, it is a microservices architecture diagram. Among them, in the control plane, the user configures three candidate environments, namely the development environment, the test environment, and the production environment, and configures three API groups to classify multiple APIs into a group for convenient batch management and configuration. Each API group can contain multiple APIs. The API management module supports different API configurations and management, including name, path, request method, etc. Exemplarily, API group 1 includes API1 and API2. Each candidate environment corresponds to a fixed plugin and an environment domain name. After the user configures the candidate environments through the control plane, the control plane calls the Admin API to write the plugin and environment domain name bound to each candidate environment into the data plane. The Service in the control plane corresponds one-to-one with the API groups in the control plane, and its role is to abstract the common capabilities of the APIs under the same group. Etcd is a distributed key-value storage system used to store the configuration information of the candidate environments.
[0104] As Figure 7 shown, it is a control plane structure diagram. Among them, the change of API group information and the API release in the control plane are both written into the control plane through the Admin API. The storage system is used to store stage_hosts, that is, the correspondence between the environment identifiers and environment domain names of the candidate environments; the request header enable flag (enable_header_stage) is used to indicate whether to enable the request header verification. The control plane binds the environment identifier of the candidate environment to the candidate route through radix tree reconstruction. x_ca_stage is the request header.
[0105] Figure 8 It is a flowchart of the message forwarding method in another embodiment. Based on the above embodiment, this embodiment provides an optional example of the message forwarding method. Combining Figure 8 , the specific implementation process is as follows:
[0106] S801, Receive an application programming interface API request sent by the client.
[0107] S802, Obtain the matching information from the API request.
[0108] Among them, the matching information includes at least one of the target environment domain name and the target environment description information. Each candidate environment docked by the microservices architecture corresponds to a candidate environment domain name and candidate environment description information; each candidate route is also bound to at least one plugin of a candidate environment.
[0109] S803, Determine the content included in the matching information; if the matching information includes the target environment domain name, execute S804; if the matching information includes the target environment description information, execute S805; if the matching information includes the target environment domain name and the target environment description information, execute S806.
[0110] S804. Select a candidate router whose bound candidate environment domain name is the same as the target environment domain name from the candidate routes as the target router, and execute S807.
[0111] Among them, each candidate route is bound with a candidate environment identifier, a candidate environment domain name, and candidate environment description information of a candidate environment.
[0112] Optionally, for each candidate route, obtain the binding information of the candidate route from the control plane. The binding information includes the route name of the candidate route and the candidate environment identifier of the candidate environment to which the candidate route is bound. According to the candidate environment identifier, obtain the candidate environment domain name, candidate environment description information, and at least one plugin corresponding to the candidate environment identifier from the storage system associated with the data plane. Bind the candidate environment domain name, candidate environment description information, and at least one plugin to the candidate environment identifier to which the candidate route is bound.
[0113] Optionally, receive the candidate environment domain name, candidate environment description information, and at least one plugin corresponding to the candidate environment identifier sent by the control plane through the API maintenance tool. Write the candidate environment domain name, candidate environment description information, and at least one plugin corresponding to the candidate environment identifier into the storage system associated with the data plane.
[0114] S805. Select a candidate router whose bound candidate environment description information is the same as the target environment description information from the candidate routes as the target router, and execute S807.
[0115] S806. Select a candidate router whose bound candidate environment domain name is the same as the target environment domain name and whose bound candidate environment description information is the same as the target environment description information from the candidate routes as the target router, and execute S807.
[0116] S807. Preprocess the API request through at least one plugin of the candidate environment bound by the target route.
[0117] S808. If the preprocessing is passed, forward the API request to the server of the candidate environment bound by the target route through the target route.
[0118] For the specific processes of the above S801 - S808, reference can be made to the descriptions in the above method embodiments. Their implementation principles and technical effects are similar and will not be elaborated here.
[0119] It should be understood that although the steps in the flowcharts involved in the above-described embodiments are shown in sequence according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless there is a clear indication in this article, the execution of these steps has no strict order limit, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-described embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be executed alternately or in turn with at least a part of other steps or steps or stages in other steps.
[0120] Based on the same inventive concept, an embodiment of the present application further provides a message forwarding device for implementing the message forwarding method described above. The solution provided by this device to solve the problem is similar to the solution described in the above method. Therefore, the specific limitations in one or more embodiments of the message forwarding device provided below can refer to the limitations on the message forwarding method in the above text, and will not be repeated here.
[0121] In an exemplary embodiment, as Figure 9 shown, a message forwarding device 900 is provided, which is configured on the data plane of the microservice architecture and includes: a request receiving module 910, an information obtaining module 920, a routing matching module 930, and a request forwarding module 940, where:
[0122] The request receiving module 910 is used to receive an application programming interface (API) request sent by a client.
[0123] The information obtaining module 920 is used to obtain matching information from the API request; where the matching information includes at least one of a target environment domain name and target environment description information, and each candidate environment docked by the microservice architecture corresponds to a candidate environment domain name and candidate environment description information.
[0124] The routing matching module 930 is used to select a target route from the candidate routes on the data plane according to the matching information; where each candidate route is bound with a candidate environment identifier, candidate environment domain name, and candidate environment description information of a candidate environment.
[0125] The request forwarding module 940 is used to forward the API request to the server of the candidate environment bound by the target route through the target route.
[0126] The above message forwarding device receives an API request sent by a client through a control plane of a microservices architecture. Since the API request contains matching information of at least one of a target environment domain name and target environment description information, and each candidate environment docked by the microservices architecture corresponds to a candidate environment domain name and candidate environment description information, and a target route is selected from candidate routes in the data plane according to the matching information; since each candidate route is bound with a candidate environment identifier, candidate environment domain name, and candidate environment description information of a candidate environment, that is, each candidate route is bound with a candidate environment, it is possible to split API requests from different candidate environments according to the target environment domain name and / or target environment description information. The API requests of each candidate environment can be independently routed to their respective servers through the bound independent candidate routes, enabling different candidate environments to run in parallel. In the above solution, by managing multiple candidate environments in the same control plane (i.e., gateway instance), the resource overhead of independently deploying gateway instances for each candidate environment is reduced, the hardware and operation and maintenance costs are reduced, and at the same time, the workload of multi-environment maintenance is reduced.
[0127] In one embodiment, the matching information includes a target environment domain name or target environment description information; the route matching module 930 is used to:
[0128] Select, from the candidate routes, a candidate router whose bound candidate environment domain name is the same as the target environment domain name as the target router; or, select, from the candidate routes, a candidate router whose bound candidate environment description information is the same as the target environment description information as the target router.
[0129] In one embodiment, the matching information includes a target environment domain name and target environment description information; the route matching module 930 is further used to:
[0130] Select, from the candidate routes, a candidate router whose bound candidate environment domain name is the same as the target environment domain name and whose bound candidate environment description information is the same as the target environment description information as the target router.
[0131] In one embodiment, each candidate route is further bound with at least one plugin of a candidate environment; the request forwarding module 940 is further used to:
[0132] Preprocess the API request through at least one plugin of the candidate environment bound by the target route; if the preprocessing passes, forward the API request to the server of the candidate environment bound by the target route through the target route.
[0133] In one embodiment, the message forwarding device 900 further includes:
[0134] A first acquisition unit, configured to acquire, for each candidate route, binding information of the candidate route from a control plane; wherein the binding information includes a route name of the candidate route and a candidate environment identifier of a candidate environment to which the candidate route is bound.
[0135] A second acquisition unit, configured to acquire, according to the candidate environment identifier, a candidate environment domain name, candidate environment description information, and at least one plugin corresponding to the candidate environment identifier from a storage system associated with a data plane.
[0136] An information binding unit, configured to bind the candidate environment domain name, the candidate environment description information, the at least one plugin to the candidate environment identifier to which the candidate route is bound.
[0137] In one embodiment, the second acquisition unit is further configured to:
[0138] Receive the candidate environment domain name, the candidate environment description information, and the at least one plugin corresponding to the candidate environment identifier sent by the control plane through an API maintenance tool; and write the candidate environment domain name, the candidate environment description information, and the at least one plugin corresponding to the candidate environment identifier into the storage system associated with the data plane.
[0139] In one embodiment, the candidate environment includes a development environment, a test environment, and a production environment.
[0140] Each module in the above message forwarding device can be implemented in whole or in part by software, hardware, and their combination. The above modules can be embedded in the processor in the computer device in the form of hardware or independent of the processor, or stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0141] In an exemplary embodiment, a computer device is provided. The computer device can be a server, and its internal structure diagram can be as Figure 10 shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, abbreviated as I / O), and a communication interface. Among them, the processor, the memory, and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used for the processor to exchange information with external devices. The communication interface of the computer device is used for communicating with an external terminal through a network connection. The computer program, when executed by the processor, implements a message forwarding method.
[0142] Those skilled in the art can understand that Figure 10 The structure shown in Figure 10 is only a block diagram of some structures related to the solution of this application, and does not constitute a limitation on the computer device to which the solution of this application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine some components, or have different component arrangements.
[0143] In an exemplary embodiment, a computer device is provided, including a memory and a processor. A computer program is stored in the memory. When the processor executes the computer program, the following steps are implemented:
[0144] Receive an Application Programming Interface (API) request sent by a client;
[0145] Obtain matching information from the API request; wherein, the matching information includes at least one of a target environment domain name and target environment description information, and each candidate environment docked by the microservice architecture corresponds to a candidate environment domain name and candidate environment description information;
[0146] Select a target route from the candidate routes on the data plane according to the matching information; wherein, each candidate route is bound with a candidate environment identifier, candidate environment domain name, and candidate environment description information of a candidate environment;
[0147] Forward the API request to the server of the candidate environment bound by the target route through the target route.
[0148] In an embodiment, the matching information includes a target environment domain name or target environment description information; when the processor executes the computer program to select a target route from the candidate routes on the data plane according to the matching information, the following steps are further implemented:
[0149] Select, from the candidate routes, the candidate router whose bound candidate environment domain name is the same as the target environment domain name as the target router; or, select, from the candidate routes, the candidate router whose bound candidate environment description information is the same as the target environment description information as the target router.
[0150] In an embodiment, the matching information includes a target environment domain name and target environment description information; when the processor executes the computer program to select a target route from the candidate routes on the data plane according to the matching information, the following steps are further implemented:
[0151] Select, from the candidate routes, the candidate router whose bound candidate environment domain name is the same as the target environment domain name and whose bound candidate environment description information is the same as the target environment description information as the target router.
[0152] In one embodiment, each candidate route is further bound to at least one plugin of a candidate environment. Before the processor executes the computer program to forward the API request to the server of the candidate environment bound to the target route through the target route, the following steps are further implemented:
[0153] Preprocess the API request through at least one plugin of the candidate environment bound by the target route; if the preprocessing passes, forward the API request to the server of the candidate environment bound to the target route through the target route.
[0154] In one embodiment, each candidate route is further bound to at least one plugin of a candidate environment. When the processor executes the computer program, the following steps are further implemented:
[0155] For each candidate route, obtain the binding information of the candidate route from the control plane; wherein, the binding information includes the route name of the candidate route and the candidate environment identifier of the candidate environment bound by the candidate route; according to the candidate environment identifier, obtain the candidate environment domain name, candidate environment description information and at least one plugin corresponding to the candidate environment identifier from the storage system associated with the data plane; bind the candidate environment domain name, candidate environment description information, at least one plugin to the candidate environment identifier bound by the candidate route.
[0156] In one embodiment, when the processor executes the computer program, the following steps are further implemented:
[0157] Receive the candidate environment domain name, candidate environment description information and at least one plugin corresponding to the candidate environment identifier sent by the control plane through the API maintenance tool; write the candidate environment domain name, candidate environment description information and at least one plugin corresponding to the candidate environment identifier into the storage system associated with the data plane.
[0158] In one embodiment, the candidate environment includes a development environment, a test environment and a production environment.
[0159] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented:
[0160] Receive an application programming interface (API) request sent by a client;
[0161] Obtain matching information from the API request; wherein, the matching information includes at least one of a target environment domain name and target environment description information, and each candidate environment docked by the microservice architecture corresponds to a candidate environment domain name and candidate environment description information;
[0162] Select a target route from the candidate routes on the data plane according to the matching information; wherein, each candidate route is bound with a candidate environment identifier, a candidate environment domain name, and candidate environment description information of a candidate environment;
[0163] Forward the API request to the server of the candidate environment bound by the target route through the target route.
[0164] In one embodiment, the matching information includes a target environment domain name or target environment description information; when the processor executes the computer program to select a target route from the candidate routes on the data plane according to the matching information, the following steps are further implemented:
[0165] Select, from the candidate routes, a candidate router whose bound candidate environment domain name is the same as the target environment domain name as the target router; or, select, from the candidate routes, a candidate router whose bound candidate environment description information is the same as the target environment description information as the target router.
[0166] In one embodiment, the matching information includes a target environment domain name and target environment description information; when the processor executes the computer program to select a target route from the candidate routes on the data plane according to the matching information, the following steps are further implemented:
[0167] Select, from the candidate routes, a candidate router whose bound candidate environment domain name is the same as the target environment domain name and whose bound candidate environment description information is the same as the target environment description information as the target router.
[0168] In one embodiment, each candidate route is further bound with at least one plugin of a candidate environment; before the processor executes the computer program to forward the API request to the server of the candidate environment bound by the target route through the target route, the following steps are further implemented:
[0169] Preprocess the API request through at least one plugin of the candidate environment bound by the target route; if the preprocessing passes, forward the API request to the server of the candidate environment bound by the target route through the target route.
[0170] In one embodiment, each candidate route is further bound with at least one plugin of a candidate environment; when the processor executes the computer program, the following steps are further implemented:
[0171] For each candidate route, obtain the binding information of the candidate route from the control plane; wherein, the binding information includes the route name of the candidate route and the candidate environment identifier of the candidate environment to which the candidate route is bound; according to the candidate environment identifier, obtain the candidate environment domain name, candidate environment description information, and at least one plugin corresponding to the candidate environment identifier from the storage system associated with the data plane; bind the candidate environment domain name, candidate environment description information, and at least one plugin to the candidate environment identifier to which the candidate route is bound.
[0172] In one embodiment, when the processor executes the computer program, the following steps are further implemented:
[0173] Receive the candidate environment domain name, candidate environment description information, and at least one plugin corresponding to the candidate environment identifier sent by the control plane through the API maintenance tool; write the candidate environment domain name, candidate environment description information, and at least one plugin corresponding to the candidate environment identifier into the storage system associated with the data plane.
[0174] In one embodiment, the candidate environment includes a development environment, a test environment, and a production environment.
[0175] In one embodiment, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the following steps are implemented:
[0176] Receive an application programming interface (API) request sent by a client;
[0177] Obtain matching information from the API request; wherein, the matching information includes at least one of a target environment domain name and target environment description information, and each candidate environment docked by the microservice architecture corresponds to a candidate environment domain name and candidate environment description information;
[0178] According to the matching information, select a target route from the candidate routes in the data plane; wherein, each candidate route is bound with a candidate environment identifier, candidate environment domain name, and candidate environment description information of a candidate environment;
[0179] Forward the API request to the server of the candidate environment to which the target route is bound through the target route.
[0180] In one embodiment, the matching information includes a target environment domain name or target environment description information; when the processor executes the computer program to select a target route from the candidate routes in the data plane according to the matching information, the following steps are further implemented:
[0181] From the candidate routes, select a candidate router whose bound candidate environment domain name is the same as the target environment domain name as the target router; or, from the candidate routes, select a candidate router whose bound candidate environment description information is the same as the target environment description information as the target router.
[0182] In one embodiment, the matching information includes a target environment domain name and target environment description information; when the processor executes a computer program to select a target route from candidate routes according to the matching information, the following steps are further implemented:
[0183] From the candidate routes, select a candidate router whose bound candidate environment domain name is the same as the target environment domain name and whose bound candidate environment description information is the same as the target environment description information as the target router.
[0184] In one embodiment, each candidate route is further bound with at least one plugin of a candidate environment. Before the processor executes a computer program to forward an API request to the server of the candidate environment bound to the target route through the target route, the following steps are further implemented:
[0185] Preprocess the API request through at least one plugin of the candidate environment bound to the target route; if the preprocessing is passed, forward the API request to the server of the candidate environment bound to the target route through the target route.
[0186] In one embodiment, each candidate route is further bound with at least one plugin of a candidate environment. When the processor executes a computer program, the following steps are further implemented:
[0187] For each candidate route, obtain the binding information of the candidate route from the control plane; where the binding information includes the route name of the candidate route and the candidate environment identifier of the candidate environment bound to the candidate route; according to the candidate environment identifier, obtain the candidate environment domain name, candidate environment description information, and at least one plugin corresponding to the candidate environment identifier from the storage system associated with the data plane; bind the candidate environment domain name, candidate environment description information, and at least one plugin to the candidate environment identifier bound to the candidate route.
[0188] In one embodiment, when the processor executes a computer program, the following steps are further implemented:
[0189] Receive the candidate environment domain name, candidate environment description information, and at least one plugin corresponding to the candidate environment identifier sent by the control plane through the API maintenance tool; write the candidate environment domain name, candidate environment description information, and at least one plugin corresponding to the candidate environment identifier into the storage system associated with the data plane.
[0190] In one embodiment, the candidate environments include a development environment, a test environment, and a production environment.
[0191] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use, and processing of relevant data need to comply with relevant regulations.
[0192] Those of ordinary skill in the art can understand that all or part of the processes of implementing the methods in the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, database, or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memories. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The databases involved in the embodiments provided in this application can include at least one of relational databases and non-relational databases. Non-relational databases can include distributed databases based on blockchain, etc., and are not limited thereto. The processors involved in the embodiments provided in this application can be general-purpose processors, central processors, graphics processors, digital signal processors, programmable logic devices, data processing logics based on quantum computing, etc., and are not limited thereto.
[0193] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, 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, it should be considered to be within the scope described in this specification.
[0194] The above-described embodiments merely represent several implementation manners of the present application. The description thereof is relatively specific and detailed, but it should not be construed as a limitation to the patent scope of the present application. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all fall within the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the appended claims.
Claims
1. A message forwarding method, applied to the data plane of a microservice architecture, characterized in that: The method comprises: Receive an application programming interface (API) request sent by a client; Obtain matching information from the API request; wherein the matching information includes at least one of a target environment domain name and a target environment description information, and each candidate environment connected to the microservice architecture corresponds to a candidate environment domain name and a candidate environment description information; According to the matching information, a target route is selected from the candidate routes of the data plane; wherein each candidate route is bound to a candidate environment identifier, a candidate environment domain name and candidate environment description information of a candidate environment; Through the target route, the API request is forwarded to the server of the candidate environment bound to the target route.
2. The method according to claim 1, characterized in that The matching information includes the target environment domain name or the target environment description information; The selecting a target route from the candidate routes of the data plane according to the matching information includes: From the candidate routes, select a candidate router whose bound candidate environment domain name is the same as the target environment domain name as the target router; or, From the candidate routes, a candidate router whose bound candidate environment description information is the same as the target environment description information is selected as the target router.
3. The method according to claim 1, characterized in that The matching information includes the target environment domain name and the target environment description information; The selecting a target route from the candidate routes of the data plane according to the matching information includes: From the candidate routes, a candidate router whose bound candidate environment domain name is the same as the target environment domain name and whose bound candidate environment description information is the same as the target environment description information is selected as the target router.
4. The method according to claim 1, characterized in that: Each candidate route is also bound to at least one plug-in of a candidate environment. Before forwarding the API request to the server of the candidate environment bound to the target route through the target route, the method further includes: Preprocessing the API request through at least one plug-in of the candidate environment bound to the target route; If the preprocessing passes, the API request is forwarded to the server of the candidate environment bound to the target route through the target route.
5. The method according to claim 1, characterized in that Each candidate route is also bound to at least one plug-in of a candidate environment, and the method further includes: For each candidate route, obtaining binding information of the candidate route from the control plane; wherein the binding information includes a route name of the candidate route and a candidate environment identifier of a candidate environment to which the candidate route is bound; According to the candidate environment identifier, obtaining a candidate environment domain name, candidate environment description information and at least one plug-in corresponding to the candidate environment identifier from a storage system associated with the data plane; The candidate environment domain name, the candidate environment description information, at least one plug-in and the candidate environment identifier bound to the candidate route are bound.
6. The method according to claim 5, characterized in that The method further comprises: Receive a candidate environment domain name, candidate environment description information, and at least one plug-in corresponding to the candidate environment identifier sent by the control plane through an API maintenance tool; The candidate environment domain name, candidate environment description information and at least one plug-in corresponding to the candidate environment identifier are written into a storage system associated with the data plane.
7. The method according to any one of claims 1 to 6, characterized in that: The candidate environments include a development environment, a test environment, and a production environment.
8. A message forwarding device, characterized in that: Configured on the data plane of the microservice architecture, the device includes: A request receiving module, used for receiving an application programming interface (API) request sent by a client; An information acquisition module, used to obtain matching information from an API request; wherein the matching information includes at least one of a target environment domain name and a target environment description information, and each candidate environment connected to the microservice architecture corresponds to a candidate environment domain name and candidate environment description information; A route matching module, configured to select a target route from the candidate routes of the data plane according to the matching information; wherein each candidate route is bound to a candidate environment identifier, a candidate environment domain name and candidate environment description information of a candidate environment; The request forwarding module is used to forward the API request to the server of the candidate environment bound to the target route through the target route.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Software development multi-environment service unified entry management method and related device
CN121418230A