userver: ugrpc::server::BidirectionalStream< Request, Response > Class Template Reference
Loading...
Searching...
No Matches
ugrpc::server::BidirectionalStream< Request, Response > Class Template Reference

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

Detailed Description

template<typename Request, typename Response>
class ugrpc::server::BidirectionalStream< Request, Response >

Controls a request stream -> response stream RPC.

This class allows the following concurrent calls:

  • GetContext
  • Read;
  • one of (Write, Finish, FinishWithError, WriteAndFinish).

The RPC is cancelled on destruction unless the stream has been finished.

If any method throws, further methods must not be called on the same stream, except for GetContext.

Definition at line 256 of file rpc.hpp.

+ Inheritance diagram for ugrpc::server::BidirectionalStream< Request, Response >:
+ Collaboration diagram for ugrpc::server::BidirectionalStream< Request, Response >:

Public Member Functions

bool Read (Request &request)
 Await and read the next incoming message.
 
void Write (const Response &response)
 Write the next outgoing message.
 
void Finish ()
 Complete the RPC successfully.
 
void FinishWithError (const grpc::Status &status) override
 Complete the RPC with an error.
 
void WriteAndFinish (const Response &response)
 Equivalent to Write + Finish
 
 BidirectionalStream (impl::CallParams &&call_params, impl::RawReaderWriter< Request, Response > &stream)
 For internal use only.
 
 BidirectionalStream (const BidirectionalStream &)=delete
 
 BidirectionalStream (BidirectionalStream &&)=delete
 
bool IsFinished () const override
 
- Public Member Functions inherited from ugrpc::server::CallAnyBase
 CallAnyBase (impl::CallParams &&params)
 
grpc::ServerContext & GetContext ()
 
std::string_view GetCallName () const
 Name of the call. Consists of service and method names.
 
tracing::SpanGetSpan ()
 
utils::AnyStorage< StorageContext > & GetStorageContext ()
 Returns call context for storing per-call custom data.
 

Additional Inherited Members

- Protected Member Functions inherited from ugrpc::server::CallAnyBase
ugrpc::impl::RpcStatisticsScope & Statistics ()
 
logging::LoggerRef AccessTskvLogger ()
 
void LogFinish (grpc::Status status) const
 

Constructor & Destructor Documentation

◆ BidirectionalStream()

template<typename Request , typename Response >
ugrpc::server::BidirectionalStream< Request, Response >::BidirectionalStream ( impl::CallParams && call_params,
impl::RawReaderWriter< Request, Response > & stream )

For internal use only.

Definition at line 478 of file rpc.hpp.

◆ ~BidirectionalStream()

template<typename Request , typename Response >
ugrpc::server::BidirectionalStream< Request, Response >::~BidirectionalStream ( )

Definition at line 484 of file rpc.hpp.

Member Function Documentation

◆ Finish()

template<typename Request , typename Response >
void ugrpc::server::BidirectionalStream< Request, Response >::Finish ( )

Complete the RPC successfully.

Finish must not be called multiple times.

Exceptions
ugrpc::server::RpcErroron an RPC error

Definition at line 519 of file rpc.hpp.

◆ FinishWithError()

template<typename Request , typename Response >
void ugrpc::server::BidirectionalStream< Request, Response >::FinishWithError ( const grpc::Status & status)
overridevirtual

Complete the RPC with an error.

Finish must not be called multiple times.

Parameters
statuserror details
Exceptions
ugrpc::server::RpcErroron an RPC error

Implements ugrpc::server::CallAnyBase.

Definition at line 530 of file rpc.hpp.

◆ IsFinished()

template<typename Request , typename Response >
bool ugrpc::server::BidirectionalStream< Request, Response >::IsFinished ( ) const
overridevirtual

Implements ugrpc::server::CallAnyBase.

Definition at line 556 of file rpc.hpp.

◆ Read()

template<typename Request , typename Response >
bool ugrpc::server::BidirectionalStream< Request, Response >::Read ( Request & request)

Await and read the next incoming message.

Parameters
requestwhere to put the request on success
Returns
true on success, false on end-of-input
Exceptions
ugrpc::server::RpcErroron an RPC error

Definition at line 492 of file rpc.hpp.

◆ Write()

template<typename Request , typename Response >
void ugrpc::server::BidirectionalStream< Request, Response >::Write ( const Response & response)

Write the next outgoing message.

Parameters
responsethe next message to write
Exceptions
ugrpc::server::RpcErroron an RPC error

Definition at line 504 of file rpc.hpp.

◆ WriteAndFinish()

template<typename Request , typename Response >
void ugrpc::server::BidirectionalStream< Request, Response >::WriteAndFinish ( const Response & response)

Equivalent to Write + Finish

This call saves one round-trip, compared to separate Write and Finish.

Finish must not be called multiple times.

Parameters
responsethe final response message
Exceptions
ugrpc::server::RpcErroron an RPC error

Definition at line 542 of file rpc.hpp.


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