userver: ugrpc::client::OutputStream< Request, Response > Class Template Reference
Loading...
Searching...
No Matches
ugrpc::client::OutputStream< Request, Response > Class Template Referencefinal

#include <userver/ugrpc/client/rpc.hpp>

Detailed Description

template<typename Request, typename Response>
class ugrpc::client::OutputStream< Request, Response >

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.

Definition at line 265 of file rpc.hpp.

+ Inheritance diagram for ugrpc::client::OutputStream< Request, Response >:

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
 
OutputStreamoperator= (OutputStream &&) noexcept=default
 
grpc::ClientContext & GetContext ()
 
std::string_view GetClientName () const
 
std::string_view GetCallName () const
 
tracing::SpanGetSpan ()
 

Protected Member Functions

impl::RpcData & GetData ()
 

Member Function Documentation

◆ Finish()

template<typename Request , typename Response >
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.

Returns
the single Response received after finishing the writes
Exceptions
ugrpc::client::RpcErroron an RPC error
ugrpc::client::RpcCancelledErroron task cancellation

Definition at line 603 of file rpc.hpp.

◆ GetCallName()

std::string_view ugrpc::client::CallAnyBase::GetCallName ( ) const
inherited
Returns
RPC name

◆ GetClientName()

std::string_view ugrpc::client::CallAnyBase::GetClientName ( ) const
inherited
Returns
client name

◆ GetContext()

grpc::ClientContext & ugrpc::client::CallAnyBase::GetContext ( )
inherited
Returns
the ClientContext used for this RPC

◆ GetSpan()

tracing::Span & ugrpc::client::CallAnyBase::GetSpan ( )
inherited
Returns
RPC span

◆ Write()

template<typename Request , typename Response >
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.

Parameters
requestthe next message to write
Returns
true if the data is going to the wire; false if the write operation failed (including due to task cancellation), in which case no more writes will be accepted, and the error details can be fetched from Finish

Definition at line 578 of file rpc.hpp.

◆ WriteAndCheck()

template<typename Request , typename Response >
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.

Parameters
requestthe next message to write
Exceptions
ugrpc::client::RpcErroron an RPC error
ugrpc::client::RpcCancelledErroron task cancellation

Definition at line 588 of file rpc.hpp.


The documentation for this class was generated from the following file: