MCPcopy Create free account
hub / github.com/AlexInLog/ReactivePlusPlus / main

Function main

src/examples/rppgrpc/doxygen/client_reactor.cpp:11–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9 **/
10
11int main() // NOLINT(bugprone-exception-escape)
12{
13 {
14 //! [bidi_reactor]
15 auto channel = grpc::CreateChannel("localhost:50051", grpc::InsecureChannelCredentials());
16 auto stub = TestService::NewStub(channel);
17
18 grpc::ClientContext ctx{};
19 const auto reactor = new rppgrpc::client_bidi_reactor<Request, Response>();
20 stub->async()->Bidirectional(&ctx, reactor);
21 reactor->get_observable().subscribe([](const Response&) {});
22
23 reactor->init();
24
25 reactor->get_observer().on_next(Request{});
26 //! [bidi_reactor]
27 }
28 {
29 //! [read_reactor]
30 auto channel = grpc::CreateChannel("localhost:50051", grpc::InsecureChannelCredentials());
31 auto stub = TestService::NewStub(channel);
32
33 grpc::ClientContext ctx{};
34 const auto reactor = new rppgrpc::client_read_reactor<Response>();
35 Request req{};
36 stub->async()->ServerSide(&ctx, &req, reactor);
37 reactor->get_observable().subscribe([](const Response&) {});
38
39 reactor->init();
40 //! [read_reactor]
41 }
42 {
43 //! [write_reactor]
44 auto channel = grpc::CreateChannel("localhost:50051", grpc::InsecureChannelCredentials());
45 auto stub = TestService::NewStub(channel);
46
47 grpc::ClientContext ctx{};
48 const auto reactor = new rppgrpc::client_write_reactor<Request>();
49 Response resp{};
50 stub->async()->ClientSide(&ctx, &resp, reactor);
51 reactor->get_observable().subscribe([](const rpp::utils::none&) {});
52
53 reactor->init();
54
55 reactor->get_observer().on_next(Request{});
56 //! [write_reactor]
57 }
58
59 return 0;
60}

Callers

nothing calls this directly

Calls 8

BidirectionalMethod · 0.45
subscribeMethod · 0.45
get_observableMethod · 0.45
initMethod · 0.45
on_nextMethod · 0.45
get_observerMethod · 0.45
ServerSideMethod · 0.45
ClientSideMethod · 0.45

Tested by

no test coverage detected