Prologue, this is a series of articles about the concept of RPC, mainly through a step-by-step adjustment, refining a relatively complete RPC framework.
RPC (remote Procedure call Protocol)--remoting procedure calls protocol, based on the C/S model. There is an article on the network is well written, you can go to understand the relevant concepts in layman RPC
Here, just use one of the authors above
In summary, there are 4 pieces of core content.
- Transfer of RPC data . As above the Rpcconnector,rpcchannel. They are mainly responsible for data transmission, the specific client-server connection is not a socket connection, is the original TCP connection or use HTTP, these RPC protocol itself does not make any provision. then our task is to abstract out such a transport layer.
- RPC messages. such as the RpcProtocol above, as well as the Encode,decode method. Because RPC is a remote call, there is no way to directly function calls, so a special set of protocols must be used to represent the invocation and the result of the call. In addition, because the actual application is basically a cross-machine connection, it is not possible to pass the memory variables directly, that is, you also need to encode the message into a string such as a type of content that can be transmitted across devices. There are many encapsulation protocols for specific RPC messages, and the common ones are based on Xml,json encapsulation. then our task is to abstract out such a protocol layer.
- RPC Service registration. as above callee-->export. What calls are specifically supported by the server, and after receiving RPC requests from the client, how to invoke the actual method that needs to be executed, which is also a complete RPC framework that must be considered. Some of the slightly higher-level frameworks are self-registering, and now the mainstream RPC framework supports the definition of remote interfaces via IDL (Interface definition Language) for cross-language RPC. then our task is to abstract out an RPC service registration mechanism .
- RPC Message processing . As above the Rpcinvoker. This is in fact not related to RPC itself, generally is to consider supporting asynchronous/synchronous calls . This part, probably I will also do some clarification, but not the focus of this series.
The RPC framework, farmers will use Python as a development language, why, and a little embarrassed: less code, easy to explain (lazy is the nature of the Code workers). The initial idea is that the entire framework starts with the original normal call, then evolves step by step, and finally generates a complete RPC framework. In this process, I hope to bring you more profound knowledge of RPC primer and Code modification. Said a bit high, hehe.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
How a simple RPC framework is tempered (I)--openings