QGrpcCallOptions Class

The QGrpcCallOptions class offers various options for fine-tuning individual RPCs. 更多...

头: #include <QGrpcCallOptions>
CMake: find_package(Qt6 REQUIRED COMPONENTS Grpc)
target_link_libraries(mytarget PRIVATE Qt6::Grpc)
Since: Qt 6.6
在 QML: GrpcCallOptions

公共函数

QGrpcCallOptions ()
QGrpcCallOptions (const QGrpcCallOptions & other )
QGrpcCallOptions (QGrpcCallOptions && other )
~QGrpcCallOptions ()
(从 6.10 起) QGrpcCallOptions & addMetadata (QByteArrayView key , QByteArrayView value )
std::optional<std::chrono::milliseconds> deadlineTimeout () const
(since 6.11) std::optional<bool> filterServerMetadata () const
(until 6.13) QHash<QByteArray, QByteArray> metadata () &&
(until 6.13) const QHash<QByteArray, QByteArray> & metadata () const &
(从 6.10 起) QMultiHash<QByteArray, QByteArray> metadata (QtGrpc::MultiValue_t) &&
(从 6.10 起) const QMultiHash<QByteArray, QByteArray> & metadata (QtGrpc::MultiValue_t) const &
QGrpcCallOptions & setDeadlineTimeout (std::chrono::milliseconds timeout )
(since 6.11) QGrpcCallOptions & setFilterServerMetadata (bool value )
(until 6.13) QGrpcCallOptions & setMetadata (QHash<QByteArray, QByteArray> && metadata )
(从 6.10 起) QGrpcCallOptions & setMetadata (QMultiHash<QByteArray, QByteArray> && metadata )
(until 6.13) QGrpcCallOptions & setMetadata (const QHash<QByteArray, QByteArray> & metadata )
(从 6.10 起) QGrpcCallOptions & setMetadata (const QMultiHash<QByteArray, QByteArray> & metadata )
(从 6.10 起) QGrpcCallOptions & setMetadata (std::initializer_list<std::pair<QByteArray, QByteArray>> metadata )
(从 6.8 起) void swap (QGrpcCallOptions & other )
(从 6.8 起) QVariant operator QVariant () const
QGrpcCallOptions & operator= (QGrpcCallOptions && other )
QGrpcCallOptions & operator= (const QGrpcCallOptions & other )
(从 6.8 起) QDebug operator<< (QDebug debug , const QGrpcCallOptions & callOpts )

详细描述

QGrpcCallOptions lets you customize individual remote procedure calls (RPCs). The generated client interface provides access points to pass the QGrpcCallOptions. These options supersede the ones set via QGrpcChannelOptions .

To configure the default options shared by RPCs, use QGrpcChannelOptions .

QGrpcCallOptions callOpts;
// Set the metadata for an individial RPC
callOpts.setMetadata({
    { "header" , "value1" },
    { "header" , "value2" },
});
const auto &md = callOpts.metadata(QtGrpc::MultiValue);
qDebug() << "Call Metadata: " << md;
// Set a 2-second deadline for an individial RPC
callOpts.setDeadlineTimeout(2s);
qDebug() << "Call timeout: " << callOpts.deadlineTimeout();
					

成员函数文档编制

[until 6.13] QHash < QByteArray , QByteArray > QGrpcCallOptions:: metadata () &&

[noexcept, until 6.13] const QHash < QByteArray , QByteArray > &QGrpcCallOptions:: metadata () const &

该函数计划在 6.13 版弃用。

使用 QMultiHash overload instead.

Returns the metadata. If this field is unset, returns empty metadata.

注意: QGrpcHttp2Channel transports metadata as HTTP/2 headers. are case-insensitive ASCII strings. You must avoid using the internal prefixes: : (pseudo-header), grpc- ,或 qtgrpc- . may be either ASCII strings or binary data. For more information, see RFC 7540, Section 8.1.2 .

另请参阅 setMetadata ().

[until 6.13] QGrpcCallOptions &QGrpcCallOptions:: setMetadata ( QHash < QByteArray , QByteArray > && metadata )

[until 6.13] QGrpcCallOptions &QGrpcCallOptions:: setMetadata (const QHash < QByteArray , QByteArray > & metadata )

该函数计划在 6.13 版弃用。

使用 QMultiHash overload instead.

设置 metadata and returns a reference to the updated object.

注意: QGrpcHttp2Channel transports metadata as HTTP/2 headers. are case-insensitive ASCII strings. You must avoid using the internal prefixes: : (pseudo-header), grpc- ,或 qtgrpc- . may be either ASCII strings or binary data. For more information, see RFC 7540, Section 8.1.2 .

注意: Call metadata is merged with any channel-level metadata when the RPC starts — see QGrpcChannelOptions::setMetadata (QMultiHash).

另请参阅 metadata ().

[since 6.10] QMultiHash < QByteArray , QByteArray > QGrpcCallOptions:: metadata ( QtGrpc::MultiValue_t ) &&

[noexcept, since 6.10] const QMultiHash < QByteArray , QByteArray > &QGrpcCallOptions:: metadata ( QtGrpc::MultiValue_t ) const &

Returns the metadata. If this field is unset, returns empty metadata.

注意: QGrpcHttp2Channel transports metadata as HTTP/2 headers. are case-insensitive ASCII strings. You must avoid using the internal prefixes: : (pseudo-header), grpc- ,或 qtgrpc- . may be either ASCII strings or binary data. For more information, see RFC 7540, Section 8.1.2 . Multiple values per key are supported.

const auto &md = opts.metadata(QtGrpc::MultiValue);
			

These functions were introduced in Qt 6.10.

另请参阅 setMetadata .

[since 6.10] QGrpcCallOptions &QGrpcCallOptions:: setMetadata ( QMultiHash < QByteArray , QByteArray > && metadata )

[since 6.10] QGrpcCallOptions &QGrpcCallOptions:: setMetadata (const QMultiHash < QByteArray , QByteArray > & metadata )

[since 6.10] QGrpcCallOptions &QGrpcCallOptions:: setMetadata ( std::initializer_list < std::pair < QByteArray , QByteArray >> metadata )

设置 metadata and returns a reference to the updated object.

注意: QGrpcHttp2Channel transports metadata as HTTP/2 headers. are case-insensitive ASCII strings. You must avoid using the internal prefixes: : (pseudo-header), grpc- ,或 qtgrpc- . may be either ASCII strings or binary data. For more information, see RFC 7540, Section 8.1.2 . Multiple values per key are supported.

注意: Call metadata is merged with any channel-level metadata when the RPC starts — see QGrpcChannelOptions::setMetadata (QMultiHash).

These functions were introduced in Qt 6.10.

另请参阅 metadata (QtGrpc::MultiValue_t).

QGrpcCallOptions:: QGrpcCallOptions ()

Default-constructs an empty QGrpcCallOptions.

QGrpcCallOptions:: QGrpcCallOptions (const QGrpcCallOptions & other )

Copy-constructs a QGrpcCallOptions from other .

[noexcept] QGrpcCallOptions:: QGrpcCallOptions ( QGrpcCallOptions && other )

Move-constructs a new QGrpcCallOptions from other .

注意: The moved-from object other is placed in a partially-formed state, in which the only valid operations are destruction and assignment of a new value.

[noexcept] QGrpcCallOptions:: ~QGrpcCallOptions ()

销毁 QGrpcCallOptions .

[since 6.10] QGrpcCallOptions &QGrpcCallOptions:: addMetadata ( QByteArrayView key , QByteArrayView value )

添加 key and value metadata if the exact pair is not already contained. The same key may appear multiple times with different values.

注意: QGrpcHttp2Channel transports metadata as HTTP/2 headers. are case-insensitive ASCII strings. You must avoid using the internal prefixes: : (pseudo-header), grpc- ,或 qtgrpc- . may be either ASCII strings or binary data. For more information, see RFC 7540, Section 8.1.2 .

注意: Call metadata is merged with any channel-level metadata when the RPC starts — see QGrpcChannelOptions::addMetadata ()

该函数在 Qt 6.10 引入。

另请参阅 metadata () 和 setMetadata ().

[noexcept] std::optional < std::chrono::milliseconds > QGrpcCallOptions:: deadlineTimeout () const

Returns the timeout duration that is used to calculate the deadline for RPCs.

If this field is unset, returns an empty std::optional .

另请参阅 setDeadlineTimeout ().

[noexcept, since 6.11] std::optional < bool > QGrpcCallOptions:: filterServerMetadata () const

返回 true if protocol-related server metadata is excluded from the result. Returns false to include all metadata received from the server.

If this field is unset, returns an empty std::optional .

This function was introduced in Qt 6.11.

另请参阅 setFilterServerMetadata () 和 QGrpcChannelOptions::filterServerMetadata ().

QGrpcCallOptions &QGrpcCallOptions:: setDeadlineTimeout ( std::chrono::milliseconds timeout )

设置 timeout and returns a reference to the updated object.

A deadline sets the limit for how long a client is willing to wait for a response from a server. The actual deadline is computed by adding the timeout to the start time of the RPC.

The deadline applies to the entire lifetime of an RPC, which includes receiving the final QGrpcStatus for a previously started call and can thus be unwanted for (long-lived) streams.

注意: Setting this field overrides the corresponding channel options field — see QGrpcChannelOptions::setDeadlineTimeout ()

另请参阅 deadlineTimeout ().

[since 6.11] QGrpcCallOptions &QGrpcCallOptions:: setFilterServerMetadata ( bool value )

value is true , protocol-related metadata defined by the gRPC transport (such as reserved grpc- keys) will be excluded. If value is false , all metadata received from the server will be included.

*/ void QGrpcCommonOptions::setFilterServerMetadata (bool value) { m_filterServerMetadata = value; }

QT_END_NAMESPACE

注意: Setting this field overrides the corresponding channel options field — see QGrpcChannelOptions::setFilterServerMetadata ()

This function was introduced in Qt 6.11.

另请参阅 filterServerMetadata () 和 QGrpcChannelOptions::setFilterServerMetadata ().

[noexcept, since 6.8] void QGrpcCallOptions:: swap ( QGrpcCallOptions & other )

交换 other 与此对象。此操作很快且从不失败。

该函数在 Qt 6.8 引入。

[since 6.8] QVariant QGrpcCallOptions:: operator QVariant () const

构造新的 QVariant from this object.

该函数在 Qt 6.8 引入。

[noexcept] QGrpcCallOptions &QGrpcCallOptions:: operator= ( QGrpcCallOptions && other )

移动赋值 other 到此 QGrpcCallOptions and returns a reference to the updated object.

注意: The moved-from object other is placed in a partially-formed state, in which the only valid operations are destruction and assignment of a new value.

QGrpcCallOptions &QGrpcCallOptions:: operator= (const QGrpcCallOptions & other )

赋值 other 到此 QGrpcCallOptions and returns a reference to the updated object.

相关非成员

[since 6.8] QDebug operator<< ( QDebug debug , const QGrpcCallOptions & callOpts )

写入 callOpts to the specified stream debug .

该函数在 Qt 6.8 引入。

内容

  1. 公共函数

  2. 相关非成员

  3. 详细描述