userver: grpc_protovalidate::server::Middleware Class Reference
Loading...
Searching...
No Matches
grpc_protovalidate::server::Middleware Class Referencefinal

Detailed Description

Definition at line 25 of file middleware.hpp.

+ Inheritance diagram for grpc_protovalidate::server::Middleware:

Public Member Functions

 Middleware (const Settings &settings)
 
void PostRecvMessage (ugrpc::server::MiddlewareCallContext &context, google::protobuf::Message &request) const override
 The function is invoked after each received message.
 
void PreSendMessage (ugrpc::server::MiddlewareCallContext &context, google::protobuf::Message &response) const override
 The function is invoked before each sended message.
 
virtual void OnCallStart (MiddlewareCallContext &context) const
 This hook is invoked once per Call (RPC), after the message metadata is received, but before the handler function is called.
 
virtual void PreSendStatus (MiddlewareCallContext &context, grpc::Status &status) const
 The function is invoked before sending the final status of the call.
 
virtual void OnCallFinish (MiddlewareCallContext &context, const std::optional< grpc::Status > &status) const
 This hook is invoked once per Call (RPC), after the handler function has finished execution and the final status is determined.
 

Constructor & Destructor Documentation

◆ Middleware()

grpc_protovalidate::server::Middleware::Middleware ( const Settings & settings)
explicit

Definition at line 35 of file middleware.cpp.

Member Function Documentation

◆ OnCallFinish()

virtual void ugrpc::server::MiddlewareBase::OnCallFinish ( MiddlewareCallContext & context,
const std::optional< grpc::Status > & status ) const
virtualinherited

This hook is invoked once per Call (RPC), after the handler function has finished execution and the final status is determined.

OnCallFinish is called exactly once per Call (RPC), regardless of whether the call succeeded or failed. It's the final middleware hook in the call chain. This is useful for cleanup operations, logging, or metrics collection that should happen after the RPC is completely processed.

Parameters
contextThe middleware call context containing call information
statusThe final status of the call, if available

◆ OnCallStart()

virtual void ugrpc::server::MiddlewareBase::OnCallStart ( MiddlewareCallContext & context) const
virtualinherited

This hook is invoked once per Call (RPC), after the message metadata is received, but before the handler function is called.

If all OnCallStart succeeded => OnCallFinish will invoked after a success method call.

Reimplemented in ugrpc::server::middlewares::baggage::Middleware, and ugrpc::server::middlewares::deadline_propagation::Middleware.

◆ PostRecvMessage()

void grpc_protovalidate::server::Middleware::PostRecvMessage ( ugrpc::server::MiddlewareCallContext & context,
google::protobuf::Message & request ) const
overridevirtual

The function is invoked after each received message.

PostRecvMessage is called:

  • unary: exactly once per Call (RPC)
  • stream: 0, 1 or more times

Reimplemented from ugrpc::server::MiddlewareBase.

Definition at line 41 of file middleware.cpp.

◆ PreSendMessage()

void grpc_protovalidate::server::Middleware::PreSendMessage ( ugrpc::server::MiddlewareCallContext & context,
google::protobuf::Message & response ) const
overridevirtual

The function is invoked before each sended message.

PreSendMessage is called:

  • unary: 0 or 1 per Call (RPC), depending on whether the RPC returns a response or a failed status
  • stream: once per response message, that is, 0, 1, more times per Call (RPC).

Reimplemented from ugrpc::server::MiddlewareBase.

Definition at line 52 of file middleware.cpp.

◆ PreSendStatus()

virtual void ugrpc::server::MiddlewareBase::PreSendStatus ( MiddlewareCallContext & context,
grpc::Status & status ) const
virtualinherited

The function is invoked before sending the final status of the call.

PreSendStatus is called exactly once per Call (RPC), right before sending the final gRPC status to the client. This allows middlewares to inspect and potentially modify the status that will be sent to the client.

Reimplemented in ugrpc::server::middlewares::deadline_propagation::Middleware.


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