userver: ugrpc::client::MiddlewareCallContext Class Reference
Loading...
Searching...
No Matches
ugrpc::client::MiddlewareCallContext Class Referencefinal

#include <userver/ugrpc/client/middlewares/base.hpp>

Detailed Description

Context for middleware-specific data during gRPC call.

It is created for each gRPC Call and it stores aux. data used by middlewares. Each registered middleware is called by Middleware::Handle with the context passed as an argument. A middleware may access Call and initial request (if any) using the context.

Examples
samples/grpc_middleware_service/src/middlewares/client/auth.cpp, and samples/grpc_middleware_service/src/middlewares/client/auth.hpp.

Definition at line 58 of file base.hpp.

Public Member Functions

grpc::ClientContext & GetClientContext () noexcept
std::string_view GetClientName () const noexcept
std::string_view GetCallName () const noexcept
RpcType GetRpcType () const noexcept
tracing::Span & GetSpan () noexcept
std::optional< std::size_t > GetLatestRequestSizeBytes () const noexcept
 Serialized size of the request message.
std::optional< std::size_t > GetLatestResponseSizeBytes () const noexcept
 Serialized size of the response message of the current attempt.

Member Function Documentation

◆ GetCallName()

std::string_view ugrpc::client::MiddlewareCallContext::GetCallName ( ) const
noexcept
Returns
RPC name

◆ GetClientContext()

grpc::ClientContext & ugrpc::client::MiddlewareCallContext::GetClientContext ( )
noexcept
Returns
the ClientContext used for this RPC
Examples
samples/grpc_middleware_service/src/middlewares/client/auth.cpp.

◆ GetClientName()

std::string_view ugrpc::client::MiddlewareCallContext::GetClientName ( ) const
noexcept
Returns
client name

◆ GetLatestRequestSizeBytes()

std::optional< std::size_t > ugrpc::client::MiddlewareCallContext::GetLatestRequestSizeBytes ( ) const
noexcept

Serialized size of the request message.

This is the size of the wire buffer, which is cheaper than calling google::protobuf::Message::ByteSizeLong on the request.

Only unary RPCs fill it: the request is serialized once before the first PreSendMessage and reused by every attempt. Streaming RPCs serialize messages inside grpcpp, so for them it is always empty.

◆ GetLatestResponseSizeBytes()

std::optional< std::size_t > ugrpc::client::MiddlewareCallContext::GetLatestResponseSizeBytes ( ) const
noexcept

Serialized size of the response message of the current attempt.

This is the size of the wire buffer, which is cheaper than calling google::protobuf::Message::ByteSizeLong on the parsed response.

Only unary RPCs fill it, before PostRecvMessage. It stays available in PostFinish, including when a response was received but could not be parsed. It is empty if the attempt finished with an error status or was interrupted before the response arrived. Streaming RPCs parse messages inside grpcpp, so for them it is always empty.

◆ GetRpcType()

RpcType ugrpc::client::MiddlewareCallContext::GetRpcType ( ) const
noexcept
Returns
RPC type

◆ GetSpan()

tracing::Span & ugrpc::client::MiddlewareCallContext::GetSpan ( )
noexcept
Returns
RPC span

The documentation for this class was generated from the following file:
  • userver/ugrpc/client/middlewares/base.hpp