MCPcopy Create free account
hub / github.com/Tradias/asio-grpc / Unary

Method Unary

example/snippets/server_callback.cpp:31–57  ·  view source on GitHub ↗

[server-rpc-unary-callback] */

Source from the content-addressed store, hash-verified

29
30 /* [server-rpc-unary-callback] */
31 grpc::ServerUnaryReactor* Unary(grpc::CallbackServerContext* context, const example::v1::Request*,
32 example::v1::Response* response) override
33 {
34 auto ptr = agrpc::make_reactor<agrpc::ServerUnaryReactor>(get_executor());
35 auto& rpc = *ptr;
36 context->AddInitialMetadata("example", "value");
37 rpc.initiate_send_initial_metadata();
38 rpc.wait_for_send_initial_metadata(
39 [response, ptr = std::move(ptr)](const error_code&, bool ok)
40 {
41 if (!ok)
42 {
43 return;
44 }
45 response->set_integer(42);
46 ptr->initiate_finish(grpc::Status::OK);
47 ptr->wait_for_finish(
48 [](const error_code&, bool ok)
49 {
50 if (!ok)
51 {
52 // ...
53 }
54 });
55 });
56 return rpc.get();
57 }
58 /* [server-rpc-unary-callback] */
59
60 /* [server-rpc-client-streaming-callback] */

Callers

nothing calls this directly

Calls 6

moveFunction · 0.85
initiate_finishMethod · 0.45
wait_for_finishMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected