RppGrpc is extension of RPP which enables support of grpc library.
More...
RppGrpc is extension of RPP which enables support of grpc library.
gRPC provides way to handle requests and responses with help of reactors. RppGrpc is set of reactors (for both: client and server side) with all possible stream modes (client, server or bidirectional stream) to pass such an reactors to gRPC and handle them via RPP.
- Server-side example:
grpc::ServerBidiReactor<Request, Response>* Bidirectional(grpc::CallbackServerContext* ) override
{
const auto reactor = new rppgrpc::server_bidi_reactor<Request, Response>();
reactor->get_observable().subscribe([](const Request&) {}, []() { std::cout << "DONE" << std::endl; });
reactor->get_observer().on_next(Response{});
return reactor;
}
- Client-side example:
auto channel = grpc::CreateChannel("localhost:50051", grpc::InsecureChannelCredentials());
auto stub = TestService::NewStub(channel);
grpc::ClientContext ctx{};
stub->async()->Bidirectional(&ctx, reactor);
reactor->get_observable().subscribe([](const Response&) {});
reactor->init();
reactor->get_observer().on_next(Request{});