The QGrpcChannelOptions class offers various options for fine-tuning a gRPC channel. 更多...
| 頭: |
#include <QGrpcChannelOptions>
|
| CMake: |
find_package(Qt6 REQUIRED COMPONENTS Grpc)
target_link_libraries(mytarget PRIVATE Qt6::Grpc)
|
| Since: | Qt 6.6 |
| 在 QML: | GrpcChannelOptions |
| QGrpcChannelOptions () | |
| QGrpcChannelOptions (const QGrpcChannelOptions & other ) | |
| QGrpcChannelOptions (QGrpcChannelOptions && other ) | |
| ~QGrpcChannelOptions () | |
(從 6.10 起)
QGrpcChannelOptions &
|
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 & |
(從 6.8 起)
QGrpcSerializationFormat
|
serializationFormat () const |
| QGrpcChannelOptions & | setDeadlineTimeout (std::chrono::milliseconds timeout ) |
(since 6.11)
QGrpcChannelOptions &
|
setFilterServerMetadata (bool value ) |
(until 6.13)
QGrpcChannelOptions &
|
setMetadata (QHash<QByteArray, QByteArray> && metadata ) |
(從 6.10 起)
QGrpcChannelOptions &
|
setMetadata (QMultiHash<QByteArray, QByteArray> && metadata ) |
(until 6.13)
QGrpcChannelOptions &
|
setMetadata (const QHash<QByteArray, QByteArray> & metadata ) |
(從 6.10 起)
QGrpcChannelOptions &
|
setMetadata (const QMultiHash<QByteArray, QByteArray> & metadata ) |
(從 6.10 起)
QGrpcChannelOptions &
|
setMetadata (std::initializer_list<std::pair<QByteArray, QByteArray>> list ) |
(從 6.8 起)
QGrpcChannelOptions &
|
setSerializationFormat (const QGrpcSerializationFormat & format ) |
| QGrpcChannelOptions & | setSslConfiguration (const QSslConfiguration & sslConfiguration ) |
| std::optional<QSslConfiguration> | sslConfiguration () const |
(從 6.8 起)
void
|
swap (QGrpcChannelOptions & other ) |
(從 6.8 起)
QVariant
|
operator QVariant () const |
| QGrpcChannelOptions & | operator= (QGrpcChannelOptions && other ) |
| QGrpcChannelOptions & | operator= (const QGrpcChannelOptions & other ) |
(從 6.8 起)
QDebug
|
operator<< (QDebug debug , const QGrpcChannelOptions & chOpts ) |
QGrpcChannelOptions lets you customize a gRPC ™ channel. Some options apply to all remote procedure calls (RPCs) that operate on the associated channel, which is used to communicate with services.
Override options for specific RPCs with QGrpcCallOptions .
QGrpcChannelOptions channelOpts; // Apply common metadata to every RPC channelOpts.setMetadata({ { "header" , "value1" }, { "header" , "value2" }, }); const auto &md = channelOpts.metadata(QtGrpc::MultiValue); qDebug() << "Channel Metadata: " << md; // Apply a 2-second deadline to every RPC channelOpts.setDeadlineTimeout(2s); qDebug() << "Channel timeout: " << channelOpts.deadlineTimeout(); // Configure SSL/TLS configuration channelOpts.setSslConfiguration(QSslConfiguration());
注意: It is up to the channel's implementation to determine the specifics of these options.
[until 6.13]
QHash
<
QByteArray
,
QByteArray
> QGrpcChannelOptions::
metadata
() &&
[noexcept, until 6.13]
const
QHash
<
QByteArray
,
QByteArray
> &QGrpcChannelOptions::
metadata
() const &
該函數計劃在 6.13 版棄用。
使用 metadata (QtGrpc::MultiValue) 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
.
另請參閱 metadata (QtGrpc::MultiValue_t) and setMetadata ().
[until 6.13]
QGrpcChannelOptions
&QGrpcChannelOptions::
setMetadata
(
QHash
<
QByteArray
,
QByteArray
> &&
metadata
)
[until 6.13]
QGrpcChannelOptions
&QGrpcChannelOptions::
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
.
注意: This metadata is included in every RPC made through the channel. Channel metadata is merged with any call-specific metadata when the RPC starts — see QGrpcCallOptions::setMetadata (QMultiHash)
另請參閱 metadata ().
[since 6.10]
QMultiHash
<
QByteArray
,
QByteArray
> QGrpcChannelOptions::
metadata
(
QtGrpc::MultiValue_t
) &&
[noexcept, since 6.10]
const
QMultiHash
<
QByteArray
,
QByteArray
> &QGrpcChannelOptions::
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]
QGrpcChannelOptions
&QGrpcChannelOptions::
setMetadata
(
QMultiHash
<
QByteArray
,
QByteArray
> &&
metadata
)
[since 6.10]
QGrpcChannelOptions
&QGrpcChannelOptions::
setMetadata
(const
QMultiHash
<
QByteArray
,
QByteArray
> &
metadata
)
[since 6.10]
QGrpcChannelOptions
&QGrpcChannelOptions::
setMetadata
(
std::initializer_list
<
std::pair
<
QByteArray
,
QByteArray
>>
list
)
設置 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.
注意: This metadata is included in every RPC made through the channel. Channel metadata is merged with any call-specific metadata when the RPC starts — see QGrpcCallOptions::setMetadata (QMultiHash)
These functions were introduced in Qt 6.10.
另請參閱 metadata (QtGrpc::MultiValue_t).
Default-constructs an empty QGrpcChannelOptions.
Copy-constructs a QGrpcChannelOptions from other .
[noexcept]
QGrpcChannelOptions::
QGrpcChannelOptions
(
QGrpcChannelOptions
&&
other
)
Move-constructs a new QGrpcChannelOptions 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]
QGrpcChannelOptions::
~QGrpcChannelOptions
()
銷毀 QGrpcChannelOptions .
[since 6.10]
QGrpcChannelOptions
&QGrpcChannelOptions::
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
.
注意: This metadata is included in every RPC made through the channel. Channel metadata is merged with any call-specific metadata when the RPC starts — see QGrpcCallOptions::addMetadata ()
該函數在 Qt 6.10 引入。
另請參閱 metadata () 和 setMetadata ().
[noexcept]
std::optional
<
std::chrono::milliseconds
> QGrpcChannelOptions::
deadlineTimeout
() const
Returns the timeout duration that is used to calculate the deadline for the channel.
If this field is unset, returns an empty
std::optional
.
另請參閱 setDeadlineTimeout ().
[noexcept, since 6.11]
std::optional
<
bool
> QGrpcChannelOptions::
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 () 和 QGrpcCallOptions::filterServerMetadata ().
[since 6.8]
QGrpcSerializationFormat
QGrpcChannelOptions::
serializationFormat
() const
Returns the serialization format used by the channel.
If this field is unset, returns a 默認 constructed serialization format.
該函數在 Qt 6.8 引入。
另請參閱 setSerializationFormat ().
設置 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 applies to all RPCs that operate on the channel, except those overriden by QGrpcCallOptions::setDeadlineTimeout ()
另請參閱 deadlineTimeout ().
[since 6.11]
QGrpcChannelOptions
&QGrpcChannelOptions::
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 applies to all RPCs that operate on the channel, except those overriden by QGrpcCallOptions::filterServerMetadata
This function was introduced in Qt 6.11.
另請參閱 filterServerMetadata () 和 QGrpcCallOptions::setFilterServerMetadata ().
[since 6.8]
QGrpcChannelOptions
&QGrpcChannelOptions::
setSerializationFormat
(const
QGrpcSerializationFormat
&
format
)
Sets the serialization format for the channel and returns a reference to the updated object.
該函數在 Qt 6.8 引入。
另請參閱 serializationFormat ().
設置 sslConfiguration for the channel and returns a reference to the updated object.
另請參閱 sslConfiguration ().
Returns the SSL configuration for the channel.
If this field is unset, returns an empty
std::optional
.
另請參閱 setSslConfiguration ().
[noexcept, since 6.8]
void
QGrpcChannelOptions::
swap
(
QGrpcChannelOptions
&
other
)
交換 other 與此對象。此操作很快且從不失敗。
該函數在 Qt 6.8 引入。
[since 6.8]
QVariant
QGrpcChannelOptions::
operator QVariant
() const
構造新的 QVariant from this object.
該函數在 Qt 6.8 引入。
[noexcept]
QGrpcChannelOptions
&QGrpcChannelOptions::
operator=
(
QGrpcChannelOptions
&&
other
)
移動賦值 other 到此 QGrpcChannelOptions 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 到此 QGrpcChannelOptions and returns a reference to the updated object.
[since 6.8]
QDebug
operator<<
(
QDebug
debug
, const
QGrpcChannelOptions
&
chOpts
)
寫入 chOpts to the specified stream debug .
該函數在 Qt 6.8 引入。