#include <userver/ugrpc/server/rpc.hpp>
Controls a request stream -> response stream RPC.
This class allows the following concurrent calls:
GetContext
Read
;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
.
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 &¶ms) | |
grpc::ServerContext & | GetContext () |
std::string_view | GetCallName () const |
Name of the call. Consists of service and method names. | |
tracing::Span & | GetSpan () |
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 |
ugrpc::server::BidirectionalStream< Request, Response >::BidirectionalStream | ( | impl::CallParams && | call_params, |
impl::RawReaderWriter< Request, Response > & | stream ) |
ugrpc::server::BidirectionalStream< Request, Response >::~BidirectionalStream | ( | ) |
void ugrpc::server::BidirectionalStream< Request, Response >::Finish | ( | ) |
Complete the RPC successfully.
Finish
must not be called multiple times.
ugrpc::server::RpcError | on an RPC error |
|
overridevirtual |
Complete the RPC with an error.
Finish
must not be called multiple times.
status | error details |
ugrpc::server::RpcError | on an RPC error |
Implements ugrpc::server::CallAnyBase.
|
overridevirtual |
Implements ugrpc::server::CallAnyBase.
bool ugrpc::server::BidirectionalStream< Request, Response >::Read | ( | Request & | request | ) |
Await and read the next incoming message.
request | where to put the request on success |
true
on success, false
on end-of-input ugrpc::server::RpcError | on an RPC error |
void ugrpc::server::BidirectionalStream< Request, Response >::Write | ( | const Response & | response | ) |
Write the next outgoing message.
response | the next message to write |
ugrpc::server::RpcError | on an RPC error |
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.
response | the final response message |
ugrpc::server::RpcError | on an RPC error |