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

Function reader

example/streaming-server.cpp:159–175  ·  view source on GitHub ↗

This function will read one requests from the client at a time. Note that gRPC only allows calling agrpc::read after a previous read has completed.

Source from the content-addressed store, hash-verified

157// This function will read one requests from the client at a time. Note that gRPC only allows calling agrpc::read after
158// a previous read has completed.
159asio::awaitable<void> reader(BidiStreamingRPC& rpc, Channel& channel)
160{
161 while (true)
162 {
163 example::v1::Request request;
164 if (!co_await rpc.read(request))
165 {
166 // Client is done writing.
167 break;
168 }
169 // Send request to writer. The `max_buffer_size` of the channel acts as backpressure.
170 (void)co_await channel.async_send(boost::system::error_code{}, std::move(request),
171 asio::as_tuple(asio::use_awaitable));
172 }
173 // Signal the writer to complete.
174 channel.close();
175}
176
177// The writer will pick up reads from the reader through the channel and switch to the thread_pool to compute their
178// response.

Callers 1

Calls 2

moveFunction · 0.85
readMethod · 0.45

Tested by

no test coverage detected