jovany-wang / dousi

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

dousi-rpc

GitHub Workflow Status Github Star Number
Highly Performance RPC Framework.

Note that this is working on progress.

Features

Pure C++ Usage

C++ Server

class Calculator {
public:
    int add(int x, int y) {
        return x + y;
    }

    int sub(int x, int y) {
        return x - y;
    }
};

int main() {

    dousi::Init(/*master=*/"127.0.0.1:100001");

    auto my_service = dousi::CreateService<Calculator>();
    const auto add_rm = dousi::Remote(&Calculator::add);
    adder_service.RegisterMethod(add_rm);
    adder_service.RegisterMethod(dousi::Remote(&Calculator::sub));

    dousi::Loop();

    return 0;
}

C++ Client

int main() {
    dousi::Init(/*master=*/"127.0.0.1:100001");

    ServiceHandle calc_service = dousi::GetService<Calculator>();

    DousiFuture<int> sum_future = calc_service.Call(dousi::Remote(&Calculator::add), 2, 3);
    DousiFuture<int> sub_future = calc_service.Call(dousi::Remote(&Calculator::sub), 10, 3);

    std::cout << "2 + 3 = " << *sum_future.Get() << std::endl;
    std::cout << "10 - 3 = " << *sub_future.Get() << std::endl;
    return 0;
}

Cross-Languaged RPC

Java Async-Server and Async-Client is supported now, and it's supported that a Java client connects to C++ server and a C++ client connects to a Java server.
More information can be refered in Java Part of Dousi

Roadmap