10#include <userver/logging/log.hpp>
11#include <userver/ugrpc/client/impl/graceful_stream_finish.hpp>
12#include <userver/ugrpc/client/stream.hpp>
14USERVER_NAMESPACE_BEGIN
16namespace ugrpc::client {
27template <
typename Response>
29 return impl::ReadRemainingAndFinish<Reader<Response>, Response>(stream);
42template <
typename Request,
typename Response>
44 const bool writes_done_success = stream.WritesDone();
45 const std::optional<std::size_t> messages_remaining =
46 impl::ReadRemainingAndFinish<ReaderWriter<Request, Response>, Response>(stream);
47 return writes_done_success ? messages_remaining : std::nullopt;
62template <
typename Request,
typename Response>
63[[nodiscard]]
bool PingPongFinish(ReaderWriter<Request, Response>& stream)
noexcept {
65 const bool writes_done_success = stream.WritesDone();
68 if (!stream.Read(response)) {
70 return writes_done_success;
73 LOG_WARNING() <<
"PingPongFinish: there are more messages to read from the stream";
75 }
catch (
const std::exception& e) {
76 LOG_WARNING() <<
"PingPongFinish: failed to close the stream - " << e;