Simple-rpc supports 3 kinds of RPC: normal, fast, raw.
normal: RPC is handled in ThreadPool
fast: RPC is handled in IO thread
raw: RPC is handled manually, programmer need to parse messages by hand, and write code to reply RPC request.
raw RPC is useful when the RPC request cannot be replied in a timely fashion. It gives programmer the option to reply RPC at any time, or even drop the connection.
But dealing with raw RPC is painful, especially the serialization part.
So it's a good idea to provide something less bare metal. A defer RPC handles serialization, and will have more human friendly signature:
Instead of rpc(Request* req, ServerConnection* sconn), we have rpc(input&, output*, defer). So programmers can write this:
rpc(input&, output* out, defer) {
defer->run_async([output* ] {
*out = some_func();
defer->reply(); // also deletes the defer object
});
}
Simple-rpc supports 3 kinds of RPC: normal, fast, raw.
raw RPC is useful when the RPC request cannot be replied in a timely fashion. It gives programmer the option to reply RPC at any time, or even drop the connection.
But dealing with raw RPC is painful, especially the serialization part.
So it's a good idea to provide something less bare metal. A
defer
RPC handles serialization, and will have more human friendly signature:Instead of
rpc(Request* req, ServerConnection* sconn)
, we haverpc(input&, output*, defer)
. So programmers can write this: