Open jovany-wang opened 4 years ago
Extract Executor implementation
class Executor {
Executor(std::function<void(std::buffer &encoded_bytes)> func) :on_request_coming_callback_(func) {
}
std::function<void(std::buffer &encoded_bytes)> on_request_coming_callback_;
};
C++ RPC Server
class RpcServer {
void CreateService(service_name service) {
}
Executor executor_ = Executor([](std::buffer &encoded_byte) {
auto rpc_request = codec_.decode();
str service = rpc_request.service_name();
str method = rpc_request.method_name();
tuple args = rpc_request.args();
Invoke(service, method, args);
});
CppCodec codec_;
map<service_name, service_instance> services_;
};
Since we should write much code for JNI implementation. It's more graceful to use netty for Java if we define the protocol.