QGrpcInterceptorChain Class

Stores and manages a sequence of interceptors. More...

Header: #include <QGrpcInterceptorChain>
CMake: find_package(Qt6 REQUIRED COMPONENTS Grpc)
target_link_libraries(mytarget PRIVATE Qt6::Grpc)
Since: Qt 6.11

Public Functions

~QGrpcInterceptorChain()
bool empty() const
Q_DECL_IMPORT hasHandlerFor(QtGrpc::InterceptorCapability cap) const
bool isEmpty() const

Detailed Description

QGrpcInterceptorChain stores interceptor instances that observe or modify different stages of an RPC. The chain is passed to a channel during construction, and the channel owns the chain for the remainder of its lifetime.

As an RCP progresses through its lifecycle, the channel invokes the interceptors stored in the chain at the corresponding interception points.

Interceptors are added to the chain in a defined order. The order is significant and determines how interceptors are invoked during outbound and inbound stages of an RPC. For details, see the Direction and flow section of the Qt GRPC Interceptors Overview.

Interceptors can be added using two primary ownership models:

  • Owning: Add interceptors using std::unique_ptr<T>. On success, the chain takes ownership and destroys the interceptors when the chain (and therefore the channel) is destroyed.
  • Non-owning: Add interceptors using raw pointers T*. The chain does not take ownership. The caller must ensure that interceptor objects remain valid for as long as the channel may invoke them.

Both models can be combined within the same chain. While supported, mixing owning and non-owning interceptors requires care to ensure that non-owning interceptors outlive all channels that may use them.

Note: QGrpcInterceptorChain is not copyable and can only be moved.

See also QtGrpc::InterceptorCapability.

Member Function Documentation

[noexcept] QGrpcInterceptorChain::~QGrpcInterceptorChain()

Destroys the interceptor chain.

[noexcept] bool QGrpcInterceptorChain::empty() const

Returns true if the chain contains no interceptors; otherwise returns false.

See also size() and isEmpty().

[noexcept] Q_DECL_IMPORT QGrpcInterceptorChain::hasHandlerFor(QtGrpc::InterceptorCapability cap) const

Returns true if the chain contains at least one interceptor that provides a handler for capability cap; otherwise returns false.

See also capabilities() and capabilitiesAt().

[noexcept] bool QGrpcInterceptorChain::isEmpty() const

Returns true if the chain contains no interceptors; otherwise returns false.

See also size() and empty().