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

Function bidirectional_streaming_rpc_handler

example/streaming-server.cpp:204–224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

202}
203
204auto bidirectional_streaming_rpc_handler(asio::thread_pool& thread_pool)
205{
206 return [&](BidiStreamingRPC& rpc) -> asio::awaitable<void>
207 {
208 // Maximum number of requests that are buffered by the channel to enable backpressure.
209 static constexpr auto MAX_BUFFER_SIZE = 2;
210
211 Channel channel{co_await asio::this_coro::executor, MAX_BUFFER_SIZE};
212
213 using namespace asio::experimental::awaitable_operators;
214 const auto ok = co_await (reader(rpc, channel) && writer(rpc, channel, thread_pool));
215
216 if (!ok)
217 {
218 // Client has disconnected or server is shutting down.
219 co_return;
220 }
221
222 co_await rpc.finish(grpc::Status::OK);
223 };
224}
225// ---------------------------------------------------
226//
227

Callers 1

mainFunction · 0.85

Calls 3

readerFunction · 0.70
writerFunction · 0.70
finishMethod · 0.45

Tested by

no test coverage detected