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

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

Detailed Description

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

Controls a single request -> single response RPC.

This class is not thread-safe, it cannot be used from multiple tasks at the same time.

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

Definition at line 23 of file response_future.hpp.

Public Member Functions

 ResponseFuture (ResponseFuture &&) noexcept=default
ResponseFuture & operator= (ResponseFuture &&) noexcept=default
bool IsReady () const
 Checks if the asynchronous call has completed Note, that once user gets result, IsReady should not be called.
engine::FutureStatus WaitUntil (engine::Deadline deadline) const noexcept
 Await response until specified timepoint.
Response Get ()
 Await and read the response.
void Cancel ()
 Cancel call.
CallContextGetContext ()
 Get call context, useful e.g. for accessing metadata.
const CallContextGetContext () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
engine::AwaitableToken GetAwaitableToken () noexcept
 Satisfies engine::Awaitable, for use with engine::WaitAnyContext and friends.

Member Function Documentation

◆ Cancel()

template<typename Response>
void ugrpc::client::ResponseFuture< Response >::Cancel ( )
inline

Cancel call.

Definition at line 54 of file response_future.hpp.

◆ Get()

template<typename Response>
Response ugrpc::client::ResponseFuture< Response >::Get ( )
inline

Await and read the response.

Get should not be called multiple times for the same UnaryFuture.

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 51 of file response_future.hpp.

◆ GetAwaitableToken()

template<typename Response>
engine::AwaitableToken ugrpc::client::ResponseFuture< Response >::GetAwaitableToken ( )
inlinenoexcept

Satisfies engine::Awaitable, for use with engine::WaitAnyContext and friends.

Definition at line 63 of file response_future.hpp.

◆ GetContext() [1/2]

template<typename Response>
CallContext & ugrpc::client::ResponseFuture< Response >::GetContext ( )
inline

Get call context, useful e.g. for accessing metadata.

Definition at line 57 of file response_future.hpp.

◆ GetContext() [2/2]

template<typename Response>
const CallContext & ugrpc::client::ResponseFuture< Response >::GetContext ( ) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 60 of file response_future.hpp.

◆ IsReady()

template<typename Response>
bool ugrpc::client::ResponseFuture< Response >::IsReady ( ) const
inlinenodiscard

Checks if the asynchronous call has completed Note, that once user gets result, IsReady should not be called.

Returns
true if result ready

Definition at line 33 of file response_future.hpp.

◆ WaitUntil()

template<typename Response>
engine::FutureStatus ugrpc::client::ResponseFuture< Response >::WaitUntil ( engine::Deadline deadline) const
inlinenodiscardnoexcept

Await response until specified timepoint.

Exceptions
ugrpc::client::RpcErroron an RPC error

Definition at line 38 of file response_future.hpp.


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