Data Calling Method, Apparatus and Electronic Device
A virtual RPC service simplifies cross-process communication by acting as a proxy for target RPC services, reducing the need for repetitive definitions and maintenance efforts.
Patent Information
- Application Number
- CN202010670418.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-07-13
- Publication Date
- 2025-07-15
- Estimated Expiration
- 2040-07-13
AI Technical Summary
In a plug-in platform, the methods and attributes to be called need to be defined separately when communicating across processes, which leads to a large amount of workload and is difficult to maintain.
By creating a virtual RPC service in the first process, using the target protocol to achieve cross-process communication, defining preset attributes and method call interfaces, reducing the need for repeated definitions on cross-process services.
It reduces the workload and maintenance difficulty during cross-process communication, and simplifies the maintenance process of methods and attributes.
Smart Images

Figure CN113934549B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of data invocation, and in particular, to a data invocation method, apparatus, and electronic device. Background Art
[0002] In a plugin-based platform, it is necessary to ensure the secure isolation of plugins. In the development environment of NET (Network Operating Platform), the related technology uses the way of assembly reference to achieve the isolation of plugins. However, in the case of assembly reference conflicts, unpredictable abnormal results will occur. For the stability of the platform, process isolation can be used in the plugin platform to achieve the isolation between plugins.
[0003] When performing cross-process communication between various plugins in the plugin-based system, the related technology uses the RPC communication method. The GRPC definition file is used on the services at both ends to define one by one the methods and parameter types to be remotely invoked, thus laying a foundation for the invocation of method attributes between services. However, when the number of methods or attributes to be invoked is huge, the number of definitions required is huge, and when the methods and attributes need to be changed subsequently, it will cause difficulties in maintenance.
[0004] Aiming at the problem that when performing cross-process communication in the related technology, it is necessary to separately define the methods and attributes to be invoked on the two cross-process services, resulting in a large workload and difficult maintenance, no effective solution has been proposed yet. Summary of the Invention
[0005] This application provides a data invocation method, apparatus, and electronic device to solve the problem in the related technology that when performing cross-process communication, it is necessary to separately define the methods and attributes to be invoked on the two cross-process services, resulting in a large workload and difficult maintenance.
[0006] According to one aspect of this application, a data invocation method is provided. The method includes: the virtual RPC service of the first process receives a call request sent by the first RPC service of the first process, where the call request is used to request to call a target method and / or target attribute from the second RPC service of the second process, and the service definitions of the virtual RPC service and the second RPC service are the same; the virtual RPC service sends the call request to the second RPC service through a target protocol, and receives the return data obtained by the second RPC service in response to the call request through the target protocol; the virtual RPC service sends the return data to the first RPC service to complete the data invocation between the first process and the second process.
[0007] Optionally, before the virtual RPC service of the first process receives a call request sent by the first RPC service of the first process, the method further includes: creating, in the first process, a virtual service identical to the service definition of the second RPC service to obtain the virtual RPC service.
[0008] Optionally, the method further includes: defining a preset attribute call interface and a preset method call interface for the RPC protocol to obtain a target protocol, where the preset attribute call interface is used to call various attribute call requests, and the preset method call interface is used to call various method call requests.
[0009] Optionally, the virtual RPC service sends the call request to the second RPC service through the target protocol and receives the return data obtained by the second RPC service in response to the call request through the target protocol, including: the virtual RPC service serializes the call request and sends it to the second RPC service through the target protocol; the virtual RPC service receives, through the target protocol, the return data obtained by the second RPC service in response to the call request, where the return data is the serialized return data of the second RPC service.
[0010] Optionally, when the call request is used to request the second RPC service to call a target attribute, the virtual RPC service receives, through the target protocol, the return data obtained by the second RPC service in response to the call request, including: when the target attribute exists in the second RPC service, the virtual RPC service receives the target attribute value returned by the second RPC service based on the preset attribute call interface.
[0011] Optionally, when the call request is used to request the second RPC service to call a target method, the virtual RPC service receives, through the target protocol, the return data obtained by the second RPC service in response to the call request, including: when the execution of the target method by the second RPC service is successful, the virtual RPC service receives the execution result of the target method returned by the second RPC service based on the preset method call interface.
[0012] According to one aspect of the present application, another data calling method is provided. The method includes: defining a preset attribute calling interface and a preset method calling interface for the RPC protocol to obtain a target protocol, where the preset attribute calling interface is used to call various attribute calling requests, and the preset method calling interface is used to call various method calling requests; after receiving a serialized calling request sent by a virtual RPC service outside the target process through the target protocol, the fourth RPC service of the target process responds to the calling request to obtain return data, where the calling request is information for the third RPC service outside the target process to request the fourth RPC service to call a target method and / or a target attribute, the virtual RPC service has the same service definition as the fourth RPC service, and the virtual RPC service and the third RPC service are services of the same process; the fourth RPC service serializes the return data and sends it to the virtual RPC service through the target protocol to complete cross-process data calling.
[0013] According to another aspect of the present application, a data calling device is provided. The device includes: a first receiving unit, configured to receive a calling request sent by the first RPC service of the first process using the virtual RPC service of the first process, where the calling request is used to request the second RPC service of the second process to call a target method and / or a target attribute, and the virtual RPC service has the same service definition as the second RPC service; a first sending unit, configured to send the calling request to the second RPC service through the target protocol using the virtual RPC service and receive the return data obtained by the second RPC service in response to the calling request through the target protocol; a second sending unit, configured to deserialize the return data using the virtual RPC service and send it to the first RPC service to complete data calling between the first process and the second process.
[0014] According to another aspect of the present application, another data calling device is provided. The device includes: a defining unit, configured to define a preset attribute calling interface and a preset method calling interface for the RPC protocol to obtain a target protocol, where the preset attribute calling interface is used to call various attribute calling requests, and the preset method calling interface is used to call various method calling requests; a responding unit, configured to, after receiving a serialized calling request sent by a virtual RPC service outside the target process through the target protocol, the fourth RPC service of the target process responds to the calling request to obtain return data, where the calling request is information for the third RPC service outside the target process to request the fourth RPC service to call a target method and / or a target attribute, the virtual RPC service has the same service definition as the fourth RPC service, and the virtual RPC service and the third RPC service are services of the same process; a third sending unit, configured to serialize the return data using the fourth RPC service and send it to the virtual RPC service through the target protocol to complete cross-process data calling.
[0015] To achieve the above object, according to another aspect of the present application, there is provided an electronic device, which includes at least one processor, at least one memory connected to the processor, and a bus; wherein, the processor and the memory communicate with each other through the bus; the processor is configured to call program instructions in the memory to execute the above data calling method.
[0016] Through the present application, the following steps are adopted: The virtual RPC service of the first process receives a call request sent by the first RPC service of the first process, where the call request is used to request to call a target method and / or target attribute from the second RPC service of the second process, and the virtual RPC service has the same service definition as the second RPC service; the virtual RPC service sends the call request to the second RPC service through the target protocol and receives the return data obtained by the second RPC service in response to the call request through the target protocol; the virtual RPC service sends the return data to the first RPC service to complete the data call between the first process and the second process, solving the problem in the related art that when performing cross-process communication, it is necessary to separately define the methods and attributes to be called on two cross-process services, resulting in a large workload and difficulty in maintenance. By using the virtual RPC service of the first process to implement the communication between the RPC service of the first process and the RPC service of the second process, the effect of not needing to separately define the methods and attributes to be called on two cross-process services when performing cross-process communication, reducing the workload and maintenance difficulty is achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The drawings constituting a part of the present application are used to provide a further understanding of the present application. The schematic embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation to the present application. In the drawings:
[0018] Figure 1 is a flowchart of the data calling method provided by the embodiment of the present application;
[0019] Figure 2 is a flowchart of another data calling method provided by the embodiment of the present application;
[0020] Figure 3 is a schematic diagram of the data calling device provided by the embodiment of the present application;
[0021] Figure 4 is a schematic diagram of another data calling device provided by the embodiment of the present application; and
[0022] Figure 5 is a schematic diagram of the electronic device provided by the embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0023] It should be noted that, without conflict, the embodiments in the present application and the features in the embodiments may be combined with each other. The present application will be described in detail below with reference to the drawings and in conjunction with the embodiments.
[0024] In order to enable those skilled in the art to better understand the solution of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without making creative efforts shall fall within the protection scope of the present application.
[0025] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily need to be used to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so as to describe the embodiments of the present application here. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device comprising a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0026] According to an embodiment of the present application, a data call method is provided.
[0027] Figure 1 is a flowchart of the data call method according to the embodiment of the present application. As Figure 1 shown, the method includes the following steps:
[0028] Step S101, the virtual RPC service of the first process receives a call request sent by the first RPC service of the first process, where the call request is used to request to call a target method and / or a target attribute from the second RPC service of the second process, and the virtual RPC service has the same service definition as the second RPC service.
[0029] It should be noted that the virtual RPC service and the first RPC service are services of the first process, and the communication between them is intra-process communication. The virtual RPC service and the second RPC service are located in different processes, but the virtual RPC service is an agent service of the second RPC service, equivalent to a substitute of the second RPC service. The virtual RPC service and the second RPC service have different execution logics but the same service definition. Therefore, the first RPC service can complete the service request for the second RPC service through the virtual RPC service without directly communicating with the second RPC service.
[0030] Specifically, when the first RPC service of the first process communicates with the second RPC service of the second process, the first RPC service first sends a call request to the virtual RPC service of the first process. After receiving the call request, the virtual RPC service sends a call request to the second RPC service and receives the return result, thereby implementing the request of the first RPC service.
[0031] Optionally, in the data call method provided in the embodiment of the present application, before the virtual RPC service of the first process receives the call request sent by the first RPC service of the process, the method further includes: creating a virtual service in the first process that has the same service definition as the second RPC service to obtain the virtual RPC service.
[0032] It should be noted that the virtual RPC service is a calling end and has all the function interfaces of the second RPC service. Since the virtual RPC service and the first RPC service are services of the same process, the communication between the two belongs to intra-process communication. When the first RPC service needs to call the methods or attributes of the second RPC service, the virtual RPC service can be used as a substitute for the second RPC service, and the virtual RPC service can be directly called.
[0033] Therefore, when the first RPC service communicates with the second RPC service, it is not necessary to define all the function definitions between the two at the communication layer of the first RPC service and the second RPC service. Remote calls can be made through the common methods between the virtual RPC service and the second RPC service, which facilitates the maintenance and modification of the function interfaces.
[0034] Step S102, the virtual RPC service sends the call request to the second RPC service through the target protocol and receives the return data obtained by the second RPC service in response to the call request through the target protocol.
[0035] Specifically, the virtual RPC service itself does not execute the call request, but sends the call request to the second RPC service through the target protocol. In the second RPC service, attribute lookup and method execution are performed, and the corresponding results are sent to the virtual RPC service and finally sent to the first RPC service.
[0036] To facilitate the call of methods and attributes, optionally, in the data call method provided in the embodiment of the present application, the method further includes: defining a preset attribute call interface and a preset method call interface for the RPC protocol to obtain the target protocol, where the preset attribute call interface is used to call various attribute call requests, and the preset method call interface is used to call various method call requests.
[0037] It should be noted that in the embodiments of the present application, a variety of attribute call interfaces and a variety of method call interfaces that need to be defined in the communication layer are abstracted, and only one preset attribute call interface and one preset method call interface are defined. The preset attribute call interface is a common attribute call interface that can support the call of multiple attributes, and the preset method call interface is a common method call interface that can support the call of multiple methods. Therefore, when the supported called attributes and methods are changed, there is no need to generate a new service definition.
[0038] Optionally, in the data call method provided by the embodiments of the present application, the virtual RPC service sends a call request to the second RPC service through the target protocol, and receives the return data obtained by the second RPC service in response to the call request through the target protocol, including: the virtual RPC service serializes the call request and sends it to the second RPC service through the target protocol; the virtual RPC service receives the return data obtained by the second RPC service in response to the call request through the target protocol, where the return data is the serialized return data of the second RPC service.
[0039] For example, the target protocol can be the GRPC protocol, and serialization can be binary. Specifically, the virtual RPC service encapsulates and packs the call request in a binary way, and remotely transmits the packed result to the second RPC service through the GRPC protocol. After receiving the packed call request, the second RPC service performs de - binary on the packed content, executes the call request based on the result of de - binary, and finally returns the execution result to the virtual RPC service after binary.
[0040] Optionally, in the data call method provided by the embodiments of the present application, when the call request is used to request the call of a target attribute from the second RPC service, the virtual RPC service receives the return data obtained by the second RPC service in response to the call request through the target protocol, including: in the case where the target attribute exists in the second RPC service, the virtual RPC service receives the target attribute value returned by the second RPC service based on the preset attribute call interface.
[0041] Specifically, when requesting to call a target attribute, the data packet sent to the second RPC service includes the request parameters of the target attribute. The request parameters of the target attribute include the name and type of the attribute. The target attribute value is searched for in the second RPC service according to the request parameters of the target attribute. In the case where it is found, the target attribute value is serialized, and the serialized result is sent to the virtual RPC service through the target protocol.
[0042] In addition, in the case where the target attribute does not exist in the second RPC service, the second RPC service returns a message indicating whether the request was successful and the log of what kind of error occurred.
[0043] Optionally, in the data calling method provided in the embodiments of the present application, when the call request is used to request to call a target method from a second RPC service, the virtual RPC service receives the return data obtained by the second RPC service in response to the call request through a target protocol, including: when the second RPC service successfully executes the target method, the virtual RPC service receives the execution result of the target method returned by the second RPC service based on a preset method call interface.
[0044] Specifically, when requesting to call a target method, the data packet sent to the second RPC service includes the request parameters of the target method. The request parameters of the target method include the name of the method and a parameter type table. The parameter type table contains the name and value of the parameter. The target method is executed in the second RPC service according to the request parameters of the target method. When the execution is successful, the execution result is serialized, and the serialized result is sent to the virtual RPC service through the target protocol.
[0045] In addition, when the execution of the target method in the second RPC service fails, the second RPC service returns a message indicating whether the request was successful and the log of what kind of error occurred.
[0046] Step S103, the virtual RPC service sends the return data to the first RPC service to complete the data call between the first process and the second process.
[0047] Specifically, the virtual RPC service receives the serialized return data, deserializes the data, and sends the deserialized result to the first RPC service.
[0048] In the data calling method provided in the embodiments of the present application, the virtual RPC service of the first process receives the call request sent by the first RPC service of the first process, where the call request is used to request to call a target method and / or target attribute from the second RPC service of the second process, and the service definitions of the virtual RPC service and the second RPC service are the same; the virtual RPC service sends the call request to the second RPC service through the target protocol and receives the return data obtained by the second RPC service in response to the call request through the target protocol; the virtual RPC service sends the return data to the first RPC service to complete the data call between the first process and the second process, which solves the problem in the related art that when performing cross-process communication, it is necessary to separately define the methods and attributes to be called on two cross-process services, resulting in a large workload and difficulty in maintenance. By using the virtual RPC service of the first process to implement the communication between the RPC service of the first process and the RPC service of the second process, the effect of not needing to separately define the methods and attributes to be called on two cross-process services when performing cross-process communication, reducing the workload and maintenance difficulty is achieved.
[0049] Figure 2 is a flowchart of a data calling method according to an embodiment of the present application. As Figure 2 shown, the method includes the following steps:
[0050] Step S201: Define a preset attribute calling interface and a preset method calling interface for the RPC protocol to obtain a target protocol. Among them, the preset attribute calling interface is used to call multiple attribute calling requests, and the preset method calling interface is used to call multiple method calling requests.
[0051] It should be noted that in the embodiment of the present application, multiple attribute calling interfaces and multiple method calling interfaces that need to be defined in the communication layer are abstracted, and only one preset attribute calling interface and one preset method calling interface are defined. The preset attribute calling interface is a common attribute calling interface that can support the calling of multiple attributes, and the preset method calling interface is a common method calling interface that can support the calling of multiple methods. Therefore, when the attributes and methods to be called change, there is no need to generate a new service definition.
[0052] Step S202: After receiving the serialized calling request sent by the virtual RPC service outside the target process through the target protocol, the fourth RPC service of the target process responds to the calling request to obtain return data. Among them, the calling request is information for the third RPC service outside the target process to request the fourth RPC service to call a target method and / or a target attribute. The service definitions of the virtual RPC service and the fourth RPC service are the same, and the virtual RPC service and the third RPC service are services of the same process.
[0053] It should be noted that the virtual RPC service is a calling end, and it has all the function interfaces of the third RPC service. Since the virtual RPC service is a service of the target process, when the fourth RPC service of the target process needs to call the method or attribute of the third RPC service outside the process, the virtual RPC service can be used as a substitute for the third RPC service, and the virtual RPC service can be directly called. The communication between the two belongs to intra-process communication.
[0054] Therefore, when the fourth RPC service communicates with the third RPC service, there is no need to define all the functions between the two in the communication layer of the fourth RPC service and the third RPC service. Remote calls are made through the common methods between the virtual RPC service and the third RPC service, which is convenient for the maintenance and modification of function interfaces.
[0055] In addition, it should be noted that the target protocol can be the GRPC protocol, and serialization can be binary. Specifically, the virtual RPC service encapsulates and packs the calling request in a binary way and remotely transmits the packing result to the third RPC service through the GRPC protocol.
[0056] Step S203: The fourth RPC service serializes the returned data and sends it to the virtual RPC service through the target protocol to complete cross-process data invocation.
[0057] Specifically, the virtual RPC service receives the serialized returned data, deserializes the data, and sends the deserialized result to the fourth RPC service, and the fourth RPC service receives the result of the requested invocation.
[0058] The data invocation method provided by the embodiment of the present application defines a preset attribute invocation interface and a preset method invocation interface for the RPC protocol to obtain the target protocol. The preset attribute invocation interface is used to invoke various attribute invocation requests, and the preset method invocation interface is used to invoke various method invocation requests. After receiving the serialized invocation request sent by the virtual RPC service outside the target process through the target protocol, the fourth RPC service in the target process responds to the invocation request to obtain the returned data. The invocation request is information for the third RPC service outside the target process to request the fourth RPC service to invoke the target method and / or target attribute. The service definitions of the virtual RPC service and the fourth RPC service are the same, and the virtual RPC service and the third RPC service are services in the same process. The fourth RPC service serializes the returned data and sends it to the virtual RPC service through the target protocol to complete cross-process data invocation, which solves the problem in the related art that when performing cross-process communication, the methods and attributes to be invoked need to be defined separately on two cross-process services, resulting in a large workload and difficult maintenance. By using the virtual RPC service of the target process to implement communication between the RPC service of the target process and the RPC service outside the target process, the effect of not needing to define the methods and attributes to be invoked separately on two cross-process services when performing cross-process communication, reducing the workload and maintenance difficulty is achieved.
[0059] It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. And although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here.
[0060] The embodiment of the present application also provides a data invocation device. It should be noted that the data invocation device of the embodiment of the present application can be used to execute the data invocation method provided by the embodiment of the present application. The following introduces the data invocation device provided by the embodiment of the present application.
[0061] Figure 3 is a schematic diagram of the data invocation device according to the embodiment of the present application. As Figure 3 shown, the device includes: a first receiving unit 31, a first sending unit 32, and a second sending unit 33.
[0062] Specifically, a first receiving unit 31 is configured to receive a call request sent by a first RPC service of a first process by using a virtual RPC service of the first process, where the call request is used to request to call a target method and / or a target attribute from a second RPC service of a second process, and the virtual RPC service has the same service definition as the second RPC service.
[0063] A first sending unit 32 is configured to send the call request to the second RPC service through a target protocol by using the virtual RPC service, and receive return data obtained by the second RPC service in response to the call request through the target protocol.
[0064] A second sending unit 33 is configured to deserialize the return data by using the virtual RPC service and send the deserialized return data to the first RPC service to complete data call between the first process and the second process.
[0065] The data call device provided in an embodiment of the present application receives, by a first receiving unit 31, a call request sent by a first RPC service of a first process by using a virtual RPC service of the first process, where the call request is used to request to call a target method and / or a target attribute from a second RPC service of a second process, and the virtual RPC service has the same service definition as the second RPC service; a first sending unit 32 sends the call request to the second RPC service through a target protocol by using the virtual RPC service, and receives return data obtained by the second RPC service in response to the call request through the target protocol; a second sending unit 33 deserializes the return data by using the virtual RPC service and sends the deserialized return data to the first RPC service to complete data call between the first process and the second process, thereby solving the problem in the related art that when performing cross-process communication, methods and attributes to be called need to be defined separately on two cross-process services, resulting in a large workload and difficulty in maintenance. By using the virtual RPC service of the first process to implement communication between the RPC service of the first process and the RPC service of the second process, the effect of not needing to define methods and attributes to be called separately on two cross-process services when performing cross-process communication, reducing the workload and maintenance difficulty is achieved.
[0066] Optionally, in the data call device provided in an embodiment of the present application, the device further includes: a creation unit, configured to create a virtual service having the same service definition as the second RPC service in the first process before the virtual RPC service of the first process receives a call request sent by the first RPC service of the first process, to obtain the virtual RPC service.
[0067] Optionally, in the data calling device provided in the embodiments of the present application, the device further includes: a definition unit, configured to define a preset attribute calling interface and a preset device calling interface for the RPC protocol to obtain a target protocol, where the preset attribute calling interface is used to call multiple attribute calling requests, and the preset device calling interface is used to call multiple device calling requests.
[0068] Optionally, in the data calling device provided in the embodiments of the present application, the first sending unit 32 includes: a serialization module, configured to serialize the calling request through the virtual RPC service and send it to the second RPC service through the target protocol; a receiving module, configured to receive, through the virtual RPC service through the target protocol, the return data obtained by the second RPC service in response to the calling request, where the return data is the serialized return data of the second RPC service.
[0069] Optionally, in the data calling device provided in the embodiments of the present application, the receiving module includes: a first receiving sub-module, configured to, when the calling request is used to request to call a target attribute from the second RPC service, and when the target attribute exists in the second RPC service, the virtual RPC service receives the target attribute value returned by the second RPC service based on the preset attribute calling interface.
[0070] Optionally, in the data calling device provided in the embodiments of the present application, the receiving module includes: a second receiving sub-module, configured to, when the calling request is used to request to call a target method from the second RPC service, and when the execution of the target method by the second RPC service is successful, the virtual RPC service receives the execution result of the target method returned by the second RPC service based on the preset device calling interface.
[0071] Figure 4 is a schematic diagram of the data calling device according to the embodiments of the present application. As Figure 4 shown, the device includes: a definition unit 41, a response unit 42, and a third sending unit 43.
[0072] Specifically, the definition unit 41 is configured to define a preset attribute calling interface and a preset method calling interface for the RPC protocol to obtain a target protocol, where the preset attribute calling interface is used to call multiple attribute calling requests, and the preset method calling interface is used to call multiple method calling requests.
[0073] The response unit 42 is configured to, after receiving the serialized calling request sent by the virtual RPC service outside the target process through the target protocol, the fourth RPC service of the target process responds to the calling request to obtain return data, where the calling request is information for the third RPC service outside the target process to request to call a target method and / or a target attribute from the fourth RPC service, the service definitions of the virtual RPC service and the fourth RPC service are the same, and the virtual RPC service and the third RPC service are services of the same process.
[0074] A third sending unit 43 is configured to serialize the returned data by using a fourth RPC service and send the serialized data to a virtual RPC service through a target protocol, so as to complete cross-process data invocation.
[0075] The data invocation device provided by the embodiment of the present application defines, by a defining unit 41, a preset attribute invocation interface and a preset method invocation interface for an RPC protocol to obtain a target protocol, where the preset attribute invocation interface is used to invoke various attribute invocation requests, and the preset method invocation interface is used to invoke various method invocation requests; after a response unit 42 receives a serialized invocation request sent by a virtual RPC service outside a target process through the target protocol, a fourth RPC service of the target process responds to the invocation request to obtain returned data, where the invocation request is information for a third RPC service outside the target process to request the fourth RPC service to invoke a target method and / or a target attribute, the virtual RPC service and the fourth RPC service have the same service definition, and the virtual RPC service and the third RPC service are services of the same process; the third sending unit 43 serializes the returned data by using the fourth RPC service and sends the serialized data to the virtual RPC service through the target protocol to complete cross-process data invocation, thereby solving the problem in the related art that when performing cross-process communication, methods and attributes to be invoked need to be defined separately on two cross-process services, resulting in a large workload and difficult maintenance. By using the virtual RPC service of the first process to implement communication between the RPC service of the first process and the RPC service of the second process, the effect of not needing to define methods and attributes to be invoked separately on two cross-process services when performing cross-process communication, reducing the workload and maintenance difficulty is achieved.
[0076] The data invocation device includes a processor and a memory. The above-mentioned defining unit 41, response unit 42, third sending unit 43, etc. are all stored in the memory as program units, and the processor executes the above program units stored in the memory to implement corresponding functions.
[0077] The processor includes a kernel, and the kernel retrieves corresponding program units from the memory. One or more kernels can be set, and by adjusting kernel parameters, the problem in the related art that when performing cross-process communication, methods and attributes to be invoked need to be defined separately on two cross-process services, resulting in a large workload and difficult maintenance is solved.
[0078] An embodiment of the present invention provides a storage medium, on which a program is stored, and when the program is executed by a processor, the data invocation method is implemented.
[0079] An embodiment of the present invention provides a processor, and the processor is used to run a program, where when the program runs, the data invocation method is executed.
[0080] An embodiment of the present invention provides a device, such as Figure 5 shown. The device includes at least one processor, at least one memory connected to the processor, and a bus. Among them, the processor and the memory complete communication with each other through the bus. The processor is used to call program instructions in the memory to execute the above data calling method. The device herein can be a server, a PC, a PAD, a mobile phone, etc.
[0081] The present application also provides a computer program product, which is adapted to execute a program initialized with the following method steps when executed on a data processing device: The virtual RPC service of the first process receives a call request sent by the first RPC service of the first process, where the call request is used to request to call a target method and / or a target attribute from the second RPC service of the second process, and the service definitions of the virtual RPC service and the second RPC service are the same; the virtual RPC service sends the call request to the second RPC service through the target protocol and receives the return data obtained by the second RPC service in response to the call request through the target protocol; the virtual RPC service sends the return data to the first RPC service to complete the data call between the first process and the second process.
[0082] Before the virtual RPC service of the first process receives the call request sent by the first RPC service of the first process, the method further includes: creating a virtual service in the first process with the same service definition as the second RPC service to obtain the virtual RPC service.
[0083] The method further includes: defining a preset attribute call interface and a preset method call interface for the RPC protocol to obtain the target protocol, where the preset attribute call interface is used to call various attribute call requests, and the preset method call interface is used to call various method call requests.
[0084] The virtual RPC service sends the call request to the second RPC service through the target protocol and receives the return data obtained by the second RPC service in response to the call request through the target protocol, including: the virtual RPC service serializes the call request and sends it to the second RPC service through the target protocol; the virtual RPC service receives the return data obtained by the second RPC service in response to the call request through the target protocol, where the return data is the serialized return data of the second RPC service.
[0085] When the call request is used to request to call a target attribute from the second RPC service, the virtual RPC service receives the return data obtained by the second RPC service in response to the call request through the target protocol, including: when the target attribute exists in the second RPC service, the virtual RPC service receives the target attribute value returned by the second RPC service based on the preset attribute call interface.
[0086] When the call request is used to request the invocation of a target method from a second RPC service, the virtual RPC service receives, via a target protocol, return data obtained by the second RPC service in response to the call request, including: in the case where the second RPC service successfully executes the target method, the virtual RPC service receives, based on a preset method call interface, the execution result of the target method returned by the second RPC service.
[0087] This application is described with reference to the flowcharts and / or block diagrams of methods, apparatuses (systems), and computer program products according to embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of flows and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to the processors of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, such that the instructions executed by the processors of the computer or other programmable data processing devices generate means for implementing the functions specified in one Figure 1 flow or multiple flows and / or blocks Figure 1 or multiple blocks.
[0088] In a typical configuration, a device includes one or more processors (CPUs), a memory, and a bus. The device may also include an input / output interface, a network interface, etc.
[0089] The memory may include non-permanent memory in a computer-readable medium, in the form of random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash memory (flash RAM), and the memory includes at least one storage chip. The memory is an example of a computer-readable medium.
[0090] Computer-readable media include permanent and non-permanent, removable and non-removable media that can store information by any method or technology. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory, or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD), or other optical storage, magnetic cassette tapes, magnetic disk storage, or other magnetic storage devices, or any other non-transmission media that can be used to store information accessible by a computing device. As defined herein, computer-readable media do not include transitory computer-readable media, such as modulated data signals and carrier waves.
[0091] It should also be noted that the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, commodity or device comprising a series of elements not only includes those elements, but also includes other elements not expressly listed, or further includes elements inherent to such process, method, commodity or device. Without further limitation, an element defined by the statement "comprising one..." does not exclude the presence of additional identical elements in the process, method, commodity or device comprising the element.
[0092] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system or a computer program product. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0093] The above are only the embodiments of the present application and are not intended to limit the present application. For those skilled in the art, various changes and modifications can be made to the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included within the scope of the claims of the present application.
Claims
1. A data calling method, characterized in that, including: The virtual RPC service of the first process receives a call request sent by the first RPC service of the first process, where the call request is used to request to call a target method and / or a target attribute from the second RPC service of the second process, and the service definitions of the virtual RPC service and the second RPC service are the same; The virtual RPC service sends the call request to the second RPC service through a target protocol, and receives return data obtained by the second RPC service in response to the call request through the target protocol; The virtual RPC service sends the return data to the first RPC service to complete data call between the first process and the second process; The method further includes: defining a preset attribute call interface and a preset method call interface for the RPC protocol to obtain the target protocol, where the preset attribute call interface is used to call various attribute call requests, and the preset method call interface is used to call various method call requests.
2. The method according to claim 1, wherein Before the virtual RPC service of the first process receives the call request sent by the first RPC service of the first process, the method further includes: creating, in the first process, a virtual service with the same service definition as the second RPC service to obtain the virtual RPC service.
3. The method according to claim 1, wherein The virtual RPC service sending the call request to the second RPC service through a target protocol and receiving return data obtained by the second RPC service in response to the call request through the target protocol includes: serializing the call request by the virtual RPC service and sending it to the second RPC service through the target protocol; the virtual RPC service receiving, through the target protocol, the return data obtained by the second RPC service in response to the call request, where the return data is the serialized return data of the second RPC service.
4. The method according to claim 1, wherein When the call request is used to request to call the target attribute from the second RPC service, the virtual RPC service receiving, through the target protocol, the return data obtained by the second RPC service in response to the call request includes: in the case where the target attribute exists in the second RPC service, the virtual RPC service receives the target attribute value returned by the second RPC service based on the preset attribute call interface.
5. The method according to claim 1, wherein When the call request is used to request to call the target method from the second RPC service, the virtual RPC service receiving, through the target protocol, the return data obtained by the second RPC service in response to the call request includes: in the case where the second RPC service successfully executes the target method, the virtual RPC service receives the execution result of the target method returned by the second RPC service based on the preset method call interface.
6. A data calling method, characterized in that, including: defining a preset attribute call interface and a preset method call interface for the RPC protocol to obtain a target protocol, where the preset attribute call interface is used to call various attribute call requests, and the preset method call interface is used to call various method call requests; After receiving the serialized call request sent by the virtual RPC service outside the target process through the target protocol, the fourth RPC service of the target process responds to the call request to obtain return data. Among them, the call request is information for the third RPC service outside the target process to request the fourth RPC service to call a target method and / or a target attribute. The virtual RPC service has the same service definition as the fourth RPC service, and the virtual RPC service and the third RPC service are services of the same process; The fourth RPC service serializes the return data and sends it to the virtual RPC service through the target protocol to complete cross-process data calls.
7. A data calling device, characterized in that Including: A first receiving unit, configured to use the virtual RPC service of the first process to receive the call request sent by the first RPC service of the first process. Among them, the call request is used to request the second RPC service of the second process to call a target method and / or a target attribute, and the virtual RPC service has the same service definition as the second RPC service; A first sending unit, configured to use the virtual RPC service to send the call request to the second RPC service through the target protocol, and receive the return data obtained by the second RPC service in response to the call request through the target protocol; A second sending unit, configured to use the virtual RPC service to deserialize the return data and send it to the first RPC service to complete the data call between the first process and the second process; A defining unit, configured to define a preset attribute call interface and a preset method call interface for the RPC protocol to obtain a target protocol. Among them, the preset attribute call interface is used to call various attribute call requests, and the preset method call interface is used to call various method call requests.
8. A data call device, characterized in that Including: A defining unit, configured to define a preset attribute call interface and a preset method call interface for the RPC protocol to obtain a target protocol. Among them, the preset attribute call interface is used to call various attribute call requests, and the preset method call interface is used to call various method call requests; A response unit, configured to after receiving the serialized call request sent by the virtual RPC service outside the target process through the target protocol, the fourth RPC service of the target process responds to the call request to obtain return data. Among them, the call request is information for the third RPC service outside the target process to request the fourth RPC service to call a target method and / or a target attribute. The virtual RPC service has the same service definition as the fourth RPC service, and the virtual RPC service and the third RPC service are services of the same process; A third sending unit, configured to use the fourth RPC service to serialize the return data and send it to the virtual RPC service through the target protocol to complete cross-process data calls.
9. An electronic device, the device comprising at least one processor, at least one memory connected to the processor, and a bus; wherein, The processor and the memory complete communication with each other through the bus; The processor is configured to call the program instructions in the memory to execute the data call method according to any one of claims 1-6.
Citation Information
Patent Citations
Cross-process calling method and device of single-case method, equipment and storage medium
CN109739666A