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

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

Detailed Description

template<typename Response>
class ugrpc::client::UnaryCall< Response >

Controls a single request -> single response RPC.

This class is not thread-safe except for GetContext.

The RPC is cancelled on destruction unless Finish or FinishAsync. In that case the connection is not closed (it will be reused for new RPCs), and the server receives RpcInterruptedError immediately.

Definition at line 176 of file rpc.hpp.

+ Inheritance diagram for ugrpc::client::UnaryCall< Response >:

Public Types

using ResponseType = Response
 

Public Member Functions

Response Finish ()
 Await and read the response.
 
UnaryFuture FinishAsync (Response &response)
 Asynchronously finish the call.
 
 UnaryCall (UnaryCall &&) noexcept=default
 
UnaryCalloperator= (UnaryCall &&) noexcept=default
 
grpc::ClientContext & GetContext ()
 
std::string_view GetClientName () const
 
std::string_view GetCallName () const
 
tracing::SpanGetSpan ()
 

Protected Member Functions

impl::RpcData & GetData ()
 

Member Typedef Documentation

◆ ResponseType

template<typename Response >
using ugrpc::client::UnaryCall< Response >::ResponseType = Response

Definition at line 178 of file rpc.hpp.

Member Function Documentation

◆ Finish()

template<typename Response >
Response ugrpc::client::UnaryCall< Response >::Finish ( )

Await and read the response.

Finish should not be called multiple times for the same RPC.

The connection is not closed, it will be reused for new RPCs.

Returns
the response on success
Exceptions
ugrpc::client::RpcErroron an RPC error
ugrpc::client::RpcCancelledErroron task cancellation

Definition at line 509 of file rpc.hpp.

◆ FinishAsync()

template<typename Response >
UnaryFuture ugrpc::client::UnaryCall< Response >::FinishAsync ( Response & response)

Asynchronously finish the call.

FinishAsync should not be called multiple times for the same RPC.

Finish and FinishAsync should not be called together for the same RPC.

Returns
the future for the single response

Definition at line 517 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

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