QGrpcStartInterceptor Class
拦截 RPC 的开始。更多内容...
| 头文件: | #include <QGrpcInterceptor> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Grpc) target_link_libraries(mytarget PRIVATE Qt6::Grpc) |
| 自: | Qt 6.11 |
- 所有成员列表,包括继承的成员
- QGrpcStartInterceptor 属于Qt GRPC 拦截器。
注意:该类中的所有函数均为可重入的。
公共类型
(since 6.11) enum class | Continuation { Proceed, Drop } |
公共函数
| virtual | ~QGrpcStartInterceptor() |
| virtual QGrpcStartInterceptor::Continuation | onStart(QGrpcInterceptionContext &context, QProtobufMessage &message, QGrpcCallOptions &callOptions) = 0 |
详细说明
实现 QGrpcStartInterceptor 以观察或调整 RPC 启动时使用的参数。
拦截器在每次 RPC 调用开始之前被调用一次。
有关拦截机制的介绍以及拦截器接口如何参与 RPC 生命周期的信息,请参阅《Qt GRPC 拦截器概述》。
注意:此 拦截器在出站方向上运行。有关多个拦截器回调如何在链中流转的详细信息,请参阅“方向和流”部分。
另请参阅 QtGrpc::InterceptorCapability::Start 和QGrpcInterceptionContext 。
成员类型文档
[since 6.11] enum class QGrpcStartInterceptor::Continuation
控制是否允许被拦截的 RPC 继续执行。
| 常量 | 值 | 描述 |
|---|---|---|
QGrpcStartInterceptor::Continuation::Proceed | 0 | 继续调用。 |
QGrpcStartInterceptor::Continuation::Drop | 1 | 中止调用。 |
该枚举在 Qt 6.11 中引入。
成员函数文档
[virtual noexcept] QGrpcStartInterceptor::~QGrpcStartInterceptor()
摧毁了这架拦截机。
[pure virtual] QGrpcStartInterceptor::Continuation QGrpcStartInterceptor::onStart(QGrpcInterceptionContext &context, QProtobufMessage &message, QGrpcCallOptions &callOptions)
当 RPC 即将开始时调用此方法。
context 提供了有关被拦截的 RPC 的信息。
message 包含初始请求消息,并且可以就地修改。
callOptions 可以被修改以调整每次调用的设置。
返回 `Continuation::Proceed ` 以继续 RPC,或返回 `Continuation::Drop ` 以阻止其继续。
如果返回了 `Continuation::Drop `,则 RPC 将被中止,操作将转为 `finished()`。返回的状态码为 `Aborted`。实现 `QGrpcFinishedInterceptor ` 的拦截器仍会被调用。
注意: 可变的 callOptions 指的是与context.callOptions() 返回的调用选项实例相同的实例 。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.