jovany-wang / dousi

Native Multiple Languages RPC Framework.
6 stars 3 forks source link

TODOs for Cross-Languaged RPC #48

Open jovany-wang opened 4 years ago

jovany-wang commented 4 years ago
jovany-wang commented 4 years ago

Java RPC Server

  1. 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_;
    };
  2. 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_;
    };
jovany-wang commented 4 years ago

Since we should write much code for JNI implementation. It's more graceful to use netty for Java if we define the protocol.