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).
Default-constructs an empty QGrpcCallOptions.
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 ().
設置 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.
賦值 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 引入。