Request processing method, cloud service container, electronic equipment and storage medium
By determining the request protocol type and generating response information within the service process, no protocol conversion is required, which solves the compatibility problem between HTTP and RPC protocols, achieves compatible processing of multiple protocols, reduces development workload, and improves operating efficiency.
Patent Information
- Application Number
- CN202411067105.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-05
- Publication Date
- 2026-02-06
AI Technical Summary
In existing technologies, the HTTP protocol and the RPC protocol are incompatible, which makes it impossible to reuse request information in microservice architecture, increasing development workload and operation and maintenance costs.
By determining the protocol type of the request and generating response information in the corresponding protocol format within the service process, no protocol conversion is required; the request and response information can be transmitted directly through the corresponding protocol channel.
It achieves compatibility handling for multiple protocol types, reduces the workload of the development process, and improves the operating efficiency of the architecture.
Smart Images

Figure CN121486473A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present disclosure relate to the communication technology field, and in particular to a request processing method, a cloud service container, an electronic device and a storage medium. BACKGROUND
[0002] At present, the micro-service architecture of the distributed system usually needs to process request information based on the Hypertext Transfer Protocol (HTTP) and the Remote Procedure Call Protocol (RPC).
[0003] However, the HTTP protocol and the RPC protocol are incompatible. If the request processing is based on the RPC service, the request information based on the HTTP protocol needs to be converted into the request information based on the RPC format, and vice versa. For the same kind of request information based on different protocol types, the RPC service or the HTTP service in the micro-service architecture cannot realize the reuse of information, resulting in a large amount of development work. SUMMARY
[0004] The present disclosure provides a request processing method, a cloud service container, an electronic device and a storage medium, which do not need to perform protocol conversion, realize compatible processing of requests corresponding to multiple protocol types, reduce the workload in the development process, and improve the running efficiency of the architecture.
[0005] In a first aspect, the embodiments of the present disclosure provide a request processing method, which comprises:
[0006] determining a first protocol type of a first request;
[0007] transmitting the first request to a service process through a channel corresponding to the first protocol type;
[0008] generating response information of the first request in the service process according to a protocol format corresponding to the first protocol type;
[0009] sending the response information.
[0010] In a second aspect, the embodiments of the present disclosure further provide a cloud service container, which comprises:
[0011] a service processing component configured to determine a first protocol type of a first request, and transmit the first request to a service process through a channel corresponding to the first protocol type;
[0012] a service process configured to generate response information of the first request in the service process according to a protocol format corresponding to the first protocol type, and send the response information.
[0013] In a third aspect, the embodiments of the present disclosure further provide an electronic device, which comprises:
[0014] one or more processing devices;
[0015] a storage device configured to store one or more programs,
[0016] When the one or more programs are executed by the one or more processing devices, the one or more processing devices implement the request processing method provided in the first aspect.
[0017] In a fourth aspect, the embodiments of the present disclosure further provide a storage medium containing computer executable instructions for executing the request processing method provided in the first aspect when executed by a computer processor.
[0018] In the embodiments of the present disclosure, the first protocol type of the first request is determined, the first request is transmitted to a service process through a channel corresponding to the first protocol type, response information of the first request is generated in the service process according to a protocol format corresponding to the first protocol type, and the response information is sent. In the above technical solution, the transmission of the request into the service process is realized based on the corresponding protocol type channel, one service process can detect two ports and process two protocols at the same time, and when the service process processes the request, protocol conversion is not required, the compatible processing of the requests corresponding to multiple protocol types can be realized, the workload in the development process is reduced, and the running efficiency of the architecture is improved. BRIEF DESCRIPTION OF DRAWINGS
[0019] The above and other features, advantages, and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and the original and elements are not necessarily drawn according to the scale.
[0020] Figure 1 is a structural example diagram of a distributed system micro-service architecture provided by the embodiments of the present disclosure;
[0021] Figure 2 is another structural example diagram of a distributed system micro-service architecture provided by the embodiments of the present disclosure;
[0022] Figure 3 is a request processing method flowchart provided by the embodiments of the present disclosure;
[0023] Figure 4 is another request processing method flowchart provided by the embodiments of the present disclosure;
[0024] Figure 5 is a structural schematic diagram of a cloud service container provided by an embodiment of the present disclosure.
[0025] Figure 6 is a structural schematic diagram of a cloud service container provided by an embodiment of the present disclosure.
[0026] Figure 7 is a structural schematic diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0027] Embodiments of the present disclosure will be described in more detail with reference to the drawings. While certain embodiments of the present disclosure will be shown and described below, it is to be understood that the present disclosure can be embodied in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and fully convey the scope of the present disclosure to those skilled in the art.
[0028] It should be understood that each step recited in the method embodiments of the present disclosure can be executed in different orders and / or in parallel. In addition, the method embodiments can include additional steps and / or omit the execution of the steps shown. The scope of the present disclosure is not limited in this respect.
[0029] The term "comprising" and variations thereof as used herein are used inclusively, i.e., "comprising but not limited to." The term "based on" is "based at least in part on." The term "one embodiment" means "at least one embodiment." The term "another embodiment" means "at least one additional embodiment." The term "some embodiments" means "at least some embodiments." Related definitions of other terms will be given in the description below.
[0030] It should be noted that the terms "first", "second", and the like in the present disclosure are merely used to distinguish different devices, modules or units, and do not imply the order or interdependence of the functions performed by these devices, modules or units.
[0031] It should be noted that the terms "one", "multiple" in the present disclosure are illustrative and not restrictive, and those skilled in the art should understand that "one or more" should be understood unless otherwise explicitly indicated in the context.
[0032] The names of the messages or information exchanged between the plurality of devices in the embodiments of the present disclosure are merely for illustrative purposes, and are not intended to limit the scope of the messages or information.
[0033] It can be understood that, before using the technical solutions disclosed in the embodiments of the present disclosure, the type, use range, use scenario, etc. of the personal information involved in the present disclosure should be informed to the user and the authorization of the user should be obtained through appropriate means according to relevant laws and regulations.
[0034] For example, in response to receiving an active request of a user, a prompt information is sent to the user to explicitly prompt the user that the operation requested to be performed will require obtaining and using personal information of the user. Thus, the user can autonomously select whether to provide personal information to the software or hardware such as an electronic device, an application program, a server or a storage medium, etc. performing the operation of the technical solutions of the present disclosure according to the prompt information.
[0035] As an optional but non-limiting implementation manner, in response to receiving an active request of a user, the manner of sending a prompt information to the user may, for example, be a pop-up window manner, and the prompt information may be presented in a text manner in the pop-up window. In addition, the pop-up window may also carry a selection control for the user to select “agree” or “disagree” to provide personal information to the electronic device.
[0036] It can be understood that the above notification and obtaining of user authorization process is only illustrative, and does not limit the implementation manner of the present disclosure, and other manners meeting relevant laws and regulations can also be applied to the implementation manner of the present disclosure.
[0037] It can be understood that the data (including but not limited to the data itself, the acquisition or use of the data) involved in the present technical solutions should comply with the requirements of relevant laws and regulations and relevant provisions.
[0038] In the micro-service architecture of the distributed system, the back-end service needs to provide ports for different scenarios. Different scenarios have different requirements for data transmission efficiency and link quality, so various application layer protocols have been derived, and the most common application layer protocols are Hypertext Transfer Protocol (HTTP) and Remote Procedure Call Protocol (RPC).
[0039] Figure 1 is a structural example diagram of a micro-service architecture of a distributed system provided by an embodiment of the present disclosure. As shown in Figure 1 The micro-service architecture of the distributed system includes a client, an internal service, an HTTP service, a service processing component (MeshProxy), an RPC detection port (RPC Port) and an RPC service.
[0040] As shown in Figure 1In the illustrated distributed system microservice architecture, the client can be a mobile phone software or a WEB site, which needs to use the HTTP protocol and return JSON / PB data; the internal service is a kind of network service, which can correspond to a plurality of different service types. The HTTP service provides an HTTP port, implements the general processing logic of the HTTP gateway, including flow limiting, data injection, etc.; can convert the HTTP request into an RPC request, forward the request, and convert the RPC response data into HTTP data (protocol conversion + request forwarding). The service processing component provides some general service processing capabilities, which can process an HTTP request or an RPC request proxy, and cannot process both requests, which can be allowed to be processed in the HTTP service or the RPC service; if the request is an HTTP protocol, the request is forwarded to the HTTP gateway (HTTPGateway) process for processing; if the request is an RPC protocol, the request is forwarded to the RPC process for processing; the data returned by the HTTP / RPC process is returned. The RPC service is used to receive an RPC request through a PRC detection port; read and write corresponding data from a memory or a database storing data; implement data acquisition code logic; encode the data according to the RPC response format, and return.
[0041] When the request is an HTTP request issued by the client, the interaction process of the microservice architecture is as follows:
[0042] The client sends an HTTP request to the HTTP service through a port; the HTTP service converts the HTTP format request into an RPC format request through the built-in service processing component, and forwards the RPC format request to another service processing component through a port; the request is transmitted through the service processing component, the RPC service obtains the request transferred by the service processing component through an RPC detection port, reads and writes data corresponding to the request information from a memory or a database based on the request, forms an RPC format response information, and returns the response information to the HTTP service through a port; the HTTP service receives the RPC format response information through a port and converts the response information into an HTTP format response information, and returns the HTTP format response information to the client.
[0043] When the request is an RPC request issued by the internal service, the interaction process of the microservice architecture is as follows:
[0044] The internal service directly sends an RPC request through a port, the request is transmitted through a service processing component, the RPC service obtains the request transferred by the service processing component through an RPC detection port, reads and writes data corresponding to the request information from a memory or a database based on the request, forms an RPC format response information, and returns the response information to the internal service through a port.
[0045] The distributed system micro-service architecture based on the forced protocol splitting service may sometimes cause the development efficiency to decrease. Many ports provide the same data from the business perspective of HTTP port and RPC detection port (for example, the ports for obtaining specific information exist in both HTTP / RPC services), but the codes need to be developed in the HTTP service and the RPC service respectively to meet the access requirements of the client and the internal service, in which case, the codes in the HTTP service are usually used to convert the request parameters into the parameters of the RPC service, forward the request to the RPC service, and convert the response data of the RPC service into the data format required by the HTTP to return to the client, which will cost extra time; when the port increases the field or adds a new port, the codes of the HTTP service and the RPC service need to be modified simultaneously, which requires double work based on one problem; the HTTP / RPC two different services need to be deployed and operated online simultaneously, which increases the operation and maintenance cost.
[0046] To solve the above technical problems, an HTTP gateway supporting protocol conversion capability is evolved, the application gateway is responsible for receiving the HTTP request and completing the conversion from the HTTP protocol to the RPC protocol, when the business needs to expose an existing RPC port to the public network, only needs to access the HTTP gateway and perform a small amount of configuration, without modifying the two services.
[0047] Figure 2 Another structure example diagram of the distributed system micro-service architecture provided by the embodiment of the disclosure is shown in the figure. Figure 2 As shown in the figure, it includes a client, an internal service, a service processing component (MeshProxy), an HTTP gateway (HTTPGateway) and an RPC service.
[0048] As shown in the figure, Figure 2 In the distributed system micro-service architecture shown in the figure, the function of the HTTP service is migrated to the HTTP gateway, without retaining a separate HTTP service, the HTTP gateway only processes the HTTP request proxy and does not process the RPC request; the general processing logic of the HTTP gateway is implemented, including flow limiting, data injection, etc.; the HTTP request is converted into the RPC request, the request is forwarded, and the RPC response data is converted into the HTTP data (protocol conversion + request forwarding). The service processing component receives the HTTP request and the RPC request simultaneously, and identifies whether the protocol type of the request is HTTP or RPC; if the request is the HTTP protocol, it is forwarded to the HTTP gateway (HTTPGateway) process for processing; if the request is the RPC protocol, it is forwarded to the RPC service process for processing; the data returned by the HTTP / RPC process is returned to the corresponding request sender.
[0049] The interaction process of the micro-service architecture is:
[0050] The client or internal service sends a corresponding request to the service processing component;
[0051] When the service processing component identifies that the type of the request is the HTTP protocol type sent by the client, the request is sent to the HTTP gateway, the HTTP gateway converts the request into an RPC format request, and sends the RPC format request, the process of the RPC service obtains the RPC format request sent by the HTTP gateway through the RPC detection port, reads and writes the data corresponding to the request information from the memory or the database based on the request, forms the RPC format response information, and returns the response information to the HTTP gateway; the HTTP gateway receives the RPC format response information and converts the response information into an HTTP format response information, and returns the HTTP format response information to the client through the service processing component;
[0052] When the service processing component identifies that the type of the request is the RPC protocol type sent by the internal service, the service processing component transits and transmits the request, the RPC service can directly obtain the RPC request through the RPC detection port, and reads and writes the data corresponding to the request information from the memory or the database based on the request, forms the RPC format response information, and directly returns the response information to the internal service through the service processing component.
[0053] If the distributed system is a newly developed system, Figure 2 The microservice architecture shown can be better applied, which realizes the general logic + protocol conversion + request forwarding capability based on the HTTP gateway, and does not need to develop the HTTP service separately, can effectively reduce the coding work of protocol conversion, and improves the research and development efficiency.
[0054] However, at present, a large number of distributed systems are based on, for example, Figure 1Therefore, the HTTP / RPC services with repeated functions need to be combined to achieve the simplification of the architecture. Although the HTTP / RPC ports logically provide the same information acquisition function, the definitions of the two ports are quite different. In the process of upgrading the online system, the following problems are likely to occur, causing the application gateway to bear a lot of business functions. First, the HTTP and RPC port fields are not completely aligned, and the HTTP gateway needs to do a lot of additional conversion processing. For example, if the response information is a picture, the HTTP service will return the complete URL address, and the RPC service will only return the relative address of the picture, which cannot be directly provided to the client. Second, there is a migration problem of the public code library relied on by the HTTP service. Specifically, there are many business logics in the API public library based on HTTP request information customization. Since the RPC service cannot completely copy the HTTP request context, these functions cannot be smoothly migrated to the RPC service. Third, the functions that the HTTP gateway needs to bear lack standardized definitions, so it often takes a lot of time to determine which functions to put in the application gateway and which functions to put in the RPC service.
[0055] To solve the above technical problems, the embodiment of the disclosure provides a request processing method, Figure 3 A flowchart of a request processing method provided by the embodiment of the disclosure is suitable for the case of processing the obtained service request. The method can be executed by a cloud service container. The container can be implemented in the form of software and / or hardware. Optionally, the container can be implemented by an electronic device, which can be a mobile terminal, a PC terminal, or a server.
[0056] As Figure 3 The method comprises the following steps.
[0057] S110, determining the first protocol type of the first request.
[0058] The first request can be understood as a query request or a processing request, or other types of requests, obtained from the request sender. The request sender can be understood as a terminal or a service that sends the first request, such as a client, an intranet service, or other software or hardware with request generation and sending capabilities. The first protocol type can be understood as the rules and standards used when the first request is sent, including at least HTTP and RPC.
[0059] Specifically, the service processing component in the cloud service container obtains the first request sent by the request sender based on the corresponding communication protocol, and identifies the first protocol type corresponding to the first request.
[0060] The service processing is a process of managing, coordinating and optimizing the interaction between multiple services in a micro-service architecture, aiming to ensure that different services can work efficiently and stably in a distributed environment, thereby improving the scalability, reliability and performance of the overall system.
[0061] S120, transmitting the first request to the service process through a channel corresponding to the first protocol type.
[0062] The channel can be understood as a path in the cloud service platform for transmitting the first request to the service process. It at least includes a transmission path outside the service process and a transmission path on the service process. The transmission path outside the service process can be understood as a gateway, and the transmission path on the service process can be understood as a way for the service process to receive the first request, such as a port or a set communication mechanism. The set communication mechanism can be shared memory or inter-process communication (Unix domain socket), and the present disclosure does not limit it.
[0063] The service process can be understood as a process for processing requests. The service process can process requests of at least two protocol types. The service process can be a hypertext transfer service process based on the hypertext transfer protocol, or a remote procedure call service process based on the remote procedure call protocol. The present embodiment does not limit it.
[0064] Specifically, the protocols supported by the cloud service container have corresponding transmission channels in the cloud service container. After receiving the first request, the service processing component in the cloud service container transmits the first request to the service process through the channel corresponding to the first protocol type. The service process receives the first request through the channel corresponding to the first protocol type.
[0065] For example, after the cloud service container receives the first request, when the first protocol type of the first request is consistent with the service type of the service process, the service processing component in the cloud service container directly sends the first request to the service process based on the original channel corresponding to the service; when the first protocol type of the first request is inconsistent with the service type of the service process, the service processing component in the cloud service container sends the first request to the port corresponding to the first protocol type on the service process through the gateway corresponding to the first protocol type, and transmits the first request to the service process through the port.
[0066] S130, generating response information of the first request in the service process according to the protocol format corresponding to the first protocol type.
[0067] The response information of the first request can be understood as information obtained by the service process based on the first request after processing the first request.
[0068] Specifically, after receiving the first request, the service process in the cloud service container processes the first request based on the first request, and encapsulates the processing result into a protocol format corresponding to the first protocol type to form the final response information.
[0069] For example, when the first request is a query request, the service process accesses a corresponding database based on a query instruction contained in the first request to perform a corresponding query operation and obtain a query result. When the first protocol type of the first request is the hypertext transfer protocol, the query result is encapsulated into a query result in the hypertext transfer protocol format as the response information of the first request.
[0070] S140, sending the response information.
[0071] Specifically, the response information is returned to the request issuer of the first request via the original path.
[0072] For example, in the cloud service container, when the first protocol type is consistent with the service type of the service process, the service process directly sends the response information to the service processing component based on the original channel corresponding to the service, and the service processing component returns the response information to the request issuer of the first request outside the cloud service container; when the first protocol type is inconsistent with the service type of the service process, the service process transmits the response information to the corresponding gateway via a port corresponding to the protocol type of the response information, and the gateway transmits the response information to the service processing component, and finally the service processing component returns the response information to the request issuer of the first request outside the cloud service container.
[0073] The technical scheme of the embodiment of the disclosure includes determining a first protocol type of a first request; transmitting the first request to a service process via a channel corresponding to the first protocol type; generating, in the service process, response information of the first request in a protocol format corresponding to the first protocol type; and sending the response information. In the above technical scheme, the transmission of the request into the service process is realized based on the corresponding protocol type channel, one service process simultaneously detects two ports and processes two protocols, and when the service process processes the request, protocol conversion is not required, the compatible processing of the requests corresponding to multiple protocol types can be realized, the workload in the development process is reduced, and the running efficiency of the architecture is improved.
[0074] On the basis of the above embodiment, a variant embodiment of the above embodiment is proposed. It should be noted that, in order to make the description brief, only the differences between the variant embodiment and the above embodiment are described in the variant embodiment.
[0075] In one embodiment, the first protocol type comprises a hypertext transfer protocol or a remote procedure call protocol; the service process is a process of a remote procedure call service, and accordingly, the transmitting the first request to the service process through a channel corresponding to the first protocol type comprises:
[0076] S1201, in the case where the first protocol type is a hypertext transfer protocol, transmitting the first request to a process of a remote procedure call service through a hypertext transfer gateway.
[0077] The hypertext transfer gateway can be understood as a gateway based on the hypertext transfer protocol, i.e., an HTTP gateway. The remote procedure call service can be understood as a service based on the remote procedure call protocol, i.e., an RPC service. The RPC service is a collection of remotely callable functions or methods, which defines operations that can be requested by remote clients to execute and related input and output parameters. The process of the remote procedure call service, i.e., the RPC service process, can be understood as a program instance that actually runs and processes remote call requests (the first request).
[0078] Specifically, the distributed system micro-service architecture (or cloud service container) employed by the embodiments of the present disclosure supports both the hypertext transfer protocol and the remote procedure call protocol. When the service process is a process of a remote procedure call service (the RPC service process), the request based on the remote procedure call protocol can be directly transmitted to the RPC service process through a detection port or other communication mechanism on the RPC service process, and therefore, there is no need to set a corresponding gateway. The request based on the hypertext transfer protocol cannot be directly discovered by the original RPC detection port or other communication mechanism on the RPC service process, and therefore, an HTTP gateway and an HTTP detection port or other communication mechanism based on the hypertext transfer protocol are set on the RPC service process, so that the RPC service process can obtain the request information based on the hypertext transfer protocol.
[0079] Specifically, when the first protocol type of the first request is the hypertext transfer protocol and the service process is a process of a remote procedure call service, the service processing component forwards the first request through a hypertext transfer gateway, and the RPC service process obtains the first request based on the hypertext transfer protocol through an HTTP detection port or other communication mechanism.
[0080] S1202, in the case where the first protocol type is a remote procedure call protocol, transmitting the first request to the process of the remote procedure call service.
[0081] Specifically, when the service process is a process serving remote procedure calls (RPC service process), the request based on the remote procedure call protocol can be directly transmitted to the RPC service process through a detection port or other communication mechanism on the RPC service process. Therefore, when the first protocol type of the first request is the remote procedure call protocol and the service process is a process serving remote procedure calls, the service processing component transmits the first request, and the RPC service process obtains the first request based on the remote procedure call protocol through the RPC detection port or other communication mechanism.
[0082] In one embodiment, the first protocol type includes a hypertext transfer protocol or a remote procedure call protocol; the service process is a process serving hypertext transfer; accordingly, the transmitting the first request to the service process through a channel corresponding to the first protocol type includes:
[0083] S1203, in the case where the first protocol type is a hypertext transfer protocol, transmitting the first request to a process serving hypertext transfer through a hypertext transfer gateway.
[0084] The process serving hypertext transfer can be understood as a service based on the hypertext transfer protocol, that is, an HTTP service. The process serving hypertext transfer, that is, the HTTP service process, can be understood as a program instance that actually runs and processes the first request.
[0085] Specifically, the distributed system micro-service architecture (or cloud service container) adopted by the embodiments of the present disclosure supports two protocols, the remote procedure call protocol and the hypertext transfer protocol. When the first protocol type of the first request is the hypertext transfer protocol and the service process is a process serving hypertext transfer (HTTP service process), the service processing component forwards the first request through a hypertext transfer gateway, and the HTTP service process obtains the first request based on the hypertext transfer protocol through an HTTP detection port or other communication mechanism.
[0086] S1204, in the case where the first protocol type is a remote procedure call protocol, transmitting the first request to the process serving hypertext transfer.
[0087] Specifically, when the first protocol type of the first request is the remote procedure call protocol and the service process is a process serving hypertext transfer (HTTP service process), the service processing component transmits the first request, and the HTTP service process obtains the first request based on the remote procedure call protocol through an RPC detection port or other communication mechanism.
[0088] Figure 4 is another request processing method flowchart provided by the embodiments of the present disclosure, as shown in Figure 4 The method includes:
[0089] S210, determine a first protocol type of a first request.
[0090] S220, transmit the first request to a service process through a channel corresponding to the first protocol type.
[0091] S230, generate response information of the first request in a protocol format corresponding to the first protocol type in the service process.
[0092] S240, send the response information.
[0093] S250, generate response information of the requested content of the first request in a protocol format corresponding to a second protocol type, the second protocol type including protocol types supported by the service process other than the first protocol type.
[0094] The second protocol type can be understood as a rule and standard of data transmission, at least including the Hypertext Transfer Protocol HTTP and the Remote Procedure Call Protocol RPC. The second protocol type includes other protocol types supported by the service process other than the first protocol type, for example, when the protocol types supported by the service process include the Hypertext Transfer Protocol and the Remote Procedure Call Protocol, and the first protocol type is the Hypertext Transfer Protocol, the second protocol type is the Remote Procedure Call Protocol, and vice versa. It can be understood that the protocol types supported by the service process are not only the above two protocols, and the second protocol type can include at least one type.
[0095] Specifically, when the service process in the cloud service container receives the first request sent by the request sender, processes the request based on the first request, and forms the corresponding processing result, in addition to generating response information in the corresponding format of the processing result according to the first request, for the same function and same field port, the response information in the protocol format corresponding to the second protocol type can also be generated based on the request content of the first request and stored for subsequent demand.
[0096] For example, when the protocol types supported by the service process include the Hypertext Transfer Protocol and the Remote Procedure Call Protocol, the first request is an image query request, and the first protocol type corresponding to the first request is the Hypertext Transfer Protocol, in addition to generating response information based on the Hypertext Transfer Protocol for the image query request, response information based on the Remote Procedure Call Protocol can also be generated and stored.
[0097] Specifically, the service process performs request processing based on the first request, forms a corresponding processing result, generates response information based on the first protocol type, and for ports with the same function and field, can directly store the processing result in a code file, and when a request based on the second protocol type is subsequently received, generates corresponding response information based on the corresponding protocol format.
[0098] In one embodiment, the method further comprises:
[0099] In a case where the second request of the second protocol type is acquired, the response information corresponding to the second request is acquired and transmitted, and the requested content of the second request is the same as the requested content of the first request.
[0100] The second request can be understood as request information of the protocol format corresponding to the second protocol type, and the requested content of the second request is the same as the requested content of the first request, for example, both are query requests for an image.
[0101] Specifically, when the cloud service container acquires a second request of the second protocol type sent by a request sender such as another client or a service, the service process acquires the response information corresponding to the second protocol type generated in advance, and transmits the response information to the request sender.
[0102] Specifically, as described above, when the service process stores a code file based on the first request and receives a second request with the same content as the first request, the service process forms response information of the protocol format corresponding to the second protocol type based on the second protocol type corresponding to the second request, and transmits the response information to the request sender.
[0103] The above technical solution can effectively realize the reusability of the micro-service architecture, improve the processing efficiency, and avoid the problems of resource waste and time waste caused by multiple processing of the same request.
[0104] Figure 5 is another structure example diagram of a distributed system micro-service architecture provided by the embodiment of the disclosure, Figure 5 Taking a service process as a remote procedure call service process (RPC service process) as an example, a hypertext transfer protocol gateway (HTTP gateway) is established between the service processing component and the RPC service process, and an HTTP detection port is established on the RPC service process. It can be understood that when the service process is a hypertext transfer service process (HTTP service process), a hypertext transfer protocol gateway (PRPC gateway) is established between the service processing component and the HTTP service process, and an HTTP detection port is established on the RPC service process.
[0105] As Figure 5As shown, when the service process is a process for remote procedure call service, the distributed system microservice architecture includes a client, an internal service, a service processing component (MeshProxy), an HTTP gateway (HTTPGateway), an HTTP detection port (HTTP Port), an RPC detection port (RPC Port), and an RPC service process.
[0106] In the distributed system microservice architecture as shown, Figure 5 In the distributed system microservice architecture as shown, each component has the following functions:
[0107] The service processing component receives both HTTP requests and RPC requests, and identifies whether the protocol type of the request is HTTP or RPC; if the request is an HTTP protocol, it is forwarded to the HTTP gateway process for processing; if the request is an RPC protocol, it is forwarded to the RPC service process for processing; the data returned by the HTTP / RPC process is returned to the client or internal service. The HTTP gateway only processes HTTP request proxies and does not process RPC requests; it can implement general processing logic for the HTTP gateway; after the HTTP request is verified, it is directly forwarded to the HTTP port of the business service, and no longer undertakes the conversion of the HTTP protocol to the RPC protocol. The RPC service process receives both HTTP requests and RPC requests; HTTP protocol and RPC protocol requests use different ports for detection, namely HTTP detection port and RPC detection port; implement underlying business processing code, such as obtaining specific information from a storage or a database; encode the information directly into the required format and return the data; if it is an HTTP request, return it in the HTTP protocol format; if it is an RPC request, return it in the RPC protocol format.
[0108] The interaction flow of the microservice architecture is as follows:
[0109] The client or internal service sends a request in the corresponding format to the service processing component (the client sends an HTTP request, and the internal service sends an RPC request);
[0110] The service processing component receives both HTTP requests and RPC requests, and identifies whether the protocol type of the request is HTTP or RPC;
[0111] If the protocol type is HTTP, the HTTP request is forwarded to the HTTP gateway for processing; after the HTTP gateway performs verification and other processing on the HTTP request, the processed HTTP request is sent to the RPC service thread; the RPC service thread obtains the HTTP request through the set HTTP detection port, accesses the associated storage or database to process the HTTP request accordingly, forms a response information in the corresponding HTTP format, and returns the response information to the client via the original path;
[0112] If the protocol type is RPC, the RPC request is directly sent to the RPC service process, the RPC service process obtains the RPC request through the RPC detection port, accesses the associated memory or database to process the RPC request, forms response information corresponding to the RPC format, and returns the response information to the internal service according to the original path.
[0113] Figure 6 A cloud service container structure diagram provided by an embodiment of the present disclosure is shown in FIG. 1. Figure 6 As shown in FIG. 1, the cloud service container includes a service processing component 310 and a service process 320.
[0114] The service processing component 310 is configured to determine a first protocol type of a first request, and transmit the first request to the service process through a channel corresponding to the first protocol type.
[0115] The service process 320 is configured to generate response information of the first request in the service process according to a protocol format corresponding to the first protocol type, and send the response information.
[0116] The technical solution provided by the embodiment of the present disclosure realizes the transmission of the request into the service process based on the corresponding protocol type channel, and the service process can process at least two protocols. When the service process processes the request, protocol conversion is not required, the compatible processing of the requests corresponding to multiple protocol types can be realized, the workload in the development process is reduced, and the running efficiency of the architecture is improved.
[0117] In one embodiment, the service processing component 310 includes:
[0118] The protocol type determination unit is configured to determine a first protocol type of a first request.
[0119] The request transmission unit is configured to transmit the first request to the service process through a channel corresponding to the first protocol type.
[0120] In one embodiment, the service process 320 is specifically configured to:
[0121] Generate response information of the first request in the service process according to a protocol format corresponding to the first protocol type.
[0122] Send the response information.
[0123] In one embodiment, the first protocol type includes a hypertext transfer protocol or a remote procedure call protocol; and the service process is a process of a remote procedure call service.
[0124] In one embodiment, the request transmission unit is specifically configured to:
[0125] in the case that the first protocol type is the hypertext transfer protocol, transmitting the first request to a process of the hypertext transfer service via a hypertext transfer gateway;
[0126] in the case that the first protocol type is the remote procedure call protocol, transmitting the first request to the process of the remote procedure call service.
[0127] In an embodiment, the first protocol type comprises the hypertext transfer protocol or the remote procedure call protocol; and the service process is a process of a hypertext transfer service.
[0128] In an embodiment, the request transmitting unit is specifically configured to:
[0129] in the case that the first protocol type is the hypertext transfer protocol, transmitting the first request to a process of the hypertext transfer service via a hypertext transfer gateway;
[0130] in the case that the first protocol type is the remote procedure call protocol, transmitting the first request to the process of the hypertext transfer service.
[0131] In an embodiment, the cloud service container further comprises:
[0132] a response information generating module configured to generate response information of content requested by the first request in a protocol format corresponding to a second protocol type, the second protocol type comprising a protocol type supported by the service process other than the first protocol type.
[0133] In an embodiment, the cloud service container further comprises:
[0134] a response information transmitting module configured to, in the case that a second request of the second protocol type is acquired, acquire and transmit response information corresponding to the second request, the content requested by the second request being the same as the content requested by the first request.
[0135] The cloud service container provided by the embodiments of the present disclosure can execute the request processing method provided by any of the embodiments of the present disclosure, and has the corresponding functional modules and beneficial effects of the execution method.
[0136] It should be noted that each unit and module included in the cloud service container is only divided according to functional logic, but is not limited to the above division, as long as the corresponding functions can be implemented; in addition, the specific names of each functional unit are only for easy mutual differentiation, and do not limit the protection scope of the embodiments of the present disclosure.
[0137] Figure 7A structural diagram of an electronic device is provided in embodiments of the present disclosure. Reference is made below to Figure 7 which shows a structural diagram of an electronic device (e.g., a terminal device or a server) 400 suitable for use in implementing embodiments of the present disclosure. Figure 7
[0138] one or more processing devices;
[0139] a storage device for storing one or more programs,
[0140] When the one or more programs are executed by the one or more processing devices, the one or more processing devices implement the request processing method according to any one of the preceding embodiments.
[0141] A terminal device in embodiments of the present disclosure can include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (Personal Digital Assistant), a PAD (Tablet Personal Computer), a PMP (Portable Multimedia Player), a car terminal (e.g., a car navigation terminal), and the like, as well as a stationary terminal such as a digital TV, a desktop computer, and the like. Figure 7 The electronic device shown is merely one example, and should not bring any limitation to the functions and the range of use of embodiments of the present disclosure.
[0142] As shown in FIG. 4, Figure 7 The electronic device 400 can include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 401 that can perform various appropriate actions and processes according to programs stored in a read-only memory (ROM) 402 or loaded into a random access memory (RAM) 403 from a storage device 408. Various programs and data required for the operation of the electronic device 400 are also stored in the RAM 403. The processing device 401, the ROM 402, and the RAM 403 are connected to each other through a bus 404. An input / output (I / O) port 405 is also connected to the bus 404.
[0143] In general, the following devices can be connected to the I / O port 405: input devices 406 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, and the like; output devices 407 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, and the like; storage devices 408 including, for example, a magnetic tape, a hard disk, and the like; and communication devices 409. The communication devices 409 can allow the electronic device 400 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 7 The electronic device 400 is shown with various devices, but it is understood that all of the shown devices are not required to be implemented or present. More or fewer devices can alternatively be implemented or present.
[0144] In particular, according to embodiments of the present disclosure, the processes described above with reference to the flowcharts can be implemented as a computer software program. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for executing the methods illustrated by the flowcharts. In such embodiments, the computer program can be downloaded and installed from the network by the communication apparatus 409, or installed from the storage apparatus 408, or installed from the ROM 402. When the computer program is executed by the processing apparatus 401, the above-mentioned functions defined in the methods of the embodiments of the present disclosure are executed.
[0145] The names of the messages or information exchanged between the plurality of apparatuses in the embodiments of the present disclosure are only for illustrative purposes, and are not intended to limit the scope of the messages or information.
[0146] The electronic device provided by the embodiments of the present disclosure and the request processing method provided by the above-mentioned embodiments belong to the same inventive concept, and the technical details not described in detail in the present embodiment can be referred to the above-mentioned embodiments, and the present embodiment has the same beneficial effects as the above-mentioned embodiments.
[0147] The embodiments of the present disclosure provide a computer storage medium, which stores a computer program, and the program is executed by a processor to implement the request processing method provided by the above-mentioned embodiments.
[0148] It should be noted that the computer readable medium of the present disclosure described above can be a computer readable signal medium or a computer readable storage medium or any combination of the above two.
[0149] The computer storage medium can be a storage medium of computer executable instructions, and the computer executable instructions are used to execute the method provided by the present disclosure when executed by a computer processor.
[0150] The computer readable storage medium can be, for example but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of the computer readable storage medium can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the disclosure, the computer readable storage medium can be any tangible medium that contains or stores a program used by or in connection with an instruction execution system, apparatus, or device. In the disclosure, the computer readable signal medium can include a computer readable program code carried in a baseband or as a part of a carrier wave, in which the computer readable program code is used by or in connection with an instruction execution system, apparatus, or device. Such a propagated computer readable signal medium can take various forms, including but not limited to electro-magnetic, optical, or any suitable combination of the foregoing. The computer readable signal medium can also be any computer readable medium that is not a computer readable storage medium and that can be used to carry or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code carried by the computer readable media can be transmitted in any suitable medium, including but not limited to wire, cable, fiber optic, RF (radio frequency), or any suitable combination of the foregoing.
[0151] In some embodiments, the client, server, or both can communicate using any current known or future developed network protocol, such as HTTP (HyperText Transfer Protocol), and can be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include local area networks ("LAN"), wide area networks ("WAN"), the Internet, and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any current known or future developed networks.
[0152] The computer readable medium described above can be included in the electronic device described above; or can exist separately from the electronic device, and can not be assembled in the electronic device.
[0153] The computer readable medium described above carries one or more programs, when the one or more programs are executed by the electronic device, cause the electronic device to: determine a first protocol type of a first request; transmit the first request to a service process through a channel corresponding to the first protocol type; generate response information of the first request in the service process according to a protocol format corresponding to the first protocol type; and send the response information.
[0154] Computer program code for carrying out operations of the present disclosure can be written in any one or more programming languages, including object oriented programming languages such as Java, Smalltalk, C++, as well as conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider).
[0155] The flow diagrams and the block diagrams in the drawings are meant as methodological and functional description of implementations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flow diagrams or block diagrams can represent a module, a segment, or a portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that in some alternative implementations, the functions noted in the blocks can occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently or the blocks may
[0156] The modules or units described in the embodiments of the present disclosure can be implemented by software, or by hardware, or by a combination of software and hardware. In some cases, the names of the modules or units do not constitute a limitation on the modules or units themselves. For example, the service processing component can also be described as a component unit that acquires and transmits a first request.
[0157] The functions described above in the specification of the present disclosure can be performed by one or more hardware logic components. For example, and without limitation, illustrative types of hardware logic components that can be used include Field-programmable Gate Arrays (FPGAs), Program-specific Integrated Circuits (ASICs), Program-specific Standard Products (ASSPs), System-on-a-chip systems (SOCs), Complex Programmable Logic Devices (CPLDs), etc.
[0158] In the context of this disclosure, a machine-readable medium can be a tangible medium that contains or stores a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include but is not limited to an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of the machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0159] According to one or more embodiments of the present disclosure, example 1 provides a request processing method, comprising:
[0160] determining a first protocol type of a first request;
[0161] transmitting the first request to a service process through a channel corresponding to the first protocol type;
[0162] generating response information of the first request in a protocol format corresponding to the first protocol type within the service process;
[0163] sending the response information.
[0164] According to one or more embodiments of the present disclosure, example 2 provides the method according to example 1, wherein the first protocol type comprises a hypertext transfer protocol or a remote procedure call protocol; and the service process is a process of a remote procedure call service.
[0165] According to one or more embodiments of the present disclosure, example 3 provides the method according to example 2, wherein the transmitting the first request to the service process through the channel corresponding to the first protocol type comprises:
[0166] in a case where the first protocol type is the hypertext transfer protocol, transmitting the first request to the process of the remote procedure call service through a hypertext transfer gateway;
[0167] in a case where the first protocol type is the remote procedure call protocol, transmitting the first request to the process of the remote procedure call service.
[0168] According to one or more embodiments of the present disclosure, example 4 provides the method according to example 1, wherein the first protocol type comprises a hypertext transfer protocol or a remote procedure call protocol; and the service process is a process of a hypertext transfer service.
[0169] According to one or more embodiments of this disclosure, Example 5 describes the method described in Example 4, wherein transmitting the first request to the service process via a channel corresponding to the first protocol type includes:
[0170] When the first protocol type is Hypertext Transfer Protocol, the first request is transmitted to the process of Hypertext Transfer Service through the Hypertext Transfer Gateway;
[0171] If the first protocol type is a remote procedure call protocol, the first request is transmitted to the process of the hypertext transfer service.
[0172] According to one or more embodiments of this disclosure, Example 6, based on the method described in Example 1, after generating the response information for the first request in the service process according to the protocol format corresponding to the first protocol type, further includes:
[0173] The response information for the content requested by the first request is generated according to the protocol format corresponding to the second protocol type. The second protocol type includes protocol types other than the first protocol type among the protocol types supported by the service process.
[0174] According to one or more embodiments of this disclosure, Example 7, based on the method described in Example 6, further includes: upon receiving a second request of the second protocol type, acquiring and transmitting response information corresponding to the second request, wherein the content requested by the second request is the same as the content requested by the first request. The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of disclosure involved in this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalent features without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features with similar functions disclosed in this disclosure.
[0175] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.
[0176] Although the subject matter has been described in language specific to structural features and / or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims.
Claims
1. A request processing method characterized by comprising: The method comprises: determining a first protocol type of a first request; transmitting the first request to a service process through a channel corresponding to the first protocol type; generating response information of the first request in the service process according to a protocol format corresponding to the first protocol type; sending the response information.
2. The method of claim 1, wherein, The first protocol type comprises a hypertext transfer protocol or a remote procedure call protocol; and the service process is a process of a remote procedure call service.
3. The method of claim 2, wherein, The transmitting the first request to the service process through the channel corresponding to the first protocol type comprises: in a case where the first protocol type is the hypertext transfer protocol, transmitting the first request to the process of the remote procedure call service through a hypertext transfer gateway; and in a case where the first protocol type is the remote procedure call protocol, transmitting the first request to the process of the remote procedure call service.
4. The method of claim 1, wherein, The first protocol type comprises a hypertext transfer protocol or a remote procedure call protocol; and the service process is a process of a hypertext transfer service.
5. The method of claim 4, wherein, The transmitting the first request to the service process through the channel corresponding to the first protocol type comprises: in a case where the first protocol type is the hypertext transfer protocol, transmitting the first request to the process of the hypertext transfer service through a hypertext transfer gateway; and in a case where the first protocol type is the remote procedure call protocol, transmitting the first request to the process of the hypertext transfer service.
6. The method of claim 1, wherein, After the generating the response information of the first request in the service process according to the protocol format corresponding to the first protocol type, the method further comprises: generating response information of content requested by the first request according to a protocol format corresponding to a second protocol type, the second protocol type comprising a protocol type supported by the service process other than the first protocol type.
7. The method of claim 6, wherein, The method further comprises: in a case where a second request of the second protocol type is acquired, acquiring and transmitting response information corresponding to the second request, the second request requesting the same content as the first request.
8. A cloud service container, characterized by The method comprises: a service processing component configured to determine a first protocol type of a first request, and transmit the first request to a service process through a channel corresponding to the first protocol type; a service process configured to generate response information of the first request in the service process according to a protocol format corresponding to the first protocol type, and send the response information.
9. An electronic device, comprising: The electronic device comprises: one or more processing apparatuses; a storage apparatus configured to store one or more programs, when the one or more programs are executed by the one or more processing apparatuses, the one or more processing apparatuses implement the request processing method according to any one of claims 1-7.
10. A storage medium containing computer-executable instructions for performing the request processing method according to any one of claims 1-7 when executed by a computer processor.