Request processing method and device for Janus gateway, equipment and medium
By determining the target service in the Janus gateway and using the service registration list of multiple service registration centers, the service discovery problem caused by changes in the service node network address is solved, and the success rate and efficiency of request processing are improved.
Patent Information
- Application Number
- CN202311717057.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-13
- Publication Date
- 2025-06-13
AI Technical Summary
After the network address of the service node is changed, the Janus gateway cannot realize the discovery of the service node, resulting in low success rate and efficiency of request processing.
When the Janus gateway receives the client request, the target service is determined, and the target service node is determined from multiple service clusters corresponding to the multiple service registry centers based on the service registration list obtained from the multiple service registry centers, thereby forwarding the request to the target service node.
The service discovery method has been broadened, so that Janus gateway can not only realize service discovery based on network addresses, but also realize service discovery based on other service registration information in multiple service registration centers, thereby improving the success rate and efficiency of request processing.
Smart Images

Figure CN120151401A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of network technologies, and in particular, to a request processing method, apparatus, device, and medium for a Janus gateway. Background Art
[0002] As a network middleware working at the top layer of each service, the Janus gateway can be used to implement various functions of the flow control layer. For example, the Janus gateway can be used to implement traffic distribution in the flow control layer. A client can send a request to the Janus gateway, and the Janus gateway can obtain a list of available upstream services through a service registry to forward the request sent by the client to the corresponding upstream service for request processing.
[0003] To ensure that the Janus gateway can implement service discovery through a service registry, it is necessary to pre-configure the service registry for the Janus gateway. In related technologies, when configuring the service registry for the Janus gateway, it is necessary to write the network address of the service node into the service registry so that the Janus gateway can implement the discovery of the service node after receiving a client request based on the configured network address.
[0004] However, the network address of the service node cannot remain unchanged all the time. Once the network address of the service node changes, the Janus gateway cannot implement the discovery of the service node based on the configured network address therein, resulting in low success rate and efficiency of request processing. Summary of the Invention
[0005] To overcome the problems existing in related technologies, this application provides a request processing method, apparatus, device, and medium for a Janus gateway.
[0006] According to the first aspect of the embodiments of this application, a request processing method for a Janus gateway is provided. The method includes:
[0007] In response to receiving a request from a client, determine a target service for processing the request;
[0008] Based on a service registration list obtained from multiple service registries, determine a target service node for providing the target service from multiple service clusters corresponding to the multiple service registries; wherein, for any service cluster, the service registration list records service registration information of the service cluster, and the service registration information is used to indicate the services provided by the service cluster and the service node configuration of the service cluster;
[0009] Forward the request to the target service node.
[0010] In some embodiments, forwarding the request to the target service node includes:
[0011] Forward the request to the target service node according to the network address of the target service node.
[0012] In some embodiments, before determining the target service node for providing the target service from multiple service clusters corresponding to multiple service registration centers based on the service registration list obtained from the multiple service registration centers, the method further includes:
[0013] Pull the service registration list from each of the multiple service registration centers and cache the pulled service registration list.
[0014] In some embodiments, in response to receiving a request from a client, determining the target service for processing the request includes:
[0015] In response to receiving a request from a client, obtain the request parameters carried by the request;
[0016] Based on the request parameters, obtain the service name of the target service for processing the request.
[0017] In some embodiments, after authenticating the request in response to receiving a request from a client, the method further includes:
[0018] If the request passes the authentication, cache the authentication result of the request so that when the request is received again, the cached authentication result is used as the authentication result of the request received again.
[0019] According to a second aspect of the embodiments of the present application, there is provided a request processing apparatus for a Janus gateway, the apparatus including:
[0020] A determination module, configured to determine a target service for processing a request in response to receiving a request from a client;
[0021] The determination module is further configured to determine, based on the service registration list obtained from multiple service registration centers, a target service node for providing the target service from multiple service clusters corresponding to the multiple service registration centers; wherein, for any service cluster, the service registration list records the service registration information of the service cluster, and the service registration information is used to indicate the services provided by the service cluster and the service node configuration of the service cluster;
[0022] A sending module, configured to forward the request to the target service node.
[0023] According to a third aspect of the embodiments of the present application, there is provided a network device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the operations performed by the above-mentioned request processing method for a Janus gateway.
[0024] According to a fourth aspect of the embodiments of the present application, there is provided a computer-readable storage medium, on which a program is stored, and the program is executed by a processor to perform the operations executed by the above-mentioned request processing method for the Janus gateway.
[0025] According to a fifth aspect of the embodiments of the present application, there is provided a computer program product, including a computer program, and when the computer program is executed by a processor, it implements the operations executed by the above-mentioned request processing method for the Janus gateway.
[0026] The technical solutions provided by the embodiments of the present application may include the following beneficial effects:
[0027] When the Janus gateway receives a request from a client, a target service for processing the request is determined, and then based on the service registration list obtained from multiple service registration centers, a target service node for providing the target service is determined from multiple service clusters corresponding to the multiple service registration centers, and then the request is forwarded to the target service node to implement the processing of the request. Among them, for any service cluster, the service registration list records the service registration information of the service cluster, and the service registration information is used to indicate the services provided by the service cluster and the service node configuration of the service cluster, broadening the service discovery method, so that Janus can not only implement service discovery based on network addresses, but also implement service discovery according to other service registration information in multiple service registration centers, thereby improving the success rate and efficiency of request processing.
[0028] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and cannot limit the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] The drawings herein are incorporated into the specification and constitute a part of the present application, showing embodiments consistent with the present application, and are used together with the specification to explain the principles of the present application.
[0030] Figure 1 is a flowchart of a request processing method for a Janus gateway shown according to an exemplary embodiment of the present application.
[0031] Figure 2 is an interaction flowchart of a Janus gateway and a service registration center shown according to an exemplary embodiment of the present application.
[0032] Figure 3 is a schematic diagram of an interface of a first configuration interface shown according to an exemplary embodiment of the present application.
[0033] Figure 4 is a flowchart of an authentication process shown according to an exemplary embodiment of the present application.
[0034] Figure 5 This is a schematic flowchart of an index collection process shown according to an exemplary embodiment of the present application.
[0035] Figure 6 This is a block diagram of a request processing device for a Janus gateway shown according to an exemplary embodiment of the present application.
[0036] Figure 7 This is a schematic structural diagram of a network device shown according to an exemplary embodiment of the present application. Detailed implementation manners
[0037] Here, the exemplary embodiments will be described in detail, and the examples are shown in the drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementation manners described in the following exemplary embodiments do not represent all implementation manners consistent with the present application. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the present application.
[0038] The terms used in the present application are only for the purpose of describing specific embodiments and are not intended to limit the present application. The singular forms "a", "the", and "said" used in the present application are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more of the associated listed items.
[0039] It should be understood that although the terms first, second, third, etc. may be used in the present application to describe various information, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "when" or "while" or "in response to determining".
[0040] The present application provides a request processing method for a Janus gateway to expand the request processing ability of the Janus gateway. Optionally, the request processing method for a Janus gateway provided by the present application can be used to process various types of requests. For example, the request processing method for a Janus gateway provided by the present application can be used to process access requests, search requests, file download requests, authentication requests, payment requests, push notification requests, location requests, recommendation requests, etc. The present application does not limit the specific request types.
[0041] The above-mentioned request processing method for the Janus gateway can be executed by a network device, which can be a Janus gateway.
[0042] The above is only an exemplary description of the application scenario of the present application, and does not constitute a limitation on the application scenario of the present application. In more possible implementation manners, the present application can be applied to other various types of request processing processes.
[0043] After introducing the application scenario of the present application, next, in combination with the embodiments of the present application, the request processing method provided by the present application for the Janus gateway will be described in detail.
[0044] As Figure 1 shown, Figure 1 FIG. is a flowchart of a request processing method for a Janus gateway according to an exemplary embodiment of the present application. The method includes the following steps:
[0045] Step 101, in response to receiving a request from a client, determine a target service for processing the request.
[0046] In some embodiments, the Janus gateway can be associated with multiple types of services, so that service discovery can be performed among the multiple associated services to determine a target service for processing a client request.
[0047] Optionally, the services associated with the Janus gateway can include payment services, search services, storage services, computing services, communication services, security services, etc. The target service can be any one of the services associated with the Janus gateway, and the present application does not limit the specific service type.
[0048] Step 102, based on the service registration lists obtained from multiple service registries, determine a target service node for providing the target service from multiple service clusters corresponding to the multiple service registries; wherein, for any service cluster, the service registration list records the service registration information of the service cluster, and the service registration information is used to indicate the services provided by the service cluster and the service node configuration of the service cluster.
[0049] It should be noted that in the present application, the Janus gateway can provide the access capability of multiple registries, or rather, the Janus gateway can support the access of multiple registries. That is, a Janus gateway can be configured with multiple service registries, and a Janus gateway can support service discovery from different service registries.
[0050] Optionally, different service registries can be used to provide service registration and service discovery functions for different service clusters, and different service clusters can be used to provide different types of services.
[0051] Step 103: Forward the request to the target service node.
[0052] By forwarding the request to the target service node for providing the target service, the target service node can process the request to meet the processing requirements of the request.
[0053] In this application, when the Janus gateway receives a request from a client, the target service for processing the request is determined, so that based on the service registration list obtained from multiple service registration centers, the target service node for providing the target service is determined from multiple service clusters corresponding to the multiple service registration centers, and then the request is forwarded to the target service node to implement the processing of the request. Among them, for any service cluster, the service registration list records the service registration information of the service cluster, and the service registration information is used to indicate the services provided by the service cluster and the service node configuration of the service cluster, broadening the service discovery method, so that Janus can not only implement service discovery based on the network address, but also implement service discovery according to other service registration information in multiple service registration centers, thereby improving the success rate and efficiency of request processing.
[0054] After introducing the basic implementation process of this application, various non-limiting implementation manners of this application will be specifically introduced below.
[0055] In some embodiments, for step 101, when determining the target service for processing the request in response to receiving a request from a client, the following steps may be included:
[0056] Step 1011: In response to receiving a request from a client, obtain the request parameters carried by the request.
[0057] In a possible implementation manner, after the Janus gateway receives a request from a client, the received request can be parsed to parse out the request parameters carried by the request.
[0058] Step 1012: Based on the request parameters, obtain the service identifier of the target service for processing the request.
[0059] Optionally, the request parameters can be used to indicate the domain name to be accessed by the request, so that the service identifier of the target service for processing the request can be determined according to the domain name indicated by the request parameters.
[0060] Among them, the request parameters can be host parameters, but are not limited thereto. The request parameters can also be other types of parameters, and this application does not limit the parameter type of the request parameters.
[0061] Optionally, the service identifier may be the service name, but is not limited thereto. The service identifier may also be in other forms.
[0062] After determining the target service for processing the request through the above embodiments, step 102 can be used to determine the target service node for providing the target service from multiple service clusters corresponding to multiple service registration centers based on the service registration list obtained from multiple service registration centers.
[0063] It should be noted that to ensure that the Janus gateway in this application can provide the access capability of multiple registration centers, multiple service registration centers can be pre-configured in Janus. That is, before step 101, step 100 can also be included, which is to configure multiple service registration centers in the Janus gateway.
[0064] In some embodiments, for step 100, the process of configuring multiple service registration centers in the Janus gateway can be implemented through the following steps:
[0065] Step 100A: In response to the configuration instruction, add the service registration information of multiple service registration centers in the Janus gateway.
[0066] Optionally, the configuration instruction can be triggered based on the user's configuration operation on the Janus gateway.
[0067] Among them, the service registration information may include the network address, username, and password of the service registration center, but is not limited thereto. The service registration information may also include more information, and this application does not limit the type of information included in the service registration information.
[0068] Optionally, the service registration center may be a consul cluster, or the service registration center may be an eureka cluster, but is not limited thereto. This application does not limit the specific type of the service registration center.
[0069] Taking the service registration center as a consul cluster as an example, the service registration information of the service registration center may be the cluster address, username, password, etc. of the consul cluster. Taking the service registration center as an eureka cluster as an example, the service registration information of the service registration center may be the cluster address, username, password, etc. of the eureka cluster.
[0070] Step 100B: Add a service discovery function in the Janus gateway. The service discovery function is used for the Janus gateway to implement service discovery based on the service registration information in multiple service registration centers.
[0071] In a possible implementation manner, the upstream service of the Janus gateway can be configured to discover from the service registration center to configure the service discovery function in the Janus gateway.
[0072] It should be noted that through Step 1, the service registration information of multiple service registration centers has been configured in the Janus gateway. Then, through Step 2, the upstream service of the Janus gateway is configured to discover from the service registration center, so that the Janus gateway can perform service discovery among the multiple configured service registration centers to obtain the service registration information from multiple service registration centers.
[0073] See Figure 2 , Figure 2 is an interaction flowchart of a Janus gateway and a service registration center shown according to an exemplary embodiment of the present application. As Figure 2 shown, a service can be registered in the service registration center and report a heartbeat to the service registration center regularly, so that the service registration center can monitor the running status of the service based on the heartbeats reported by each service; the Janus gateway can pull the service registration list from multiple service registration centers respectively, so that it can process the requests sent by the client based on the pulled service registration list.
[0074] Through the above embodiments, when configuring the upstream service, there is no need to fix the network address of the upstream service, but instead, the service discovery function is configured. In this way, even if the service registration information of the service cluster changes, the Janus gateway can still obtain the latest service configuration information from the service registration center through the service discovery function to implement service node determination, so as to ensure that requests can still be processed normally when the network address of the upstream service changes, and there is no need to rebind the upstream service.
[0075] Optionally, the process of configuring multiple service registration centers in the Janus gateway can be implemented through the Janus control console, but it is not limited to this, and other entities can also be used to configure multiple service registration centers in the Janus gateway.
[0076] It should be noted that different service registration centers can correspond to different service clusters, or rather, the relationship between the service registration center and the service cluster can be one-to-one or one-to-many. One service registration center can provide service registration and service discovery capabilities for at least one service cluster.
[0077] Optionally, the service registration center can maintain a service registration list corresponding to the service cluster. The service registration list records the service registration information of the service cluster, and the service registration information can be used to indicate the services provided by the service cluster and the service node configuration of the service cluster, so that the service registration center can maintain the services provided by the service cluster by maintaining the service registration list.
[0078] In the case where multiple service registration centers are configured for the Janus gateway through the above embodiments, the Janus gateway can separately pull service registration lists from multiple service registration centers and cache the pulled service registration lists.
[0079] Optionally, whenever a service registration center is configured in the Janus gateway, the Janus gateway can pull the service registration list from this configured service registration center and cache the pulled service registration list locally, and so on, so that the Janus gateway can pull service registration lists of multiple service registration centers and complete the caching of the pulled multiple service registration lists.
[0080] By caching the service registration list locally, the Janus gateway can directly perform service discovery through the service registration list in the cache without having to interact with the service registration center frequently.
[0081] In some embodiments, for step 102, when determining a target service node for providing a target service from multiple service clusters corresponding to multiple service registration centers based on the service registration lists obtained from the multiple service registration centers, the following steps may be included:
[0082] Step 1021: Based on the service registration list, determine a target service cluster for providing the target service from multiple service clusters, and determine the multiple service nodes included in the target service cluster as candidate service nodes.
[0083] It should be noted that for any service cluster, the service registration information may include the service identifier of the service provided by the service cluster and the network addresses of the service nodes included in the service cluster, but is not limited thereto, and the service registration information may also include more types of information.
[0084] Among them, the service identifier may be the service name, but is not limited thereto, and the service identifier may also be in other forms, as long as the service identifier can uniquely identify a type of service.
[0085] Taking the service registration information including the service identifier provided by the service cluster and the network addresses of the service nodes included in the service cluster as an example, the above step 1021 can be implemented through the following steps:
[0086] Step 1021A: Based on the service registration list, determine a target service cluster from multiple service clusters whose provided service identifier matches the service identifier of the target service.
[0087] Taking the service identifier as the service name as an example, it is possible to match the service name included in the service registration information in the service registration list with the service name of the target service, so as to determine a service cluster whose provided service name is the same as that of the target service as the target service cluster.
[0088] Step 1021B: Determine multiple service nodes included in the target service cluster as candidate service nodes, and obtain the network addresses of the candidate service nodes.
[0089] It should be noted that the target service cluster may include multiple service nodes, and these multiple service nodes can all be determined as candidate service nodes, so that the target service node can be determined among these multiple candidate service nodes.
[0090] Optionally, the network addresses of these multiple candidate service nodes can be obtained, so that subsequent processing can be performed based on the obtained network addresses.
[0091] Step 1022: Determine a target service node for processing the request from multiple candidate service nodes according to the load balancing policy.
[0092] By using the load balancing policy to determine a target service node for processing the request from multiple candidate service nodes, the request can be evenly distributed to multiple service nodes, improving the performance, reliability and scalability of the system, enabling each service node to effectively process and respond to the request, and avoiding the situation where one service node is overloaded resulting in performance degradation or service unavailability.
[0093] After determining the target service node through the above embodiments, the request can be forwarded to the target service node through step 103.
[0094] It should be noted that since the network addresses of the candidate service nodes have been obtained, and the target service node is determined from the candidate service nodes, the network address of the target service node has also been obtained. Therefore, when forwarding the request to the target service node, the request can be forwarded to the target service node according to the network address of the target service node for the target service node to process the request.
[0095] Through the above embodiments, the access capability of multiple service registration centers can be provided. A Janus gateway can be configured with multiple service registration centers and can be configured to perform service discovery from different service registration centers to implement request processing.
[0096] In more possible implementation manners, the present application can also support more complex routing policies and can support customizing routing matching conditions according to actual requirements.
[0097] Optionally, a visualization interface may be provided to provide the function of customizing routing matching conditions through the visualization interface. For example, a first configuration interface may be provided so that users can customize routing matching conditions through the first configuration interface.
[0098] Optionally, the result of performing a specified expression operation on a certain or certain request parameters may be used as a routing matching condition, and the specified expression may be a custom routing expression set through the first configuration interface.
[0099] In some embodiments, the process of customizing a routing expression to implement the configuration of the routing expression may include the following steps:
[0100] Step 1: Provide a first configuration interface, which includes a parameter definition control and an expression setting control.
[0101] In a possible implementation, the Janus control console may display the routes corresponding to multiple service clusters, and users can select the route for which they want to customize the expression according to actual needs. The Janus control console may display the first configuration interface corresponding to the selected route in response to a selection operation on any of the multiple displayed routes.
[0102] Among them, the parameter definition control can be used to set the parameter position and parameter name of the request parameters involved in the routing expression, and the expression setting control can be used to set the specific routing expression, such as the operation relationship between the request parameters and other parameters in the routing expression, the expected parameter value, and the comparison relationship between the expected parameter value and the operation result of the request parameters and other parameters.
[0103] Optionally, taking a request as an HTTP (Hyper Text Transfer Protocol) request as an example, the parameter position may be a request header (header), or the parameter position may be a query parameter (query param), or the parameter position may be any parameter in the request body (body), and the present application does not limit this.
[0104] See Figure 3 , Figure 3 is a schematic diagram of an interface of a first configuration interface shown according to an exemplary embodiment of the present application. As Figure 3 shown, the parameter definition control may include an input control labeled "parameter position" in text and a request control labeled "parameter name" in text, and the expression setting control may include an input control labeled "custom expression" in text, an input control labeled "operator" in text, and an input control labeled "parameter value" in text.
[0105] Among them, the input control labeled with "parameter position" can be used to input the position of the request parameter. For example, according to the settings shown in Figure 3 , in the input control labeled with "parameter position", input "HTTP request header" to set the request parameter whose position is in the HTTP request in the request to the request parameter involved in the routing expression; the input control labeled with "parameter name" can be used to input the name of the request parameter. For example, according to the settings shown in Figure 3 , in the input control labeled with "parameter name", input "id" to set the request parameter named id in the request to the parameter involved in the routing expression; the input control labeled with "custom expression" can be used to input a self-defined routing expression. For example, according to the settings shown in Figure 3 , in the input control labeled with "custom expression", input "(? + 2) / 2" to achieve the customization of the routing expression; the input control labeled with "operator" can be used to input the logical operation relationship between the operation result of the self-defined routing expression and the expected parameter value. For example, according to the settings shown in Figure 3 , in the input control labeled with "operator", input "greater than (>)" to set the logical operation relationship between the operation result of the routing expression and the expected parameter value to that the operation result is greater than the expected parameter value; the input control labeled with "parameter value" can be used to input the expected parameter value. For example, according to the settings shown in Figure 3 , in the input control labeled with "parameter value", input "3" to set the expected parameter value to 3.
[0106] In more possible implementation manners, a switch setting control for self-setting whether to enable the custom expression function can also be provided. As shown in Figure 3 , the setting control labeled with "custom expression enable" is the switch setting control. By providing two options of "enable" and "disable" in this control, users can set whether to enable the custom expression function according to actual needs.
[0107] Step 2: Generate a routing expression based on the request parameters received by the parameter definition control and the expression received by the expression setting control.
[0108] After the setting of the custom expression is implemented through the above steps, the routing expression can be generated according to the set custom expression.
[0109] Through the above embodiments, more and more complex routing strategies can be supported to more comprehensively apply the advanced matching parameter capabilities of the Janus gateway to cope with more complex application scenarios (such as scenarios like gray release and traffic isolation).
[0110] For example, an operation can be performed on a certain parameter in the HTTP request header, query param, or body, and the operation result can be logically operated with the expected parameter value. The result of the logical operation can be used as the routing matching strategy. For example, in the header, there is a parameter with the key "id". The routing measurement can be to take the modulus of the parameter value by 10 to perform the operation, compare the obtained operation result with 2. If it is greater than 2, this route is hit; if it is less than or equal to 2, it is not hit.
[0111] For another example, for a route, the modulus can be taken on the "cityCode" field in the request parameters. If the modulus result is greater than 3, it may be a non-A region. Through this routing matching measurement, it can be ensured that the traffic in the non-A region hits this route.
[0112] Optionally, after customizing the routing expression through the above embodiments, the request can be routed and matched based on the defined routing expression.
[0113] It should be noted that different services correspond to different routes. Therefore, in some embodiments, when responding to a request received from a client and determining the target service for processing the request, the request can be routed and matched based on a pre-configured routing expression in response to receiving the client's request to obtain a routing matching result; and then based on the routing matching result, the service corresponding to the matched route can be determined as the target service for processing the request.
[0114] By expanding the custom expression function, the user can customize a routing expression on a route according to the specified request parameters. The Janus gateway can perform operations based on the request parameters and the routing expression, and the operation result can be logically operated with the expected parameter value. If the result of the logical operation is true, the matching condition is satisfied and this route is hit; otherwise, the matching condition is not satisfied and this route is not hit.
[0115] In more possible implementation manners, as the upstream entry of the traffic, the Janus gateway can also perform unified authentication on requests from different clients.
[0116] That is, in response to receiving a request from a client, the Janus gateway can authenticate the request.
[0117] In some embodiments, when authenticating a request in response to receiving a request from a client, the Janus gateway can, in response to receiving the client's request, obtain the signature information carried by the request; and based on the signature information, obtain the authentication result of the request from the application authentication center.
[0118] Optionally, after receiving a request from the client, the Janus gateway can parse the request to obtain the signature information carried by the request.
[0119] Optionally, when obtaining the authentication result of the request from the application authentication center based on the signature information, the signature information can be re-encapsulated based on the communication protocol, and the information obtained after encapsulation is sent to the application authentication center, so as to interact with the application authentication center based on the encapsulated information to obtain the authentication result of the request.
[0120] Among them, the communication protocol can be the open-source Remote Procedure Calls (gRPC) protocol, but is not limited thereto. The present application does not limit the specific type of the communication protocol.
[0121] Optionally, the signature information carried by the client can be generated according to a signature algorithm agreed in advance with the application authentication center. The signature algorithm can be any signature algorithm, and the embodiments of the present application do not limit this.
[0122] Optionally, if the request passes the authentication, determine the target service for processing the request; if the request fails the authentication, an error prompt can be sent.
[0123] Among them, the error prompt can be an error code and / or error message, and the error prompt can be user-defined.
[0124] In more possible implementation manners, if the request passes the authentication, the authentication result of the request can be cached so that when the same type of request is received again, the cached authentication result is used as the authentication result of the request received again.
[0125] Optionally, the cached authentication result can have a valid time. Within the valid time of the cached authentication result, the cached authentication result can be directly used to authenticate the same type of request received, without requesting the application authentication center for authentication. Once the valid time is exceeded, the cached authentication result can be automatically discarded.
[0126] Optionally, a hot-pluggable authentication plugin can be abstracted in the Janus gateway to determine whether the client initiating the request has the permission to initiate a request to the service provider (i.e., the service cluster). Among them, the authentication plugin can be the yumc-cloud-auth plugin, but is not limited thereto. The present application does not limit the specific type of the authentication plugin.
[0127] See Figure 4 , Figure 4 is a schematic flow diagram of an authentication process shown by the present application according to an exemplary embodiment. As Figure 4As shown, the client will carry signature information in the requests it sends. After the request reaches the Janus gateway, the authentication plugin yumc-cloud-auth of Janus will process the request. This plugin will parse the signature information in the request and interact with the application authentication center using the gRPC protocol to determine whether the application has the permission to access the service provider. If the authentication passes, this plugin will cache the authentication result of the application with an expiration time, so that the next application request will directly pass the authentication. If the authentication fails, an error code and / or error message can be returned.
[0128] In more possible ways, when the authentication plugin is unavailable, the user can also set the Janus gateway to skip authentication. That is, when the authentication plugin is unavailable, the Janus gateway can refrain from authenticating requests, enabling requests to access the service provider without the request being unable to be processed normally due to a failure of the authentication plugin.
[0129] In some embodiments, the solution provided by this application can also dynamically control the monitoring situation of the Janus gateway at the routing level. For example, a total metric collection switch can be configured in the Janus gateway, and in addition, a metric collection switch can be configured for each route of the Janus gateway.
[0130] Through the above configuration method, it is convenient for users to uniformly control whether to collect metric data on all routes through the total metric collection switch. In addition, users can also select the metric collection switches that need to be enabled according to actual needs, so that the Janus gateway can collect metrics on the routes where the status of the metric collection switch is enabled to obtain the metric data corresponding to this route.
[0131] Optionally, for a certain route, after enabling the corresponding metric collection switch, it is also possible to set whether to collect metric data of the first-level path. Among them, a service can include multiple sub-services, and the first-level path is a certain sub-service corresponding to the service.
[0132] For example, it is possible to set whether to enable according to the context first-level path or whether to carry the IP address information of the upstream node to set whether to collect metric data of the first-level path.
[0133] It should be noted that if it is necessary to collect metric data of the first-level path, it can be set to enable according to the context first-level path or carry the IP address information of the upstream node; if it is not necessary to collect metric data of the first-level path, it can be set to not enable according to the context first-level path or not carry the IP address information of the upstream node.
[0134] For example, for Service 1, which can include multiple sub-services, if it is set to collect metric data for the first-level path, the metric data of a certain sub-service in Service 1 can be collected. If it is set to not collect metric data for the first-level path, then all the metric data of Service 1 will be collected.
[0135] Optionally, the prometheus plugin function can be enabled in the Janus gateway to implement metric collection through the prometheus plugin function.
[0136] It should be noted that the Janus gateway can provide a metric collection interface so that the Janus gateway can implement metric collection through the exposed metric collection interface.
[0137] In more possible implementation manners, the collected metric data can be displayed or alarmed through the Grafana platform.
[0138] See Figure 5 , Figure 5 is a flowchart showing a metric collection process according to an exemplary embodiment of the present application. As Figure 5 shown, the prometheus plugin function can be enabled on the Janus gateway, and it is configured whether to enable the metric collection function on the specific route, and it is set whether to collect metric data for the first-level path. Thus, according to the configured settings, metric collection is performed through the metric collection interface exposed on the Janus gateway, and the collected metrics can be displayed or alarmed through the Grafana platform.
[0139] In more possible implementation manners, the Janus gateway can also provide a reset interface so that the historical collected metric data can be cleared and reset through the exposed reset interface of the Janus gateway.
[0140] Corresponding to the embodiment of the foregoing method, the present application also provides an embodiment of an apparatus and a network device to which it is applied.
[0141] As Figure 6 shown, Figure 6 is a block diagram of a request processing apparatus for a Janus gateway according to an exemplary embodiment of the present application. The apparatus includes:
[0142] A determination module 601, configured to determine a target service for processing a request in response to receiving a request from a client;
[0143] The determination module 601 is further configured to determine, based on the service registration lists obtained from multiple service registration centers, target service nodes for providing a target service from multiple service clusters corresponding to the multiple service registration centers; wherein, for any service cluster, the service registration list records the service registration information of the service cluster, and the service registration information is used to indicate the services provided by the service cluster and the service node configuration of the service cluster.
[0144] The sending module 602 is configured to forward the request to the target service node.
[0145] In some embodiments, when the determination module 601 is configured to determine, based on the service registration lists obtained from multiple service registration centers, target service nodes for providing a target service from multiple service clusters corresponding to the multiple service registration centers, it is configured to:
[0146] Based on the service registration lists, determine a target service cluster for providing the target service from the multiple service clusters, and determine the multiple service nodes included in the target service cluster as candidate service nodes;
[0147] According to the load balancing policy, determine the target service node for processing the request from the multiple candidate service nodes.
[0148] In some embodiments, for any service cluster, the service registration information at least includes the service identifier of the service provided by the service cluster and the network addresses of the service nodes included in the service cluster;
[0149] When the determination module 601 is configured to determine, based on the service registration lists, a target service cluster for providing the target service from the multiple service clusters, and determine the multiple service nodes included in the target service cluster as candidate service nodes, it is configured to:
[0150] Based on the service registration lists, determine a target service cluster from the multiple service clusters whose provided service identifier matches the service identifier of the target service;
[0151] Determine the multiple service nodes included in the target service cluster as candidate service nodes, and obtain the network addresses of the candidate service nodes.
[0152] In some embodiments, when the sending module 602 is configured to forward the request to the target service node, it is configured to:
[0153] Forward the request to the target service node according to the network address of the target service node.
[0154] In some embodiments, the apparatus further includes:
[0155] The pulling module is configured to pull the service registration lists from multiple service registration centers respectively;
[0156] The first storage module is used to cache the pulled service registration list.
[0157] In some embodiments, multiple service registration centers are pre-configured in the Janus gateway, and different service registration centers correspond to different service clusters;
[0158] Among them, the process of configuring multiple service registration centers in the Janus gateway includes:
[0159] In response to a configuration instruction, add service registration information of multiple service registration centers in the Janus gateway;
[0160] Add a service discovery function in the Janus gateway, and the service discovery function is used for the Janus gateway to implement service discovery based on the service registration information in multiple service registration centers.
[0161] In some embodiments, the determination module 601, when used to determine a target service for processing a request in response to receiving a request from a client, is used for:
[0162] In response to receiving a request from a client, obtain the request parameters carried by the request;
[0163] Based on the request parameters, obtain the service name of the target service for processing the request.
[0164] In some embodiments, different services correspond to different routes;
[0165] The determination module 601, when used to determine a target service for processing a request in response to receiving a request from a client, is used for:
[0166] In response to receiving a request from a client, perform route matching based on a pre-configured route expression to obtain a route matching result;
[0167] Based on the route matching result, determine the service corresponding to the matched route as the target service for processing the request.
[0168] In some embodiments, the process of obtaining the route expression includes:
[0169] Provide a first configuration interface, and the first configuration interface includes a parameter definition control and an expression setting control;
[0170] Based on the request parameters received by the parameter definition control and the expression received by the expression setting control, generate a route expression.
[0171] In some embodiments, the process of providing the first configuration interface includes:
[0172] Display the routes corresponding to multiple service clusters;
[0173] In response to a selection operation on any one of the multiple displayed routes, a first configuration interface corresponding to the selected route is displayed.
[0174] In some embodiments, the request carries signature information;
[0175] The apparatus further includes an authentication module, and the authentication module is configured to:
[0176] In response to receiving a request from a client, obtain the signature information carried by the request;
[0177] Based on the signature information, authenticate the request;
[0178] If the request passes the authentication, determine the target service for processing the request; otherwise, send an error prompt.
[0179] In some embodiments, the apparatus further includes:
[0180] A second storage module, configured to cache the authentication result of the request if the request passes the authentication, so that when the request is received again, the cached authentication result is used as the authentication result of the request received again.
[0181] In some embodiments, different services correspond to different routes, and each route of the Janus gateway has a metric collection switch;
[0182] The apparatus further includes:
[0183] A collection module, configured to collect metrics on a route where the status of the metric collection switch is on to obtain metric data.
[0184] For the implementation processes of the functions and roles of each module in the above apparatus, please refer to the implementation processes of the corresponding steps in the above method for details, which will not be elaborated here.
[0185] For the apparatus embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to the partial descriptions of the method embodiments. The apparatus embodiments described above are only illustrative. The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical modules, that is, they may be located in one place, or may be distributed to multiple network modules. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of the present application. Those of ordinary skill in the art can understand and implement it without creative efforts.
[0186] The present application further provides a network device. Please refer to Figure 7 , Figure 7This is a schematic structural diagram of a network device shown according to an exemplary embodiment of the present application. As Figure 7 shown, the network device includes a processor 710, a memory 720, and a network interface 730. The memory 720 is used to store computer instructions that can run on the processor 710. The processor 710 is used to implement the request processing method for the Janus gateway provided in any embodiment of the present application when executing the computer instructions. The network interface 730 is used to implement input and output functions. In more possible implementation manners, the network device may further include other hardware, which is not limited in the present application.
[0187] The present application also provides a computer-readable storage medium. The computer-readable storage medium can be in various forms. For example, in different examples, the computer-readable storage medium can be: RAM (Random Access Memory), volatile memory, non-volatile memory, flash memory, storage drives (such as hard disk drives), solid-state drives, any type of storage disk (such as optical discs, DVDs, etc.), or similar storage media, or a combination thereof. Specifically, the computer-readable medium can also be paper or other suitable media capable of printing programs. A computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, it implements the request method for the Janus gateway provided in any embodiment of the present application.
[0188] The present application also provides a computer program product, including a computer program, and when the computer program is executed by a processor, it implements the request method for the Janus gateway provided in any embodiment of the present application.
[0189] Those skilled in the art should understand that one or more embodiments of the present application can be provided as a method, a device, a network device, a computer-readable storage medium, or a computer program product. Therefore, one or more embodiments of the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, one or more embodiments of the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memories, CD-ROMs, optical memories, etc.) containing computer-usable program code.
[0190] Each embodiment in the present application is described in a progressive manner. The same or similar parts among the embodiments can be referred to each other, and the key points of each embodiment are the differences from other embodiments. In particular, for the embodiment corresponding to the network device, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the description of the method embodiment.
[0191] The foregoing describes particular embodiments of the present application. Other embodiments are within the scope of the present application. In some cases, the acts or steps recited in the present application may be performed in a different order than in the embodiments and still achieve the desired result. Additionally, the processes depicted in the figures do not necessarily require the particular order or sequential order shown to achieve the desired result. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0192] Embodiments of the subject matter and the functional operations described in this application can be implemented in: digital electronic circuitry, tangibly embodied computer software or firmware, computer hardware including the structures disclosed in this application and their structural equivalents, or one or more of them in combination. Embodiments of the subject matter described in this application can be implemented as one or more computer programs, i.e., one or more modules of computer program instructions encoded on a tangible non-transitory program carrier to be executed by, or to control the operation of, a data processing apparatus. Alternatively or additionally, the program instructions can be encoded on an artificially generated propagated signal, such as a machine-generated electrical, optical, or electromagnetic signal, generated to encode and transmit information to a suitable receiver apparatus for execution by a requesting apparatus for a Janus gateway. A computer storage medium can be a machine-readable storage device, a machine-readable storage substrate, a random or serial access memory device, or a combination of one or more of them.
[0193] The processes and logical flows described in this application can be performed by one or more programmable computers executing one or more computer programs to perform the corresponding functions by operating on input data and generating output. The processes and logical flows can also be performed by, or the apparatus can be implemented as, special purpose logic circuitry, such as an FPGA (Field Programmable Gate Array) or an ASIC (Application Specific Integrated Circuit).
[0194] Computers suitable for executing computer programs include, for example, general and / or special-purpose microprocessors, or any other type of central processing unit. Generally, the central processing unit will receive instructions and data from read-only memory and / or random access memory. The basic components of a computer include a central processing unit for implementing or executing instructions and one or more memory devices for storing instructions and data. Generally, a computer will also include one or more mass storage devices for storing data, such as magnetic disks, magneto-optical disks, or optical disks, etc., or the computer will be operably coupled to such mass storage devices to receive data therefrom or transfer data thereto, or both. However, a computer is not necessarily required to have such devices. In addition, a computer may be embedded in another device, such as a mobile phone, a personal digital assistant (PDA), a mobile audio or video player, a game console, a global positioning system (GPS) receiver, or a portable storage device such as a universal serial bus (USB) flash drive, to name just a few examples.
[0195] Computer-readable media suitable for storing computer program instructions and data include all forms of non-volatile memory, media, and memory devices, such as including semiconductor memory devices (e.g., EPROM, EEPROM, and flash memory devices), magnetic disks (e.g., internal hard disks or removable disks), magneto-optical disks, and CD ROM and DVD-ROM disks. The processor and memory may be supplemented by, or incorporated in, special purpose logic circuitry.
[0196] Although this application contains many specific implementation details, these should not be construed as limiting the scope of any invention or the scope of what is claimed, but rather as mainly describing the features of specific embodiments of a particular invention. Certain features described in multiple embodiments in this application may also be implemented in combination in a single embodiment. On the other hand, various features described in a single embodiment may also be implemented separately in multiple embodiments or in any suitable sub-combination. In addition, although features may operate in certain combinations as described above and are even initially claimed as such, one or more features from the claimed combination may in some cases be removed from that combination, and the claimed combination may be directed to a sub-combination or a variation of a sub-combination.
[0197] Similarly, although operations are depicted in the drawings in a particular order, this should not be construed as requiring that the operations be performed in the particular order shown or sequentially, or that all illustrated operations be performed, to achieve the desired result. In some cases, multitasking and parallel processing may be advantageous. In addition, the separation of various system modules and components in the above embodiments should not be construed as requiring such separation in all embodiments, and it should be understood that the described program components and systems can generally be integrated together in a single software product or packaged into multiple software products.
[0198] Thus, specific embodiments of the subject matter have been described. Other embodiments are within the scope of the present application. In some cases, the acts recited in this application can be performed in a different order and still achieve the desired results. In addition, the processes depicted in the figures are not necessarily in the particular order or sequential order shown to achieve the desired results. In some implementations, multitasking and parallel processing may be advantageous.
[0199] Those skilled in the art will readily conceive of other embodiments of the present application after considering the specification and practicing the invention herein. This application is intended to cover any variations, uses, or adaptations of the present application that follow the general principles of the present application and include common general knowledge or conventional technical means in the technical field not claimed in this application. That is, this application is not limited to the precise structures described above and shown in the figures, and various modifications and changes can be made without departing from its scope.
[0200] The foregoing are only alternative embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application shall be included within the scope of protection of the present application.
Claims
1. A request processing method for a Janus gateway, characterized in that, the method includes: In response to receiving a request from a client, determining a target service for processing the request; Based on a service registration list obtained from multiple service registration centers, determining a target service node for providing the target service from multiple service clusters corresponding to the multiple service registration centers; wherein, for any service cluster, the service registration list records service registration information of the service cluster, and the service registration information is used to indicate the services provided by the service cluster and the service node configuration of the service cluster; Forwarding the request to the target service node.
2. The method according to claim 1, characterized in that, the determining a target service node for providing the target service from multiple service clusters corresponding to the multiple service registration centers based on a service registration list obtained from multiple service registration centers includes: Based on the service registration list, determining a target service cluster for providing the target service from the multiple service clusters, and determining multiple service nodes included in the target service cluster as alternative service nodes; According to a load balancing policy, determining a target service node for processing the request from the multiple alternative service nodes.
3. The method according to claim 2, characterized in that, for any service cluster, the service registration information at least includes a service identifier of the service provided by the service cluster and a network address of the service nodes included in the service cluster; the determining a target service cluster for providing the target service from the multiple service clusters based on the service registration list and determining multiple service nodes included in the target service cluster as alternative service nodes includes: Based on the service registration list, determining a target service cluster from the multiple service clusters whose provided service identifier matches the service identifier of the target service; Determining multiple service nodes included in the target service cluster as alternative service nodes, and obtaining the network addresses of the alternative service nodes.
4. The method according to claim 1, characterized in that, the multiple service registration centers are pre-configured in the Janus gateway, and different service registration centers correspond to different service clusters; wherein, the process of configuring the multiple service registration centers in the Janus gateway includes: In response to a configuration instruction, adding service registration information of the multiple service registration centers in the Janus gateway; Adding a service discovery function in the Janus gateway, and the service discovery function is used for the Janus gateway to implement service discovery based on the service registration information in the multiple service registration centers.
5. The method according to claim 1, characterized in that, different services correspond to different routes; In response to receiving a request from a client, determining a target service for processing the request includes: In response to receiving a request from a client, performing route matching based on a pre-configured route expression to obtain a route matching result; Based on the routing matching result, determine the service corresponding to the matched route as the target service for processing the request.
6. The method according to claim 5, wherein, the process of obtaining the routing expression includes: providing a first configuration interface, where the first configuration interface includes a parameter definition control and an expression setting control; generating the routing expression based on the request parameters received by the parameter definition control and the expression received by the expression setting control.
7. The method according to claim 6, wherein, the providing of the first configuration interface includes: displaying the routes corresponding to the multiple service clusters; in response to a selection operation on any one of the displayed multiple routes, displaying the first configuration interface corresponding to the selected route.
8. The method according to claim 1, wherein, the request carries signature information; the method further includes: in response to receiving a request from the client, obtaining the signature information carried by the request; performing authentication on the request based on the signature information; if the request passes the authentication, determining the target service for processing the request, otherwise, sending an error prompt.
9. The method according to claim 1, wherein, different services correspond to different routes, and each route of the Janus gateway has an index collection switch; the method further includes: performing index collection on the route where the status of the index collection switch is enabled to obtain index data.
10. A request processing device for a Janus gateway, wherein, the device includes: a determination module, configured to determine a target service for processing the request in response to receiving a request from the client; the determination module is further configured to determine a target service node for providing the target service from the multiple service clusters corresponding to the multiple service registration centers based on the service registration list obtained from the multiple service registration centers; wherein, for any service cluster, the service registration list records the service registration information of the service cluster, and the service registration information is used to indicate the services provided by the service cluster and the service node configuration of the service cluster; a sending module, configured to forward the request to the target service node.
11. A network device, wherein, the network device includes a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor executes the program to implement the operations performed by the request processing method for the Janus gateway according to any one of claims 1 to 9.
12. A computer-readable storage medium, wherein, a program is stored on the computer-readable storage medium, and the program is executed by the processor to implement the operations performed by the request processing method for the Janus gateway according to any one of claims 1 to 9.