Remote calling method and device, function development method and device, electronic equipment and medium
By designing a fixed format message structure, the functional parameters and parameter values required for remote calls are directly transmitted, which solves the problem of high computing power requirements for nodes with limited computing resources by RPC remote calls, and realizes the expansion of the functional scope and resource conservation.
Patent Information
- Application Number
- CN202311287278.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-28
- Publication Date
- 2025-03-28
AI Technical Summary
The remote calling mechanism based on RPC has too high demand for computing power for computing nodes with limited computing resources, which makes these nodes unable to effectively implement remote calling of functions, and their function scope is limited.
A message format is designed, in which the first data area represents the functional semantics of the target function in a fixed format. The functional structure includes function identifiers, functional parameters and parameter values, avoiding the serialization and deserialization steps, and directly converting the message into binary data transmission.
Reduced the requirements for computing power resources by remote calls, saved resource expenditure of computing nodes, and expanded the functional scope of computing nodes, making it suitable for scenarios with limited computing power resources.
Smart Images

Figure CN119718708A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of software technology, and in particular to a remote calling method, a function development method, a device, an electronic device and a medium. Background Art
[0002] RPC (Remote Procedure Call) is often used in distributed systems, such as cloud computing, microservice architecture, distributed databases, etc. RPC can realize remote calls between different functions, thereby realizing the collaboration of distributed systems.
[0003] However, the remote call mechanism based on RPC has high computing power requirements. In particular, the heavyweight standard RPC protocol is powerful but has a complex protocol stack and high implementation cost. For computing nodes with limited computing resources, it is even more difficult to meet the computing power requirements of RPC. This results in these computing nodes being unable to use the RPC mechanism to implement remote calls of functions, and the range of functions that can be implemented is limited. Summary of the invention
[0004] The purpose of the embodiments of the present application is to provide a remote calling method, a function development method, a device, an electronic device and a medium to achieve the technical effect of expanding the functional scope of a computing node.
[0005] In a first aspect, an embodiment of the present application provides a remote calling method, the method comprising:
[0006] Determine the target function to be called remotely;
[0007] Generate a message corresponding to the target function; wherein the message includes a first data area, the first data area includes a function structure of the target function, the function structure includes a function identifier, a function parameter, and a parameter value of the function parameter of the target function;
[0008] The message is sent to the opposite node.
[0009] In the technical solution of the embodiment of the present application, by designing a message format, the first data area in the message represents the functional semantics of the call itself in a fixed format, ensuring the consistency of concepts and methods, simplicity of implementation and flexibility of expansion. At the same time, the functional structure also carries the functional parameters and parameter values required for the target function. Therefore, the computing node can directly convert the message into binary data and transmit it in the network without serialization and deserialization, thereby saving the computing power expenditure required for remote calls and reducing the requirements of remote calls on computing resources. Therefore, it is suitable for computing nodes with limited computing resources.
[0010] In some embodiments, the method is applied to a calling node that remotely calls the target function, and the peer node is a responding node that provides the target function; wherein the message corresponding to the target function includes a call command; and the call command is used to request the responding node to execute the target function. By executing the remote call method by the calling node, the calling node can generate a call command for the target function according to the steps of the active call mode, so that the responding node can execute the target function according to the call command. The entire remote call process is simple and fast, and is suitable for computing nodes with limited computing resources.
[0011] In some embodiments, the generating of the message corresponding to the target function includes: determining the function parameter to be assigned in the target function; obtaining the parameter value of the function parameter input by the user; and generating a call command including the function parameter and the parameter value. When generating the call command corresponding to the target function, the parameter value of the function parameter is configured by the user so that the target function can be executed according to the user's needs to meet the business requirements.
[0012] In some embodiments, the method is applied to a response node that provides the target function, and the peer node is a calling node that remotely calls the target function; the generating of a message corresponding to the target function includes: in response to a call command, after executing the target function indicated by the call command, generating a call response based on the execution result. By executing the remote call method by the response node, the response node can generate a call response of the target function according to the steps of the active call mode, so that the calling node can know the execution result of the target function according to the call response. The entire remote call process is simple and fast, and is suitable for computing nodes with limited computing resources.
[0013] In some embodiments, generating a call response based on the execution result includes: determining a parameter value of a function parameter of the target function based on the execution result; and generating a call response including the function parameter and the parameter value. By determining the parameter value of the function parameter according to the execution result of the target function, the function parameter and its parameter value can reflect the execution result of the target function. The calling node can directly obtain the call result of the target function based on the call response.
[0014] In some embodiments, the method is applied to a response node that provides the target function, and the peer node is a calling node that remotely calls the target function; the generating of a message corresponding to the target function includes: generating a notification message in response to satisfying a notification trigger condition. Since the first data area in the notification message represents the functional semantics of the call itself in a fixed format, the functional structure represents the target function and carries the functional parameters and parameter values used to represent the notification information. Therefore, after receiving the notification message, the calling node can be informed of the notification information based on the target function. Thus, the remote call of the target function is completed based on the passive call mode.
[0015] In some embodiments, when the target function includes multiple functions, the first data area of the message includes multiple function structures corresponding to the multiple target functions. By setting the function structures corresponding to the multiple target functions in the first data area, a call command can request the remote call of multiple target functions; a call response can feedback the execution results of multiple target functions; a notification message can carry the notification information of multiple target functions, thereby greatly reducing the overhead of remote calls and improving the efficiency of remote calls.
[0016] In some embodiments, the message further includes a second data area; the second data area is used to transmit additional data related to the target function. Through the cooperation of the first data area and the second data area, the first data area can be used to describe the functional semantics of the target function, and the second data area can transmit large or complex additional data, so that the generated message can realize both the data reading and writing function of the data reading and writing communication protocol and the complex remote calling mechanism, thereby integrating the two functions that can be realized by the data reading and writing protocol and the remote calling protocol.
[0017] In some embodiments, the function structure also includes data information of additional data corresponding to the target function; the data information is used to locate the additional data in the second data area. By setting the data information of the additional data of the target function in the function structure, the computing node can accurately read the corresponding additional data from the second data area according to the data information.
[0018] In some embodiments, the message further includes a third data area for indicating the length of the first data area and / or the length of the second data area. The third data area indicates the length of the first data area and / or the length of the second data area, so that the computing node can accurately locate the positions of the first data area and the second data area in the message according to the third data area.
[0019] In some embodiments, the first data area is used to transmit string data; the second data area is used to transmit binary data. Through the cooperation between the first data area and the second data area, the first data area carries string data, and the second data area carries binary data, so that text data and binary data can be combined, which is compatible with the flexibility of the text protocol and the high efficiency of the binary protocol, and realizes highly flexible functional semantic expression and efficient additional data transmission.
[0020] In a second aspect, an embodiment of the present application provides a method for developing a remote call function, the method comprising:
[0021] Determine the function parameters and additional data required for the remote function;
[0022] Determine an operation unit for realizing remote calling of the remote function; the operation unit includes an interactive operation unit and a notification operation unit;
[0023] Developing a software program for a computing node so as to generate a message corresponding to the remote function using the software program; the computing node includes a calling node and / or a responding node;
[0024] The message includes a first data area, the first data area includes a function structure of the remote function, the function structure includes a function identifier of the remote function, the function parameter, and a parameter value of the function parameter.
[0025] According to the embodiment of the present application, a method for developing remote functions is provided, so that when new functions are subsequently proposed, the above method can be used to implement remote calls, which has the flexibility of expansion.
[0026] In a third aspect, an embodiment of the present application provides a remote calling device, the device comprising:
[0027] A determination module, used to determine a target function to be remotely called;
[0028] A generating module, configured to generate a message corresponding to the target function; wherein the message comprises a first data area, the first data area comprises a function structure of the target function, the function structure comprises a function identifier, a function parameter, and a parameter value of the function parameter of the target function;
[0029] The sending module is used to send the message to the opposite node.
[0030] In a fourth aspect, an embodiment of the present application provides an electronic device, the electronic device comprising:
[0031] processor;
[0032] a memory for storing processor-executable instructions;
[0033] Wherein, when the processor calls the executable instruction, it implements the operation of any method described in the first aspect or the second aspect.
[0034] In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium having computer instructions stored thereon, and when the computer instructions are executed by a processor, the steps of any method described in the first aspect or the second aspect are implemented. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0036] Figure 1 A schematic diagram of an application scenario of a remote calling method provided in an embodiment of the present application;
[0037] Figure 2 A flowchart of a remote calling method provided in an embodiment of the present application;
[0038] Figure 3 A flowchart of a calling mode in a remote calling method provided in an embodiment of the present application;
[0039] Figure 4 A flowchart of a function parameter assignment process in a remote calling method provided in an embodiment of the present application;
[0040] Figure 5 A schematic diagram of a message format in a remote calling method provided in an embodiment of the present application;
[0041] Figure 6 A flowchart of a method for developing a remote call function provided in an embodiment of the present application;
[0042] Figure 7 A structural block diagram of a remote calling device provided in an embodiment of the present application;
[0043] Figure 8 A hardware structure diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0044] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.
[0045] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0046] Computing nodes can use the RPC mechanism to implement remote function calls. However, for computing nodes with limited computing power, such as embedded devices, they often communicate based on simple data read-write protocols, which cannot afford the computing power resource overhead occupied by RPC remote calls. Therefore, computing nodes such as embedded devices can only implement a limited range of functions.
[0047] For example, in a distributed complex product testing scenario, the host computer needs to perform complex control and coordination of different test equipment through communication. In particular, some test equipment has complex built-in functions, and its control cannot be achieved through a simple data read-write protocol, but requires the use of an RPC remote function call mechanism. However, if the heavyweight standard RPC protocol is used, although it is powerful, the protocol stack is complex and the implementation cost is high. It is very unfriendly to embedded scenarios with limited computing resources.
[0048] To this end, the embodiment of the present application provides a remote call method, which is suitable for computing nodes with limited computing power resources. Specifically, a corresponding message is generated for the target function to be remotely called. Among them, the following message format is designed for the message: the message includes a first data area. The first data area includes a function structure of the target function. The function structure includes a function identifier, function parameters and parameter values of the function parameters of the target function. Compared with the traditional heavyweight standard RPC protocol, the above message format defines the function parameters required for remotely calling the target function through the function structure in the first data area, and defines the corresponding parameter values, so that after receiving the message, the opposite node can know the target function to be executed according to the function identifier, and can directly obtain the function parameters and function parameter values defined in the function structure. Therefore, when making a remote call, the computing node can omit the serialization and deserialization steps in the RPC remote call, thereby saving the computing power overhead required for the remote call and reducing the requirements of the remote call on the computing power resources. Therefore, a remote call method provided by the application embodiment is suitable for various types of intelligent test equipment.
[0049] See also Figure 1 , is an application scenario of a remote calling method provided in an embodiment of the present application, including a calling node 110 and a responding node 120. Among them, the responding node 120 provides functions for remote calling by other computing nodes. The calling node 110 can act as a function caller to remotely call the functions provided by other computing nodes.
[0050] The calling node 110 and the responding node 120 may be similar or identical computing nodes. Alternatively, the calling node 110 and the responding node 120 may be any two computing nodes in a distributed system. The distributed system may be, for example, a weak real-time distributed system, which has a real-time requirement of seconds.
[0051] In addition, the calling node 110 and the responding node 120 can be the identities of a computing node in different scenarios, which does not limit the hardware or software structure of the computing node. For example, a computing node can act as a calling node 110 in a certain scenario to remotely call the functions provided by the responding node 120; in another scenario, it can act as a responding node 120 to provide the calling node 110 with remotely callable functions.
[0052] According to some embodiments of the present application, a first aspect provides a remote calling method, comprising: Figure 2 Steps 210 to 230 are shown.
[0053] Step 210: Determine the target function to be remotely called;
[0054] Step 220: Generate a message corresponding to the target function;
[0055] The message includes a first data area, the first data area includes a function structure of the target function, the function structure includes a function identifier, a function parameter, and a parameter value of the function parameter of the target function;
[0056] Step 230: Send the message to the opposite node.
[0057] The execution subject of this embodiment may be the above-mentioned calling node or responding node. The specific execution process by different execution subjects will be described below.
[0058] The target function refers to any function that can be remotely called and provided by the response node, such as data reading and writing function, synchronous calling function, asynchronous calling function, etc. Exemplarily, the data reading and writing function may include but is not limited to data access function, file transfer function, complex data object transfer function, etc. The asynchronous calling function may be, for example, a data subscription function, etc.
[0059] Of course, the target function is not limited to the examples listed above, and any function that can be remotely called can be used as the target function to be remotely called described in this embodiment.
[0060] The message corresponding to the target function is different when the method is executed by different execution subjects. However, no matter which execution subject executes the method, in order to complete the entire process of remotely calling the target function, each execution subject will generate a message corresponding to the target function during the execution process.
[0061] The generated message has the following format: the message includes a first data area, the first data area includes a function structure of the target function, the function structure includes a function identifier of the target function, function parameters and parameter values of the function parameters.
[0062] The first data area may include one or more function structures, which will be described in detail below. Each target function corresponds to a function structure in the first data area. The function structure includes the function identifier, function parameters and corresponding parameter values of the target function. That is, the function identifier, function parameters and their parameter values are members of the function structure.
[0063] Exemplarily, the function identifier, function parameters and parameter values thereof form a function structure in a fixed format, such as, but not limited to, JSON (JavaScript Object Notation) format, XML (eXtensible Markup Language) format, and the like.
[0064] Exemplarily, the function identifier is a unique identifier of the target function. For example, the function identifier may include but is not limited to a function name, a function number, and the like.
[0065] For example, the first data area can be represented as: {"Fun1":{"P1":"V1","P2":"V2"}}. Among them, "Fun1":{"P1":"V1","P2":"V2"} is the function structure in the first data area. Fun1 is the function name of the target function, that is, the function identifier; P1 and P2 are function parameters; V1 and V2 are parameter values corresponding to the function parameters respectively.
[0066] In the first data, the target function to be remotely called can be known through the function identifier in the function structure. The first data area represents the function semantics of the call itself in a fixed format, and carries the function parameters and parameter values required by the target function.
[0067] Optionally, the message may be an RPC protocol message. The first data area may be set in the message body of the RPC protocol. That is, by setting a fixed format for the data carried by the message body of the RPC protocol, the fixed format can reflect the functional semantics of the target function, thereby obtaining a lightweight RPC message.
[0068] In the traditional RPC protocol, since the input and output parameters are objects, the calling node often needs to serialize the input parameter objects, for example, including writing the object type, attribute type, attribute value, etc. according to a certain structure. The data written according to a certain structure can express the call semantics, and then the data expressing the call semantics is converted into binary data for transmission over the network. The responding node needs to deserialize, that is, read the object type, attribute type, attribute value according to a certain structure, and recreate a new output parameter object with this information. However, if the object structure is complex and large, serialization and deserialization will require a large amount of computing power, and the resulting RPC message data volume is large.
[0069] It can be seen that compared with the traditional RPC protocol, the embodiment of the present application designs a message format, and the first data area in the message represents the functional semantics of the call itself in a fixed format, ensuring the consistency of concepts and methods, the simplicity of implementation and the flexibility of expansion. At the same time, the functional structure also carries the functional parameters and parameter values required for the target function. Therefore, the computing node can directly convert the message into binary data and transmit it in the network without serialization and deserialization, thereby saving the computing power expenditure required for remote calls and reducing the requirements of remote calls on computing resources. Therefore, it is suitable for computing nodes with limited computing resources.
[0070] In some embodiments, the target function is remotely called in an active call mode and / or a passive call mode.
[0071] That is, the remote calling of the target function can be realized in the active calling mode, or in the passive calling mode, or in the combination of the active calling mode and the passive calling mode.
[0072] like Figure 3 As shown in (a), the active call mode refers to the calling node actively requesting the responding node to call the target function. In the active call mode, the calling node sends a call command to the responding node. The responding node responds to the call command and executes the target function requested by the call command. Based on the execution result, the responding node returns a call response to the calling node. This completes the operation in the active call mode.
[0073] like Figure 3 As shown in (b), in the passive call mode, the calling node passively calls the target function. In other words, the responding node actively provides the target function to the calling node. In the passive call mode, in response to triggering a preset condition, the responding node sends a notification message to the calling node.
[0074] Some target functions can be implemented by executing Figure 3 The steps of the active call mode shown in (a) implement remote calls; some target functions can be executed by executing Figure 3 (b) The steps of the passive calling mode shown in FIG. 4 implement remote calling; and some target functions can implement remote calling by executing the steps of the active calling mode and the passive calling mode.
[0075] As an example, if the target function is a data read and write function, the calling node can read and write data to the responding node by executing the steps of the active call mode, that is, the remote call data read and write function is realized.
[0076] As an example, if the target function is a data subscription function, the calling node can subscribe to data from the responding node by successively executing the steps of the active calling mode and the passive calling mode, that is, the remote calling data subscription function is realized.
[0077] The above examples are merely examples of how to implement remote calling of any target function using active calling mode and / or passive calling mode, and do not constitute a limit to the combination of the two modes and the target function.
[0078] It can be seen that by defining active call mode and passive call mode, the remote call of different target functions can be uniformly abstracted as a combination of one or more modes. In other words, in the face of various complex distributed products, the remote call and data communication scenarios of various functions can be realized by executing a combination of one or more modes.
[0079] Based on the above embodiment, the above remote calling method can be applied to the calling node that remotely calls the target function. That is, the calling node is the execution subject of the above remote calling method. In this way, the opposite node described in step 230 is the response node that provides the target function.
[0080] The message corresponding to the target function is a call command, which is used to request the response node to execute the target function.
[0081] That is, in order to actively call the target function to the responding node, the calling node Figure 3 (a) It can be seen that the calling node can first determine the target function to be remotely called, and then generate a call command corresponding to the target function. The call command is used to request the responding node to execute the target function. In addition, the calling node sends the call command to the responding node.
[0082] The calling command includes a first data area, which includes a function structure of the target function, and the function structure includes a function identifier, a function parameter, and a parameter value of the function parameter of the target function.
[0083] Exemplarily, the function parameter of the function structure in the call command may be a function call parameter. The function call parameter is a parameter required when executing the target function. After receiving the call command, the response node may execute the target function based on the function call parameter and its parameter value.
[0084] In this embodiment, the remote calling method is executed by the calling node, and the calling node can generate a calling command of the target function according to the steps of the active calling mode, so that the responding node can execute the target function according to the calling command. The entire remote calling process is simple and fast, and is suitable for computing nodes with limited computing resources.
[0085] Based on the above embodiment, the process of generating the message in step 220 may include: Figure 4 Steps 410 - 430 are shown.
[0086] Step 410: Determine the function parameters to be assigned in the target function;
[0087] Step 420: Obtain the parameter value of the function parameter input by the user;
[0088] Step 430: Generate a call command including the function parameters and the parameter values.
[0089] Exemplarily, in the function structure of the call command, the function parameter to be assigned may be a function call parameter. The function call parameter is a parameter required when executing the target function.
[0090] The function parameter may be assigned by the user. Optionally, a user interface may be provided for the user to input the parameter value of the function parameter in the user interface. In this way, the calling node may obtain the parameter value of the function parameter input by the user in the user interface.
[0091] Subsequently, the calling node may generate a calling command including the function parameter and its parameter value. That is, in the generated calling command, the function structure of the first data area includes the function identifier, the function parameter and the acquired parameter value.
[0092] Of course, in the call command, in addition to the user assigning values to the function parameters, the parameter values of the function parameters can also be default values. In this way, after determining the function parameters of the target function, the default values of the function parameters can be directly obtained and the call command of the target function can be generated.
[0093] In this embodiment, when generating a call command corresponding to a target function, the parameter values of the function parameters are configured by the user so that the target function can be executed according to user needs to meet business requirements.
[0094] In some embodiments, the remote calling method can also be applied to a response node that provides a target function. That is, the response node is the execution subject of the remote calling method. Thus, the opposite node described in step 230 is the calling node that remotely calls the target function.
[0095] The generating of the message corresponding to the target function in the above step 220 may include: in response to the calling command, after executing the target function indicated by the calling command, generating a calling response based on the execution result.
[0096] That is, when the calling node actively calls the target function, according to Figure 3 (a) It can be seen that the response node first determines the target function to be remotely called. Exemplarily, the response node can determine the target function to be remotely called according to the received call command.
[0097] Subsequently, the calling node executes the target function, and generates a call response based on the execution result after executing the target function. Finally, the responding node sends the call response to the calling node.
[0098] The call response includes a first data area, which includes a function structure of the target function, and the function structure includes a function identifier, a function parameter, and a parameter value of the function parameter.
[0099] Exemplarily, the function parameter of the function structure in the call response may be a function response parameter, which is used to characterize the execution result of the target function. After receiving the call response, the calling node may obtain the execution result of the target function based on the call response.
[0100] It can be seen that when the remote call of the target function is realized through the active call mode, the calling node generates a call command of the target function according to the steps of the active call mode. The first data area in the call command represents the functional semantics of the call itself in a fixed format, and the function structure represents the target function to be remotely called, and carries the function parameters and parameter values used to execute the target function.
[0101] In this way, when the responding node receives the call command, it can know the target function to be remotely called. And the target function is executed based on the function parameters and parameter values in the call command. A call response can be generated based on the execution result. The first data area in the call response represents the functional semantics of the call itself in a fixed format, and the function structure represents the target function and carries the function parameters and parameter values used to represent the execution result. In this way, when the calling node receives the call response, it can know the execution result of the target function. In this way, the remote call of the target function is completed based on the active call mode.
[0102] In this embodiment, the remote call method is executed by the responding node, and the responding node can generate a call response of the target function according to the steps of the active call mode, so that the calling node can know the execution result of the target function according to the call response. The entire remote call process is simple and fast, and is suitable for computing nodes with limited computing resources.
[0103] Based on the above embodiment, the generating of the call response based on the execution result may specifically include the following steps:
[0104] Determine a parameter value of a function parameter of the target function based on the execution result;
[0105] A call response including the function parameter and the parameter value is generated.
[0106] After executing the target function and obtaining the execution result, the response node can determine the parameter value of the function parameter based on the execution result. Exemplarily, the function parameter of the function structure in the call response can be a function response parameter, which is used to characterize the execution result of the target function.
[0107] Subsequently, the responding node may generate a call response including the function parameter and its parameter value. That is, in the generated call response, the function structure in the first data area includes the function identifier, the function parameter and the acquired parameter value.
[0108] In this embodiment, by determining the parameter value of the function parameter according to the execution result of the target function, the function parameter and its parameter value can reflect the execution result of the target function. The calling node can directly obtain the calling result of the target function based on the calling response.
[0109] In some embodiments, when the remote call method is applied to a responding node, the generation of a message corresponding to the target function in step 220 may include: generating a notification message in response to satisfying a notification trigger condition.
[0110] That is, when the calling node passively calls the target function, according to Figure 3 (b) It can be seen that after the responding node determines the target function to be remotely called, in response to the notification triggering condition being met, the responding node generates a notification message of the target function and sends the notification message to the calling node.
[0111] The notification message includes a first data area, which includes a function structure of the target function, and the function structure includes a function identifier, a function parameter, and a parameter value of the function parameter of the target function.
[0112] In this embodiment, since the first data area in the notification message represents the functional semantics of the call itself in a fixed format, the function structure represents the target function and carries the function parameters and parameter values used to represent the notification information. Therefore, after receiving the notification message, the calling node can obtain the notification information based on the target function. Thus, the remote call of the target function is completed based on the passive call mode.
[0113] Based on any of the above embodiments, the target function to be remotely called may include multiple ones. In the case where the target function includes multiple ones, the first data of the message includes multiple function structures corresponding to the multiple target functions respectively.
[0114] When there are multiple target functions, it means that the calling node needs to remotely call multiple target functions provided by the responding node, and the responding node needs to execute multiple target functions.
[0115] In the case where the target function includes multiple Figure 5 As shown in (a), the first data area may include multiple function structures corresponding to each target function. For example, if the target function includes N, the first data area includes N function structures. Each function structure corresponds to one target function. Wherein N is a positive integer. And in each function structure, the function identifier, function parameters and parameter values of the target function corresponding to the function structure are respectively included.
[0116] For example, the first data area can be represented as:
[0117] {“Fun1”:{…},“Fun2”:{…},…,“FunX”:{…}}
[0118] Among them, "Fun1": {...} is the function structure corresponding to the target function Fun1. "Fun2": {...} is the function structure corresponding to the target function Fun2, and so on. It can be seen that the first data area can include function structures corresponding to multiple target functions.
[0119] In this way, for the call command generated by the calling node, the calling node can use multiple function structures in the first data area in one call command to implement the request call to multiple target functions. That is, in the case where multiple target functions need to be called remotely, the calling node can send one call command to the responding node to implement the request call to multiple target functions without generating a call request for each target function.
[0120] For the call response generated by the response node, the response node can implement the response of multiple target functions through multiple function structures in the first data area in one call command. That is, after executing multiple target functions respectively, the response node can return the execution results of all target functions to the calling node through one call response, without generating a call response for the execution results of each target function respectively.
[0121] For the notification message generated by the responding node, the responding node can carry notification information corresponding to multiple target functions through multiple function structures in the first data area in one notification message. That is, the responding node can inform the calling node of the notification information corresponding to multiple target functions through one notification message, without generating a notification message for each target function.
[0122] In this embodiment, by setting function structures corresponding to multiple target functions in the first data area, one call command can request remote calls of multiple target functions; one call response can feedback the execution results of multiple target functions; one notification message can carry notification information of multiple target functions, thereby greatly reducing the overhead of remote calls and improving the efficiency of remote calls.
[0123] Based on any of the above embodiments, the message corresponding to the target function further includes a second data area. The second data area is used to transmit additional data related to the target function.
[0124] like Figure 5 As shown in (b), in the message corresponding to the target function, in addition to the first data area, a second data area for transmitting additional data is also included. Exemplarily, the second data area can be set after the first data area.
[0125] The additional data related to the target function refers to the additional data required when executing the target function, or the additional data obtained after executing the target function.
[0126] For example, in the data read and write function, if the calling node needs to write data to the responding node, the data to be written can be carried as additional data in the call command and sent to the responding node. If the calling node needs to read data from the responding node, the read data is carried as additional data in the call response or notification message and sent to the calling node. For another example, in the data subscription function, the data subscribed by the calling node can be carried as additional data in the notification message and sent to the calling node.
[0127] The data to be written, the data to be read, and the subscribed data may include but are not limited to complex data objects, large data objects, file data, and the like.
[0128] Of course, the target function may have corresponding additional data or may not have additional data. If all target functions in a certain remote call do not have corresponding additional data, the second data area may not be set in the message.
[0129] It is understandable that in the related art, data reading and writing are often implemented through a data reading and writing communication protocol. However, in this embodiment, through the cooperation of the first data area and the second data area, the first data area can be used to describe the functional semantics of the target function, and the second data area can transmit large or complex additional data, so that the generated message can realize both the data reading and writing function of the data reading and writing communication protocol and the complex remote call mechanism, thereby integrating the two functions that can be realized by the data reading and writing protocol and the remote call protocol.
[0130] Based on the above embodiment, the function structure in the message further includes data information of the additional data corresponding to the target function, and the data information is used to locate the additional data in the second data area.
[0131] like Figure 5 As shown in (c), in the first data area, the function structure may include data information of additional data in addition to the function identifier, function parameters and their parameter values.
[0132] The data information is used to locate the additional data in the second data area. That is, based on the data information, it can be known on which bits in the second data area the additional data of the target function is carried.
[0133] Optionally, the data information may include but is not limited to the address of the additional data in the second data area and / or the data length of the additional data.
[0134] For example, the data information may include the address, and the address may include the first address and the last address of the additional data in the second data area, so that the computing node can read the additional data corresponding to the target function from the second data according to the first address and the last address.
[0135] For another example, the data information may include the data length, so that the computing node can read data of the data length from the default address of the second data area as additional data.
[0136] For another example, the data information may include the address and the data length, and the address may include the first address or the last address, so that the computing interface can read data of the data length from the second data as additional data according to the first address or the last address.
[0137] Of course, the data information is not limited to the above examples. Any information that can locate the additional data from the second data area can be used as the data information described in this embodiment.
[0138] For example, a function structure can be represented as:
[0139] "FunX":{"P1":"V1","P2":"V2",…,"AttachmentAddr":"addr1","Attachme-ntLen":"Len1"}
[0140] Among them, AttachmentAddr is the first address of the attached data, and AttachmentLen is the data length of the attached data.
[0141] If the target function includes one, that is, the function structure in the first data area includes one, then the additional data in the second data area corresponds to the target function. The function structure includes data information of the additional data.
[0142] If the target functions include multiple ones, and at least some of the target functions have corresponding additional data, then optionally, for each target function with corresponding additional data, its function structure includes data information of the corresponding additional data. The corresponding additional data of the target function can be located in the second data area using the data information in each function structure. Alternatively, the function structures of all target functions can include data information of the additional data. However, for the target function without additional data, the data information in its function structure can be a default value.
[0143] When multiple target functions have corresponding additional data respectively, the position of each additional data in the second data area can be located respectively through the data information in each functional structure, so that the computing node can accurately read the corresponding additional data of each target function from the second data area.
[0144] It can be seen that in this embodiment, by setting the data information of the additional data of the target function in the function structure, the computing node can accurately read the corresponding additional data from the second data area according to the data information.
[0145] Based on the above embodiment, the message of the target function may further include a third data area for indicating the length of the first data area and / or the length of the second data area.
[0146] The first data area length refers to the bit length of the first data area in the message; the second data area length refers to the bit length of the second data area in the message. According to the third data area, the position of the first data area and / or the second data area in the message can be known.
[0147] Exemplarily, the third data area may include the first sub-area and / or the second sub-area. Figure 5(d) shows that the third data area includes a first sub-area and a second sub-area as an example. The first data area length is recorded in the first sub-area. For example, the first data area length can be recorded in the first sub-area as a binary value with a fixed byte length. The second data area length is recorded in the second sub-area. For example, the second data area length can be recorded in the second sub-area as a binary value with a fixed byte length.
[0148] Exemplarily, the third data area can be set before the first data area with a fixed byte length, so that when the computing node reads the message from the beginning, it can know the length of the first data and / or the second data from the third data area. And because the third data area is a fixed byte length, after reading the data of the fixed byte length, the computing node can determine that the data starting from the next byte is the data of the first data area. According to the length of the first data, the end position of the first data can be known. It can be known that the data after the first data area is the second data area, so the position of the first data area and the second data area in the message can be located.
[0149] For example, Figure 5 As shown in (d), the message may also include a message header. The message header is binary data of a fixed byte length. Optionally, if the message is an RPC protocol message, the third data area may be set in the message header or in the message body.
[0150] In this embodiment, the third data area indicates the first data length and / or the second data area length, so that the computing node can accurately locate the positions of the first data area and the second data area in the message according to the third data area in the message.
[0151] Based on the above embodiment, in some embodiments, the first data area is used to transmit character string data; and the second data area is used to transmit binary data.
[0152] String data refers to data whose data type is string type. Binary data refers to data whose data type is binary type.
[0153] Among them, the character string data has high flexibility and can carry the functional semantics of the target function, so the character string data can be used as the data type in the first data area.
[0154] However, string data needs to be further encoded into binary before being transmitted over the network. Compared to binary data, string data requires more binary bytes to express a string. Therefore, binary data has a higher data density but lower flexibility than string data.
[0155] It can be seen that in this embodiment, through the cooperation of the first data area and the second data area, the first data area carries string data, and the second data area carries binary data, so that text data and binary data can be combined, which is compatible with the flexibility of the text protocol and the efficiency of the binary protocol, and realizes highly flexible functional semantic expression and efficient additional data transmission.
[0156] In order to better understand any of the above embodiments, two specific examples are provided below for illustration.
[0157] Computing node A subscribes to the data published by computing node B according to its own needs. At this time, computing node A is the calling node and computing node B is the responding node. The target function to be remotely called is the data subscription function. According to the above embodiments, the data subscription function can be implemented by successively executing the steps of the active calling mode and the passive calling mode.
[0158] Specifically, computing node A informs computing node B of the data range and data push rules to be subscribed through a call command. The function structure is represented by JSON format, and the function parameters in the call command include: subscription data group name, scanning period, change dead zone type, and change dead zone value. The call command has no additional data requirements. In this way, the first data area in the call command can be represented as:
[0159] "SubData":{"SubGroup":"DemoGroup","ScanCycle":"1000","Datas":[{"Name":"D1","DeadbandMode":"0","Deadband":"0.01"}…]}
[0160] Among them, SubData is the function name of the data subscription function. SubGroup is the name of the subscription data group, which is a function parameter; DemoGroup is the parameter value of SubGroup. ScanCycle is the scan cycle, which is a function parameter. Datas is the list of data names to be subscribed. DeadbandMode is the change deadband type. Deadband is the change deadband value.
[0161] After receiving the call command, computing node B may execute the data subscription function according to the function parameters therein, and generate a call response based on the execution result. For example, the first data area of the call response may be represented as:
[0162] “SubData”:{“SubGroup”:“DemoGroup”,“FailDatas”:[“D2…”]}, where FailDatas is a list of data names for which subscription failed. If all are successful, the parameter value is empty.
[0163] Afterwards, when the data push rule is met, computing node B actively sends a notification message to computing node A. For example, the first data area of the notification message can be expressed as:
[0164] "NotifyData":{"TimeStamp":0"2023-03-31 13:00:00.123","D1":"V1","D2":"V2"…}
[0165] Where TimeStamp is the data sampling timestamp, D1, D2... are the data names that meet the push conditions, and V1, V2... are the corresponding data values.
[0166] The data subscription function is now completed.
[0167] In addition, for computing node A reading a file from computing node B, computing node A is a calling node and computing node B is a responding node. The target function to be remotely called is a file reading function. According to the above embodiments, the file reading function can be implemented by executing the steps of the active calling mode.
[0168] Specifically, computing node A requests computing node B to read a file by calling a command. The function parameter of the calling command includes the file path to be read. Thus, the first data area of the calling command can be expressed as:
[0169] "ReadFile":{"FilePath":"Root / Dir1 / 1.txt"}
[0170] Among them, ReadFile is the function name of the file reading function. FilePath is the file path, which is a function parameter, and Root / Dir1 / 1.txt is the parameter value of FilePath.
[0171] After receiving the call command, computing node B can read the required file according to the function parameters, and then generate a call response based on the read result, and carry the read file in the second data area.
[0172] Thus, the first data area in the call response can be expressed as:
[0173] "ReadFile":{"IsSuccess":"true","FilePath":"Root / Dir1 / 1.txt",
[0174] "AttachmentAddr": "0", "AttachmentLen": "1024"}
[0175] Among them, IsSuccess indicates whether the reading is successful, which is a function parameter. True is the parameter value of IsSuccess, indicating that the reading is successful. FilePath is the file path, AttachmentAddr is the starting address of the file in the attached data area, and AttachmentLen is the length of the file data.
[0176] According to some embodiments of the present application, a second aspect provides a method for developing a remote call function, including: Figure 6 Steps 610 - 630 are shown.
[0177] Step 610: Determine the function parameters and additional data required for the remote function;
[0178] Step 620: Determine a calling mode for implementing remote calling of the remote function;
[0179] The calling mode includes an active calling mode and / or a passive calling mode;
[0180] Step 630: Develop a software program for the computing node so as to generate a message corresponding to the remote function using the software program;
[0181] The computing nodes include calling nodes and / or responding nodes;
[0182] The message includes a first data area, the first data area includes a function structure of the remote function, the function structure includes a function identifier of the remote function, the function parameter, and a parameter value of the function parameter.
[0183] When a new remote function needs to be developed later, the function can be developed through the above steps. Specifically, for the remote function to be developed, it can be first determined which function parameters need to be configured to implement the remote function include, and whether the remote function carries additional data.
[0184] Then, it can be determined which one or a combination of calling modes are used to implement the remote calling of the remote function. Specifically, the semantics of the remote function, the format of the message, and the calling mode can be determined. For specific calling modes, see Figure 3 The embodiment shown is not expanded here.
[0185] Then develop a software program for the calling node and / or the responding node. According to the determined format and calling mode, the message receiving and sending control and the message encapsulation and parsing program are implemented through specific codes. So that the software program can generate messages corresponding to the remote function. The composition of the message meets the composition of the message described in any of the above embodiments.
[0186] Optionally, before developing the software program, the communication technology used between the computing nodes can also be determined to achieve the sending and receiving of messages. For example, the communication technology can use TCP / IP (Transmission Control Protocol / Internet Protocol) in Ethernet or RS485 serial port.
[0187] Optionally, after the software program is developed, the software program may be system debugged and deployed. For example, the developed software program may be deployed to specific call nodes and response nodes, and then debugged and verified until the design expectation is achieved.
[0188] In this embodiment, a remote function development method is provided, so that when new functions are subsequently proposed, the above method can be used to implement remote calls, which has the flexibility of expansion.
[0189] According to some embodiments of the present application, a third aspect provides a remote calling device. Figure 7 As shown, the remote calling device 700 includes:
[0190] A determination module 710 is used to determine a target function to be remotely called;
[0191] A generating module 720, configured to generate a message corresponding to the target function;
[0192] The message includes a first data area, the first data area includes a function structure of the target function, the function structure includes a function identifier, a function parameter, and a parameter value of the function parameter of the target function;
[0193] The sending module 730 is configured to send the message to the opposite node.
[0194] In some embodiments, the remote calling device 700 is applied to a calling node for remotely calling the target function, and the opposite node is a responding node that provides the target function;
[0195] The message corresponding to the target function includes a call command; the call command is used to request the response node to execute the target function.
[0196] In some embodiments, the generating module 720 is specifically used to:
[0197] Determining function parameters to be assigned in the target function;
[0198] Obtaining the parameter value of the function parameter input by the user;
[0199] A calling command including the function parameter and the parameter value is generated.
[0200] In some embodiments, the method is applied to a responding node that provides the target function, and the peer node is a calling node that remotely calls the target function; the generating module 720 is specifically used to:
[0201] In response to a call command, after executing the target function indicated by the call command, a call response is generated based on the execution result.
[0202] In some embodiments, the generating module 720 is specifically used to:
[0203] Determine a parameter value of a function parameter of the target function based on the execution result;
[0204] A call response including the function parameter and the parameter value is generated.
[0205] In some embodiments, the method is applied to a responding node that provides the target function, and the peer node is a calling node that remotely calls the target function; the generating module 720 is specifically used to:
[0206] In response to the notification triggering condition being met, a notification message is generated.
[0207] In some embodiments, when the target function includes multiple functions, the first data area of the message includes multiple function structures corresponding to the multiple target functions respectively.
[0208] In some embodiments, the message further includes a second data area; the second data area is used to transmit additional data related to the target function.
[0209] In some embodiments, the function structure also includes data information of additional data corresponding to the target function; the data information is used to locate the additional data in the second data area.
[0210] In some embodiments, the message further includes a third data area for indicating a length of the first data area and / or a length of the second data area.
[0211] In some embodiments, the first data area is used to transmit string data; and the second data area is used to transmit binary data.
[0212] The implementation process of the functions and effects of each module in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, which will not be repeated here.
[0213] Based on a remote calling method described in any of the above embodiments, the present application also provides: Figure 8 A schematic diagram of the structure of an electronic device is shown in FIG. Figure 8At the hardware level, the electronic device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory, and may also include hardware required for other services. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to implement a remote calling method described in any of the above embodiments.
[0214] The present application also provides a computer storage medium, which stores a computer program. When the computer program is executed by a processor, it can be used to execute a remote calling method described in any of the above embodiments.
[0215] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them; although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein by equivalents; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application, and they should all be included in the scope of the claims and specification of the present application. In particular, as long as there is no structural conflict, the various technical features mentioned in the various embodiments can be combined in any way. The present application is not limited to the specific embodiments disclosed herein, but includes all technical solutions that fall within the scope of the claims.
[0216] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0217] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0218] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0219] The above description is only an embodiment of the present application and is not intended to limit the scope of protection of the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application. It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings.
[0220] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0221] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
Claims
1. A remote calling method, characterized in that: The method comprises: Determine the target function to be called remotely; Generate a message corresponding to the target function; wherein the message includes a first data area, the first data area includes a function structure of the target function, the function structure includes a function identifier, a function parameter, and a parameter value of the function parameter of the target function; The message is sent to the opposite node.
2. The method according to claim 1, characterized in that The method is applied to a calling node that remotely calls the target function, and the opposite node is a responding node that provides the target function; The message corresponding to the target function includes a call command; the call command is used to request the response node to execute the target function.
3. The method according to claim 2, characterized in that The generating a message corresponding to the target function includes: Determining function parameters to be assigned in the target function; Obtaining the parameter value of the function parameter input by the user; A calling command including the function parameter and the parameter value is generated.
4. The method according to claim 1, characterized in that The method is applied to a responding node that provides the target function, and the peer node is a calling node that remotely calls the target function; The generating a message corresponding to the target function includes: in response to a call command, after executing the target function indicated by the call command, generating a call response based on the execution result.
5. The method according to claim 4, characterized in that the generating a call response based on the execution result comprises: Determine a parameter value of a function parameter of the target function based on the execution result; A call response including the function parameter and the parameter value is generated.
6. The method according to claim 1, characterized in that The method is applied to a responding node that provides the target function, and the peer node is a calling node that remotely calls the target function; The generating a message corresponding to the target function includes: generating a notification message in response to satisfying a notification trigger condition.
7. The method according to any one of claims 1 to 6, characterized in that: In the case that there are multiple target functions, the first data area of the message includes multiple function structures corresponding to the multiple target functions respectively.
8. The method according to any one of claims 1 to 7, characterized in that: The message also includes a second data area; the second data area is used to transmit additional data related to the target function.
9. The method according to claim 8, characterized in that The function structure also includes data information of additional data corresponding to the target function; the data information is used to locate the additional data in the second data area.
10. The method according to claim 8, characterized in that The message further includes a third data area for indicating a length of the first data area and / or a length of the second data area.
11. The method according to claim 8, characterized in that The first data area is used to transmit character string data; the second data area is used to transmit binary data.
12. A method for developing a remote call function, characterized in that: The method comprises: Determine the function parameters and additional data required for the remote function; Determine a calling mode for implementing remote calling of the remote function; the calling mode includes an active calling mode and / or a passive calling mode; Developing a software program for a computing node so as to generate a message corresponding to the remote function using the software program; the computing node includes a calling node and / or a responding node; The message includes a first data area, the first data area includes a function structure of the remote function, the function structure includes a function identifier of the remote function, the function parameter, and a parameter value of the function parameter.
13. A remote calling device, characterized in that: The device comprises: A determination module, used to determine a target function to be remotely called; A generating module, configured to generate a message corresponding to the target function; wherein the message comprises a first data area, the first data area comprises a function structure of the target function, the function structure comprises a function identifier, a function parameter, and a parameter value of the function parameter of the target function; The sending module is used to send the message to the opposite node.
14. An electronic device, characterized in that: The electronic device comprises: processor; a memory for storing processor-executable instructions; Wherein, when the processor calls the executable instructions, the operation of any method described in claims 1-12 is implemented.
15. A computer-readable storage medium, characterized in that: Computer instructions are stored thereon, and when the computer instructions are executed by a processor, the steps of any method described in claims 1-12 are implemented.