Method and device for processing remote procedure call (RPC) service and electronic equipment
By pre-establishing a communication connection in the RPC service and directly sending and receiving RPC service requests and responses, the problem of the client needing to establish a new connection every time it calls the server-side RPC service is solved and communication efficiency is improved.
Patent Information
- Application Number
- CN202310385418.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-12
- Publication Date
- 2024-10-18
AI Technical Summary
In most actual business application scenarios, the client needs to establish a separate connection each time it calls the server-side RPC service, resulting in low communication efficiency.
By obtaining the RPC service name, RPC service parameters and RPC service type to be called, encapsulation is performed to generate an RPC service request, and the request is directly sent based on the communication connection established with the server in advance, and the response result is received to avoid establishing a new one before each call. connect.
The RPC process is simplified, the efficiency of calling RPC services is improved, and the number of connection establishments between the client and the server is reduced.
Smart Images

Figure CN118802999A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a method, device and electronic device for processing a remote procedure call (RPC) service. Background Art
[0002] Remote Procedure Call (RPC) is a technology that uses the RPC protocol to request services from a remote computer program over the network without having to understand the underlying network technology.
[0003] Usually, RPC adopts the client / server mode, where the requesting program can be the client and the service provider can be the server. The requesting program can call the server through the corresponding interface in an open platform. At present, in most actual business application scenarios, the client / server mode usually adopts a transmission method with objects as content, that is, the client sends a request object and receives the result object returned by the server after processing.
[0004] However, each time the client calls the RPC service on the server, it needs to establish a separate connection, which results in low communication efficiency. Summary of the invention
[0005] The present disclosure proposes a method, device and electronic device for processing a remote procedure call (RPC) service, aiming to solve one of the technical problems in the related art at least to a certain extent.
[0006] The first embodiment of the present disclosure provides a method for processing a remote procedure call (RPC) service, including:
[0007] Get the RPC service name, RPC service parameters and RPC service type to be called;
[0008] Encapsulate the RPC service name, RPC service parameters and RPC service type to be called, and generate an RPC service request;
[0009] Based on the communication connection pre-established with the server, the RPC service request is sent to the server;
[0010] Receive a response result corresponding to the RPC service request sent by the server.
[0011] The second aspect of the present disclosure provides a method for processing a remote procedure call (RPC) service, including:
[0012] Based on the communication connection pre-established with the client, receiving the RPC service request sent by the client;
[0013] Parse the RPC service request to obtain the RPC service name, RPC service parameters and RPC service type to be called;
[0014] Based on the RPC service name, RPC service parameters and RPC service type to be called, call the corresponding RPC service to obtain a response result corresponding to the RPC service request;
[0015] The response result is sent to the client.
[0016] The third aspect of the present disclosure provides a method for processing a remote procedure call (RPC) service, including:
[0017] The acquisition module is used to obtain the RPC service name, RPC service parameters and RPC service type to be called;
[0018] A generation module, used to encapsulate the RPC service name, RPC service parameters and RPC service type to be called, and generate an RPC service request;
[0019] A sending module, used for sending the RPC service request to the server based on a communication connection pre-established with the server;
[0020] The receiving module is used to receive the response result corresponding to the RPC service request sent by the server.
[0021] The fourth aspect of the present disclosure provides a method for processing a remote procedure call (RPC) service, including:
[0022] A receiving module, used for receiving an RPC service request sent by a client based on a communication connection established in advance with the client;
[0023] A parsing module, used to parse the RPC service request to obtain the RPC service name, RPC service parameters and RPC service type to be called;
[0024] An acquisition module, used to call the corresponding RPC service based on the RPC service name to be called, the RPC service parameters and the RPC service type, and obtain a response result corresponding to the RPC service request;
[0025] A sending module is used to send the response result to the client.
[0026] A fifth aspect of the present disclosure provides an electronic device, including:
[0027] At least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the processing method of the remote procedure call (RPC) service of the embodiment of the present disclosure.
[0028] The sixth aspect embodiment of the present disclosure proposes a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable the computer to execute the processing method of the remote procedure call (RPC) service disclosed in the embodiment of the present disclosure.
[0029] An embodiment of the seventh aspect of the present disclosure provides a vehicle, including: a processing device for the remote procedure call (RPC) service proposed in the embodiment of the second aspect of the present disclosure.
[0030] The processing method, device and electronic device for remote procedure call RPC service provided by the present disclosure can first obtain the RPC service name, RPC service parameters and RPC service type to be called, and encapsulate the RPC service name, RPC service parameters and RPC service type to be called, generate an RPC service request, and then send the RPC service request to the server based on the communication connection established in advance with the server, and finally receive the response result corresponding to the RPC service request sent by the server. Therefore, each time the client calls the RPC service of the server, it can directly send the RPC service request to the server based on the pre-established communication connection, without having to establish a connection each time before calling the RPC service of the server, thereby simplifying the RPC process and improving the efficiency of calling the RPC service.
[0031] Additional aspects and advantages of the present disclosure will be given in part in the following description and in part will be obvious from the following description or learned through practice of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] The above and / or additional aspects and advantages of the present disclosure will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0033] Figure 1 It is a flowchart of a method for processing a remote procedure call (RPC) service provided according to an embodiment of the present disclosure;
[0034] Figure 2 It is a flowchart of a method for processing a remote procedure call (RPC) service according to another embodiment of the present disclosure;
[0035] Figure 3 It is a flowchart of a method for processing a remote procedure call (RPC) service according to another embodiment of the present disclosure;
[0036] Figure 4 A flowchart of a method for processing a remote procedure call (RPC) service according to an embodiment of the present disclosure is shown in FIG.
[0037] Figure 5 It is a schematic diagram of a processing device for a remote procedure call (RPC) service provided according to an embodiment of the present disclosure;
[0038] Figure 6 It is a schematic diagram of a processing device for a remote procedure call (RPC) service provided according to an embodiment of the present disclosure;
[0039] Figure 7 is a schematic structural diagram of a vehicle provided in an embodiment of the present disclosure;
[0040] Figure 8 A block diagram of an exemplary electronic device suitable for implementing embodiments of the present disclosure is shown. DETAILED DESCRIPTION
[0041] Embodiments of the present disclosure are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present disclosure, and are not to be construed as limitations of the present disclosure. On the contrary, the embodiments of the present disclosure include all changes, modifications, and equivalents that fall within the spirit and connotation of the appended claims.
[0042] Figure 1 The flowchart of the method for processing a remote procedure call (RPC) service provided in accordance with an embodiment of the present disclosure is applied to a client. Figure 1 As shown, the method includes:
[0043] Step 101, obtain the RPC service name, RPC service parameters and RPC service type to be called.
[0044] The RPC service name may be the target function to be called, and the RPC service parameters may be the input parameters required to call the target function.
[0045] RPC service types may include streaming RPC services, and ordinary RPC services (ie, non-streaming RPC services).
[0046] In actual application scenarios, we may encounter situations where we need to continuously transmit data, such as when the amount of data is large. At this time, we can use streaming RPC to achieve data transmission and processing at the same time.
[0047] Among them, streaming RPC services include server-side streaming, client-side streaming and bidirectional streaming.
[0048] Optionally, the RPC service name and RPC service parameters sent by the service caller (caller) in the client can be obtained through the calling interface of the streaming RPC service. That is, if the caller in the client calls the streaming RPC service, the calling interface of the streaming RPC service is called.
[0049] Optionally, you can use the calling interface of the common RPC service to obtain the RPC service name and RPC service parameters sent by the caller in the client. That is, if the caller in the client calls the common RPC service, it needs to call the calling interface of the common RPC service.
[0050] Therefore, based on different types of calling interfaces, the RPC service type can be determined, and the RPC service name and RPC service parameters sent by the caller in the client can be obtained.
[0051] Step 102: Encapsulate the RPC service name, RPC service parameters and RPC service type to be called, and generate an RPC service request.
[0052] Optionally, the RPC service name, RPC service parameters and RPC service type to be called may be encapsulated according to a preset encapsulation rule to obtain an RPC service request, that is, the RPC service request includes the RPC service name, RPC service parameters and RPC service type.
[0053] Optionally, when the RPC service type is a streaming RPC service, a first total length of all RPC service requests is determined, and then the first total length is stored in the first RPC service request.
[0054] It should be noted that if the RPC service type is a streaming RPC service, the number of RPC service requests may be multiple, so the first total length of all RPC service requests can be determined, and the first total length can also be encapsulated in the first RPC service request to tell the server the total length of the streaming RPC service request, so that the server can determine whether to receive all RPC service requests based on the first total length. The first total length can be encapsulated in the message header of the first RPC service request.
[0055] The message header of the first RPC service request may also include a stream RPC start flag, for example, 0x11111111 indicates starting the stream RPC, and 0x22222222 indicates ending the stream RPC.
[0056] Optionally, when the RPC service type is a common RPC service, the number of RPC service requests is 1.
[0057] Step 103: Based on the communication connection pre-established with the server, the RPC service request is sent to the server.
[0058] Optionally, during the server-side bus initialization phase, a communication connection may be established and maintained with the server based on a communication protocol.
[0059] The communication protocol may be a Transmission Control Protocol (TCP), which is not limited in the present disclosure.
[0060] Specifically, the client sends a connection request to the server, and the server allocates a thread to the client. After the client and the server establish a connection, they remain connected for subsequent RPC service requests to be transmitted directly without the need to reestablish a connection. The thread allocated by the server to the client is specifically used to wait for the RPC service request sent by the client.
[0061] Optionally, after the client establishes a connection with the server, the connection information can be provided to the caller in the client in the form of a global variable. Different callers are distinguished by a mutex lock.
[0062] Step 104: Receive a response result corresponding to the RPC service request sent by the server.
[0063] Optionally, when the RPC service type is a common RPC service, there is only one response result. Therefore, after receiving one response result, it can be determined that all response results have been received and this RPC service is completed.
[0064] When the RPC service type is a streaming RPC service, there may be multiple response results. Therefore, it is necessary to determine whether all response results have been received.
[0065] Optionally, when the RPC service type is a streaming RPC service, the first response result received can be parsed first to determine the second total length of all response results, and then the third total length of the received response results can be determined. When the third total length is less than the second total length, continue to receive the response results sent by the server. Alternatively, when the third total length is equal to the second total length, determine that the reception of all response results is completed.
[0066] The first response result may include the second total length of all response results.
[0067] Optionally, when the RPC service type is a streaming RPC service, the first RPC service request can be used to request the server to start the streaming RPC, and the first response result can be used to return a message indicating that the streaming RPC is successfully started.
[0068] In the disclosed embodiment, the RPC service name, RPC service parameters and RPC service type to be called can be first obtained, and the RPC service name, RPC service parameters and RPC service type to be called can be encapsulated to generate an RPC service request, and then the RPC service request can be sent to the server based on the communication connection established in advance with the server, and finally the response result corresponding to the RPC service request sent by the server can be received. Therefore, each time the client calls the RPC service of the server, it can directly send the RPC service request to the server based on the pre-established communication connection, without having to establish a connection each time before calling the RPC service of the server, thereby simplifying the RPC process and improving the efficiency of calling the RPC service.
[0069] Figure 2 The flowchart of the method for processing a remote procedure call (RPC) service provided in accordance with an embodiment of the present disclosure is applied to a client. Figure 2 As shown, the method includes:
[0070] Step 201, based on the target calling interface, obtain the RPC service name and RPC service parameters to be called corresponding to different RPC service types.
[0071] The target call interface can be called by a common RPC service or a streaming RPC service. Therefore, the client can obtain the RPC service name and RPC service parameters to be called corresponding to the common RPC service based on the target call interface, and can also obtain the RPC service name and RPC service parameters to be called corresponding to the streaming RPC service.
[0072] In the disclosed embodiments, the ordinary RPC calling interface and the streaming RPC calling interface can be unified, that is, the ordinary RPC service and the streaming RPC service can use the same calling interface to call the RPC service, thereby reducing the number of interfaces required to call different RPC services and facilitating use by developers.
[0073] Step 202: Encapsulate the RPC service name, RPC service parameters and RPC service type to be called, and generate an RPC service request.
[0074] Step 203: Based on the communication connection pre-established with the server, the RPC service request is sent to the server.
[0075] Step 204: Receive a response result corresponding to the RPC service request sent by the server.
[0076] The specific implementation forms of steps 201 to 204 can refer to the detailed descriptions in other embodiments of the present disclosure, and will not be described in detail here.
[0077] In the disclosed embodiment, the RPC service name, RPC service parameters and RPC service type to be called can be obtained based on the target calling interface, wherein the number of the target calling interface is one, and then the RPC service name, RPC service parameters and RPC service type to be called are encapsulated to generate an RPC service request, and then based on the communication connection pre-established with the server, the RPC service request is sent to the server, and finally the response result corresponding to the RPC service request sent by the server is received. Thus, the client can provide a unified calling interface for streaming RPC services and ordinary RPC services, thereby not only reducing the number of interfaces and facilitating developers to call, but also eliminating the need to establish a connection each time before calling the RPC service on the server, thereby simplifying the RPC process and improving the efficiency of calling RPC services.
[0078] Figure 3 The flowchart of the method for processing a remote procedure call (RPC) service provided in accordance with an embodiment of the present disclosure is applied to the server side. Figure 3 As shown, the method includes:
[0079] Step 301: Based on the communication connection pre-established with the client, receive the RPC service request sent by the client.
[0080] Optionally, during the server-side bus initialization phase, a communication connection is established with the client based on a communication protocol and the connection is maintained.
[0081] The communication protocol may be a Transmission Control Protocol (TCP), which is not limited in the present disclosure.
[0082] Furthermore, when a communication connection request sent by a client is received, a target thread is allocated to the client, and then a communication connection is established and maintained with the client based on the target thread and the communication protocol.
[0083] The target thread allocated by the server to the client is specifically used to wait for the RPC service request sent by the client. After the client and the server establish a connection, they will remain connected for the subsequent RPC service requests to be directly transmitted without re-establishing the connection.
[0084] Optionally, when the RPC service type is a common RPC service, the number of RPC service requests is one, and therefore, after receiving one RPC service request, it can be determined that the reception of all RPC service requests is completed.
[0085] When the RPC service type is a streaming RPC service, there may be multiple RPC service requests. Therefore, it is necessary to determine whether all RPC service requests have been received.
[0086] Optionally, when the RPC service type is a streaming RPC service, the first received RPC service request is parsed to obtain a first total length of all RPC service requests, and then a fourth total length of the received RPC service requests is determined; when the fourth total length is less than the first total length, continue to receive RPC service requests sent by the client, or when the fourth total length is equal to the first total length, determine that the reception of all RPC service requests is completed.
[0087] It should be noted that if the streaming RPC service is a two-way streaming RPC, it is not necessary to process the RPC service request after receiving all RPC service requests. The response result can be returned while receiving the RPC service request. If the streaming RPC service is a client-side streaming RPC, it is necessary to return a response result after receiving all RPC service requests.
[0088] Step 302: parse the RPC service request to obtain the RPC service name, RPC service parameters and RPC service type to be called.
[0089] Specifically, based on the parsing rules that match the encapsulation rules, the RPC service request is parsed to obtain the RPC service name, RPC service parameters and RPC service type to be called.
[0090] Step 303: Based on the RPC service name, RPC service parameters and RPC service type to be called, the corresponding RPC service is called to obtain a response result corresponding to the RPC service request.
[0091] In the embodiment of the present disclosure, after determining the RPC service name, RPC service parameters and RPC service type to be called, the corresponding RPC service can be called based on the RPC service type, RPC service name and RPC service parameters, and a corresponding response result can be generated.
[0092] Specifically, when the RPC service type is a common RPC service, a response result is generated.
[0093] Optionally, when the RPC service type is a streaming RPC service, the second total length of all response results is determined, and then the second total length is stored in the first response result, so that the client can be told the second total length of all response results in the first response result, and the client can determine whether to complete the reception of all response results based on the second total length and the third total length of the received response results.
[0094] Step 304: Send the response result to the client.
[0095] The disclosed embodiment can first receive the RPC service request sent by the client based on the communication connection established in advance with the client, then parse the RPC service request to obtain the RPC service name, RPC service parameters and RPC service type to be called, then call the corresponding RPC service based on the RPC service name, RPC service parameters and RPC service type to be called, obtain the response result corresponding to the RPC service request, and finally send the response result to the client. Thus, after the server establishes a communication connection with the client, it can wait for the RPC service request sent by the client based on the communication connection, and process the RPC service request and return the response result, without the client having to establish a connection each time before calling the RPC service of the server, thereby simplifying the RPC process and improving the efficiency of the client calling the RPC service.
[0096] Figure 4 FIG. 1 is a flow chart of a method for processing a remote procedure call (RPC) service according to an embodiment of the present disclosure. Figure 4 As shown, the method includes:
[0097] Step 401: During the bus initialization phase, the server creates a thread pool and waits for the client to establish a communication connection.
[0098] Step 402: The server establishes a connection with the client and allocates a target thread to the client.
[0099] The following steps 403 and 405 are described in detail by taking the client calling a common RPC service as an example.
[0100] Step 403: Based on the established communication connection, the client sends a common RPC service request to the server, wherein the RPC service request includes an RPC service name, RPC service parameters and RPC service type.
[0101] Step 404: Based on the RPC service name and RPC service parameters contained in the received common RPC service request, a corresponding function is called to generate a response result.
[0102] Step 405: The server sends a response result to the client.
[0103] The following steps 406 and 408 are described in detail by taking the server-side streaming RPC service as an example.
[0104] Step 406: Based on the established communication connection, the client sends an RPC service request to the server, wherein the RPC service request includes the first total length of all RPC service requests, the RPC service name, the RPC service parameters and the RPC service type.
[0105] It should be noted that, in the case of server-side streaming RPC service, the client sends only one RPC service request.
[0106] Step 407: The server generates a streaming response result based on the received RPC service request, wherein the first response result includes the second total length of all response results.
[0107] Step 408: The server sends streaming response results to the client in sequence.
[0108] In order to implement the above embodiment, the present disclosure also proposes a processing device for a remote procedure call (RPC) service.
[0109] Figure 5 It is a schematic diagram of a processing device for a remote procedure call (RPC) service provided according to an embodiment of the present disclosure, which is applied to a client.
[0110] like Figure 5 As shown, the processing device 500 of the remote procedure call RPC service includes:
[0111] The acquisition module 510 is used to acquire the RPC service name, RPC service parameters and RPC service type to be called;
[0112] A generation module 520 is used to encapsulate the RPC service name, RPC service parameters and RPC service type to be called, and generate an RPC service request;
[0113] The sending module 530 is used to send the RPC service request to the server based on the communication connection pre-established with the server;
[0114] The receiving module 540 is used to receive the response result corresponding to the RPC service request sent by the server.
[0115] Optionally, also include:
[0116] The connection establishment module is used to establish and maintain a communication connection with the server based on a communication protocol during the initialization phase of the server bus.
[0117] Optionally, the acquisition module 510 is further used to acquire the RPC service name and RPC service parameters to be called corresponding to different RPC service types based on the target calling interface.
[0118] Optionally, the generating module 520 is further configured to:
[0119] In the case where the RPC service type is a streaming RPC service, determining a first total length of all RPC service requests;
[0120] The first total length is stored in the first RPC service request.
[0121] The receiving module 540 is further configured to:
[0122] When the RPC service type is a streaming RPC service, the first response result received is parsed to determine a second total length of all response results;
[0123] Determining a third total length of the received response result;
[0124] When the third total length is less than the second total length, continue to receive the response result sent by the server;
[0125] When the third total length is equal to the second total length, it is determined that reception of all response results is completed.
[0126] The functions and specific implementation principles of the above modules in the disclosed embodiments can be referred to the above method embodiments, which will not be repeated here.
[0127] The processing device for the remote procedure call RPC service of the embodiment of the present disclosure can first obtain the RPC service name, RPC service parameters and RPC service type to be called, and encapsulate the RPC service name, RPC service parameters and RPC service type to be called, generate an RPC service request, and then send the RPC service request to the server based on the communication connection established in advance with the server, and finally receive the response result corresponding to the RPC service request sent by the server. Therefore, each time the client calls the RPC service of the server, it can directly send the RPC service request to the server based on the pre-established communication connection, without having to establish a connection each time before calling the RPC service of the server, thereby simplifying the RPC process and improving the efficiency of calling the RPC service.
[0128] Figure 6 It is a schematic diagram of a processing device for a remote procedure call (RPC) service provided according to an embodiment of the present disclosure, which is applied to a server side.
[0129] like Figure 6As shown, the processing device 600 of the remote procedure call RPC service includes:
[0130] The receiving module 610 is used to receive the RPC service request sent by the client based on the communication connection pre-established with the client;
[0131] The parsing module 620 is used to parse the RPC service request and obtain the RPC service name, RPC service parameters and RPC service type to be called;
[0132] The acquisition module 630 is used to call the corresponding RPC service based on the RPC service name, RPC service parameters and RPC service type to be called, and obtain the response result corresponding to the RPC service request;
[0133] The sending module 640 is used to send the response result to the client.
[0134] Optionally, also include:
[0135] The connection establishment module is used to establish and maintain a communication connection with the client based on the communication protocol during the server-side bus initialization phase.
[0136] Optionally, the connection establishment module is also used to:
[0137] When receiving a communication connection request sent by a client, a target thread is allocated to the client;
[0138] Based on the target thread and communication protocol, establish a communication connection with the client and maintain the connection.
[0139] Optionally, a processing module is also included, for:
[0140] When the RPC service type is a streaming RPC service, the first received RPC service request is parsed to obtain a first total length of all RPC service requests;
[0141] Determining a fourth total length of the received RPC service request;
[0142] When the fourth total length is less than the first total length, continue to receive the RPC service request sent by the client;
[0143] When the fourth total length is equal to the first total length, it is determined that the reception of all RPC service requests is completed.
[0144] Optionally, the acquisition module is also specifically used to:
[0145] When the RPC service type is a streaming RPC service, determining a second total length of all response results;
[0146] Store the second total length in the first response result.
[0147] The functions and specific implementation principles of the above modules in the embodiments of the present disclosure can be referred to the above method embodiments, and will not be repeated here.
[0148] The processing device of the remote procedure call RPC service of the disclosed embodiment can first receive the RPC service request sent by the client based on the communication connection established in advance with the client, and then parse the RPC service request to obtain the RPC service name, RPC service parameters and RPC service type to be called, and then call the corresponding RPC service based on the RPC service name, RPC service parameters and RPC service type to be called, obtain the response result corresponding to the RPC service request, and finally send the response result to the client. Therefore, after the server establishes a communication connection with the client, it can wait for the RPC service request sent by the client based on the communication connection, and process the RPC service request and return the response result. The client does not need to establish a connection before each call to the server's RPC service, thereby simplifying the RPC process and improving the efficiency of the client calling the RPC service.
[0149] Figure 7 It is a schematic diagram of the structure of a vehicle proposed in one embodiment of the present disclosure.
[0150] like Figure 7 As shown, the vehicle 700 includes: a processing device 500 for the remote procedure call RPC service in the above embodiment.
[0151] In this embodiment, the RPC service name, RPC service parameters and RPC service type to be called are obtained, and the RPC service name, RPC service parameters and RPC service type to be called are encapsulated to generate an RPC service request, and then the RPC service request is sent to the server based on the communication connection established in advance with the server, and finally the response result corresponding to the RPC service request sent by the server is received. Therefore, each time the client calls the RPC service of the server, it can directly send the RPC service request to the server based on the pre-established communication connection, without having to establish a connection each time before calling the RPC service of the server, thereby simplifying the RPC process and improving the efficiency of calling the RPC service.
[0152] In order to implement the above embodiment, the present disclosure further provides an electronic device, including:
[0153] At least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the processing method of the remote procedure call (RPC) service of the embodiment of the present disclosure.
[0154] In order to implement the above embodiments, the present disclosure further proposes a non-transitory computer-readable storage medium storing computer instructions, where the computer instructions are used to enable a computer to execute the processing method for the remote procedure call (RPC) service disclosed in the embodiments of the present disclosure.
[0155] In order to implement the above embodiment, the present disclosure also provides a computer program product. Figure 8 A bus, an accelerated graphics port, a processor, or a local bus using any of a variety of bus structures. For example, these architectures include, but are not limited to, an Industry Standard Architecture (ISA) bus, a Micro Channel Architecture (MAC) bus, an enhanced ISA bus, a Video Electronics Standards Association (VESA) local bus, and a Peripheral Component Interconnection (PCI) bus.
[0156] The electronic device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the electronic device 12, including volatile and non-volatile media, removable and non-removable media.
[0157] The memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. The electronic device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 34 may be used to read and write non-removable, non-volatile magnetic media ( Figure 8 Not shown, often called a "hard drive").
[0158] although Figure 8Not shown in the figure, a disk drive for reading and writing a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing a removable non-volatile optical disk (e.g., a compact disc read only memory (CD-ROM), a digital versatile disc read only memory (DVD-ROM), or other optical media) may be provided. In these cases, each drive may be connected to the bus 18 via one or more data medium interfaces. The memory 28 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of the various embodiments of the present disclosure.
[0159] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in the memory 28, such program modules 42 including but not limited to an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. The program modules 42 generally perform the functions and / or methods of the embodiments described in the present disclosure.
[0160] The electronic device 12 may also communicate with one or more external devices 14 (e.g., keyboards, pointing devices, displays 24, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 12, and / or may communicate with any device that enables the electronic device 12 to communicate with one or more other computing devices (e.g., network cards, modems, etc.). Such communication may be performed via an input / output (I / O) interface 22. Furthermore, the electronic device 12 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 20. As shown, the network adapter 20 communicates with other modules of the electronic device 12 via a bus 18. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0161] The processing unit 16 executes various functional applications by running the programs stored in the system memory 28, such as implementing the processing method of the remote procedure call (RPC) service mentioned in the above-mentioned embodiment.
[0162] The technical solution provided by the present disclosure can obtain the RPC service name, RPC service parameters and RPC service type to be called, and encapsulate the RPC service name, RPC service parameters and RPC service type to be called, generate an RPC service request, and then send the RPC service request to the server based on the communication connection established in advance with the server, and finally receive the response result corresponding to the RPC service request sent by the server. Therefore, each time the client calls the RPC service of the server, it can directly send the RPC service request to the server based on the pre-established communication connection, without having to establish a connection each time before calling the RPC service of the server, thereby simplifying the RPC process and improving the efficiency of calling the RPC service.
[0163] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0164] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
[0165] It should be noted that, in the description of the present disclosure, the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In addition, in the description of the present disclosure, unless otherwise specified, the meaning of "plurality" is two or more.
[0166] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present disclosure includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by those skilled in the art to which the embodiments of the present disclosure belong.
[0167] It should be understood that the various parts of the present disclosure can be implemented in hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented in software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0168] A person skilled in the art may understand that all or part of the steps in the above-mentioned embodiment method may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0169] In addition, each functional unit in each embodiment of the present disclosure may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0170] The storage medium mentioned above can be a read-only memory, a magnetic disk or an optical disk, etc.
[0171] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present disclosure. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0172] Although the embodiments of the present disclosure have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations of the present disclosure. A person skilled in the art may change, modify, replace and vary the above embodiments within the scope of the present disclosure.
Claims
1. A method for processing a remote procedure call (RPC) service, characterized in that: include: Get the RPC service name, RPC service parameters and RPC service type to be called; Encapsulate the RPC service name, RPC service parameters and RPC service type to be called, and generate an RPC service request; Based on the communication connection pre-established with the server, the RPC service request is sent to the server; Receive a response result corresponding to the RPC service request sent by the server.
2. The method according to claim 1, characterized in that: Before obtaining the RPC service name, RPC service parameters and RPC service type to be called, it also includes: During the server-side bus initialization phase, a communication connection is established with the server-side based on a communication protocol and the connection is maintained.
3. The method according to claim 1, characterized in that The obtaining of the RPC service name, RPC service parameters and RPC service type to be called includes: Based on the target calling interface, obtain the RPC service name and RPC service parameters to be called corresponding to different RPC service types.
4. The method according to claim 1, characterized in that: The generating of the RPC service request further includes: In a case where the RPC service type is a streaming RPC service, determining a first total length of all RPC service requests; The first total length is stored in the first RPC service request.
5. The method according to claim 1, characterized in that The receiving a response result corresponding to the RPC service request sent by the server includes: When the RPC service type is a streaming RPC service, parsing the first response result received to determine a second total length of all response results; Determining a third total length of the received response result; When the third total length is less than the second total length, continue to receive a response result sent by the server; When the third total length is equal to the second total length, it is determined that the reception of all response results is completed.
6. A method for processing a remote procedure call (RPC) service, characterized in that: include: Based on the communication connection pre-established with the client, receiving the RPC service request sent by the client; Parse the RPC service request to obtain the RPC service name, RPC service parameters and RPC service type to be called; Based on the RPC service name, RPC service parameters and RPC service type to be called, call the corresponding RPC service to obtain a response result corresponding to the RPC service request; The response result is sent to the client.
7. The method according to claim 6, characterized in that Also includes: During the server-side bus initialization phase, a communication connection is established with the client based on a communication protocol and the connection is maintained.
8. The method according to claim 7, characterized in that The establishing a communication connection with the client based on the communication protocol and maintaining the connection includes: Upon receiving a communication connection request sent by the client, allocating a target thread to the client; Based on the target thread and the communication protocol, a communication connection is established with the client and the connection is maintained.
9. The method according to claim 6, characterized in that Also includes: When the RPC service type is a streaming RPC service, parsing the first received RPC service request to obtain a first total length of all RPC service requests; Determining a fourth total length of the received RPC service request; When the fourth total length is less than the first total length, continue to receive the RPC service request sent by the client; When the fourth total length is equal to the first total length, it is determined that the reception of all RPC service requests is completed.
10. The method according to claim 6, characterized in that The obtaining of the response result corresponding to the RPC service request also includes: In a case where the RPC service type is a streaming RPC service, determining a second total length of all response results; The second total length is stored in the first response result.
11. A processing device for a remote procedure call (RPC) service, characterized in that: include: The acquisition module is used to obtain the RPC service name, RPC service parameters and RPC service type to be called; A generation module, used to encapsulate the RPC service name, RPC service parameters and RPC service type to be called, and generate an RPC service request; A sending module, used for sending the RPC service request to the server based on a communication connection pre-established with the server; The receiving module is used to receive the response result corresponding to the RPC service request sent by the server.
12. A processing device for a remote procedure call (RPC) service, characterized in that: include: A receiving module, used for receiving an RPC service request sent by a client based on a communication connection established in advance with the client; A parsing module, used to parse the RPC service request to obtain the RPC service name, RPC service parameters and RPC service type to be called; An acquisition module, used to call the corresponding RPC service based on the RPC service name to be called, the RPC service parameters and the RPC service type, and obtain a response result corresponding to the RPC service request; A sending module is used to send the response result to the client.
13. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the method of any one of claims 1-5, or to execute the method of any one of claims 6-10.
14. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to enable the computer to execute the method according to any one of claims 1 to 5, or to enable the computer to execute the method according to any one of claims 6 to 10.
15. A vehicle, characterized in that: include: A processing device for remote procedure call (RPC) service as claimed in claim 11.
