[server-rpc-unary-callback] */
| 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] */ |
nothing calls this directly
no test coverage detected