The QGrpcOperationContext class provides context for communication between an individual gRPC ™ operation and a channel. 更多...
| 头: |
#include <QGrpcOperationContext>
|
| CMake: |
find_package(Qt6 REQUIRED COMPONENTS Grpc)
target_link_libraries(mytarget PRIVATE Qt6::Grpc)
|
| Since: | Qt 6.7 |
| 继承: | QObject |
| virtual | ~QGrpcOperationContext () override |
| QByteArrayView | argument () const |
| const QGrpcCallOptions & | callOptions () const & |
| QLatin1StringView | method () const |
| std::shared_ptr<const QAbstractProtobufSerializer> | serializer () const |
| const QHash<QByteArray, QByteArray> & | serverMetadata () const & |
| QLatin1StringView | service () const |
| void | setServerMetadata (QHash<QByteArray, QByteArray> && metadata ) |
| void | setServerMetadata (const QHash<QByteArray, QByteArray> & metadata ) |
| void | cancelRequested () |
| void | messageReceived (const QByteArray & data ) |
| void | writeMessageRequested (const QByteArray & data ) |
| void | writesDoneRequested () |
QGrpcOperationContext is constructed internally when a remote procedure call (RPC) is requested, mediating interaction between the client's operation request and the channel's operation outcome.
RPCs requested on the client interface return specializations of QGrpcOperation ,譬如 QGrpcCallReply , QGrpcServerStream , QGrpcClientStream ,或 QGrpcBidiStream . These classes are implicitly integrated with the underlying QGrpcOperationContext counterpart.
注意: Don't use this class directly unless implementing a custom channel.
The signals contained within this class are used to build the communication between the client-facing QGrpcOperation 和 QAbstractGrpcChannel implementation. These operations are asynchronous in nature, and multiple RPCs can operate on the same channel concurrently. Channels typically treat all operations the same, and it is the channel's responsibility to correctly support and restrict the subset of features its RPC type supports.
Signals which should only be emitted by the channel's implementation are:
Signals which will be emitted by QGrpcOperation and its specializations are:
Custom implementations of QAbstractGrpcChannel must handle the client's signals, as no default signal handling is provided, and emit their own signals accordingly.
Sets the server metadata received from the service.
[override virtual noexcept]
QGrpcOperationContext::
~QGrpcOperationContext
()
Destroys the operation-context.
[noexcept]
QByteArrayView
QGrpcOperationContext::
argument
() const
Returns the serialized argument that is utilized by this operation-context.
[noexcept]
const
QGrpcCallOptions
&QGrpcOperationContext::
callOptions
() const &
Returns the call options that is utilized by this operation-context.
For channel-wide options, see QGrpcChannelOptions .
[signal]
void
QGrpcOperationContext::
cancelRequested
()
此信号发射由 QGrpcOperation when requesting cancellation of the communication.
The channel is expected to connect its cancellation logic to this signal and attempt to cancel the RPC and finish it with a Cancelled status code. Successful cancellation cannot be guaranteed. Further processing of the data received from a channel is not required and should be avoided.
另请参阅 QGrpcOperation::cancel .
[signal]
void
QGrpcOperationContext::
messageReceived
(const
QByteArray
&
data
)
This signal should be emitted by the channel when a new chunk of data is received from the server.
For client streams and unary calls, this means that the single and final response has arrived and communication is about to finish.
For server and bidirectional streams, this signal should be continuously emitted by the channel upon receiving each new messages.
注意: This signal is implicitly connected to the QGrpcOperation counterpart.
另请参阅 QGrpcServerStream::messageReceived and QGrpcBidiStream::messageReceived .
[noexcept]
QLatin1StringView
QGrpcOperationContext::
method
() const
Returns the method name of the service associated with this operation-context.
Returns the serializer of this operation-context
[noexcept]
const
QHash
<
QByteArray
,
QByteArray
> &QGrpcOperationContext::
serverMetadata
() const &
Returns the metadata received from the server.
注意: This method is used implicitly by the QGrpcOperation counterpart.
另请参阅 setServerMetadata ().
[noexcept]
QLatin1StringView
QGrpcOperationContext::
service
() const
Returns the service name associated with this operation-context.
[signal]
void
QGrpcOperationContext::
writeMessageRequested
(const
QByteArray
&
data
)
此信号发射由 QGrpcClientStream or QGrpcBidiStream when it has serialized data ready for a channel to deliver.
The channel is expected to connect its writing logic to this signal and wrap the serialized data in channel-related headers before writing it to the wire.
另请参阅 QGrpcClientStream::writeMessage and QGrpcBidiStream::writeMessage .
[signal]
void
QGrpcOperationContext::
writesDoneRequested
()
此信号发射由 QGrpcClientStream or QGrpcBidiStream to indicate that it's done writing messages. The channel should respond to this by half-closing the stream.
注意: After receiving this signal no more write operations are permitted for the streaming RPCs. The server can still send messages, which should be forwarded with messageReceived ().
另请参阅 QGrpcClientStream::writesDone and QGrpcBidiStream::writesDone .