ReactivePlusPlus
ReactiveX implementation for C++20
Loading...
Searching...
No Matches
rppgrpc

RppGrpc is extension of RPP which enables support of grpc library. More...

Topics

 gRPC reactors
 Reactors for gRPC to connect it to RPP properly.
 

Detailed Description

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* /*context*/) override
{
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{});