#include <userver/ugrpc/client/rpc.hpp>
Controls a request stream -> single response RPC.
This class is not thread-safe except for GetContext
.
The RPC is cancelled on destruction unless Finish
has been called. In that case the connection is not closed (it will be reused for new RPCs), and the server receives RpcInterruptedError
immediately.
If any method throws, further methods must not be called on the same stream, except for GetContext
.
Public Member Functions | |
bool | Write (const Request &request) |
Write the next outgoing message. | |
void | WriteAndCheck (const Request &request) |
Write the next outgoing message and check result. | |
Response | Finish () |
Complete the RPC successfully. | |
OutputStream (OutputStream &&) noexcept=default | |
OutputStream & | operator= (OutputStream &&) noexcept=default |
Public Member Functions inherited from ugrpc::client::CallAnyBase | |
grpc::ClientContext & | GetContext () |
std::string_view | GetClientName () const |
std::string_view | GetCallName () const |
tracing::Span & | GetSpan () |
Additional Inherited Members | |
Protected Member Functions inherited from ugrpc::client::CallAnyBase | |
impl::RpcData & | GetData () |
Response ugrpc::client::OutputStream< Request, Response >::Finish | ( | ) |
Complete the RPC successfully.
Should be called once all the data is written. The server will then send a single Response
.
Finish
should not be called multiple times.
The connection is not closed, it will be reused for new RPCs.
Response
received after finishing the writes ugrpc::client::RpcError | on an RPC error |
ugrpc::client::RpcCancelledError | on task cancellation |
bool ugrpc::client::OutputStream< Request, Response >::Write | ( | const Request & | request | ) |
Write the next outgoing message.
Write
doesn't store any references to request
, so it can be deallocated right after the call.
request | the next message to write |
void ugrpc::client::OutputStream< Request, Response >::WriteAndCheck | ( | const Request & | request | ) |
Write the next outgoing message and check result.
WriteAndCheck
doesn't store any references to request
, so it can be deallocated right after the call.
WriteAndCheck
verifies result of the write and generates exception in case of issues.
request | the next message to write |
ugrpc::client::RpcError | on an RPC error |
ugrpc::client::RpcCancelledError | on task cancellation |