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

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

Detailed Description

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

Client-side interface for client-streaming.

This class is not thread-safe except for GetContext.

The RPC should be completed by calling ugrpc::client::Writer::Finish. If destroyed early, the RPC is cancelled. The server gets ugrpc::client::RpcInterruptedError and the abandoned-error metric is incremented. When properly finished, the connection stays open for reuse.

Definition at line 69 of file stream.hpp.

Public Member Functions

 Writer (Writer &&) noexcept=default
 
Writeroperator= (Writer &&) noexcept=default
 
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.
 
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.
 

Member Function Documentation

◆ Finish()

template<typename Request , typename Response >
Response ugrpc::client::Writer< Request, Response >::Finish ( )
inline

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 123 of file stream.hpp.

◆ GetContext() [1/2]

template<typename Request , typename Response >
CallContext & ugrpc::client::Writer< Request, Response >::GetContext ( )
inline

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

Definition at line 126 of file stream.hpp.

◆ GetContext() [2/2]

template<typename Request , typename Response >
const CallContext & ugrpc::client::Writer< Request, 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 128 of file stream.hpp.

◆ Write()

template<typename Request , typename Response >
bool ugrpc::client::Writer< Request, Response >::Write ( const Request &  request)
inline

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 95 of file stream.hpp.

◆ WriteAndCheck()

template<typename Request , typename Response >
void ugrpc::client::Writer< Request, Response >::WriteAndCheck ( const Request &  request)
inline

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
ugrpc::client::RpcErrorif the stream is already closed for writes

Definition at line 109 of file stream.hpp.


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