QGrpcOperationContext Class

The QGrpcOperationContext class implements common logic to handle the gRPC communication from the channel side. More...

Header: #include <QGrpcOperationContext>
CMake: find_package(Qt6 REQUIRED COMPONENTS Grpc)
target_link_libraries(mytarget PRIVATE Qt6::Grpc)
Since: Qt 6.7
Inherits: QObject
Status: Technical Preview

Public Functions

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)

Signals

void cancelRequested()
void finished(const QGrpcStatus &status)
void messageReceived(const QByteArray &data)
void writeMessageRequested(const QByteArray &data)
void writesDoneRequested()

Detailed Description

Member Function Documentation

[noexcept] QByteArrayView QGrpcOperationContext::argument() const

Returns the serialized arguments that are used for this operation.

[noexcept] const QGrpcCallOptions &QGrpcOperationContext::callOptions() const &

Return the options that are assigned to this operation.

[signal] void QGrpcOperationContext::cancelRequested()

The signal is emitted when client requests to terminate the communication.

The signal should only be emitted from the client counterpart. Implementations of QAbstractGrpcChannel should attempt to close connection client-server connection and return immediately. The successful connection break is not guarateed. Further processing of the data received from a channel is not required and is not recommended.

The client side will be notificated by the QGrpcOperationContext::finished signal with QtGrpc::StatusCode::Cancelled status code.

The signal is implicitly connected to the QGrpcOperation counterpart.

[signal] void QGrpcOperationContext::finished(const QGrpcStatus &status)

The signal is emitted when the gRPC communication is finished.

It usually means that the server sent the status and closed the connection. Implementations of QAbstractGrpcChannel should detect this situation and emit the signal.

The signal is implicitly connected to the QGrpcOperation counterpart.

[signal] void QGrpcOperationContext::messageReceived(const QByteArray &data)

The signal should be emitted by the channel when the new chunk of data is received.

For client streams and unary calls, this means that the response is received from the server, and communication will be successfully finished. For server and bidi streams this signal should be called by channel to signalize that receiving of new message is completed and user business logic now can process it at the client side.

The signal is implicitly connected to the QGrpcOperation counterpart.

[noexcept] QLatin1StringView QGrpcOperationContext::method() const

Returns the method name that is assigned to this operation.

std::shared_ptr<const QAbstractProtobufSerializer> QGrpcOperationContext::serializer() const

Return the serializer that is assigned to this operation.

[noexcept] const QHash<QByteArray, QByteArray> &QGrpcOperationContext::serverMetadata() const &

Returns the metadata that is received from server.

The method is used implicitly by QGrpcOperation counterpart.

See also setServerMetadata().

[noexcept] QLatin1StringView QGrpcOperationContext::service() const

Returns the service name that is assigned to this operation.

void QGrpcOperationContext::setServerMetadata(QHash<QByteArray, QByteArray> &&metadata)

Stores the recently received server metadata.

The metadata then can be processed on the client side.

See also serverMetadata().

void QGrpcOperationContext::setServerMetadata(const QHash<QByteArray, QByteArray> &metadata)

Stores the recently received server metadata.

The metadata then can be processed on the client side.

[signal] void QGrpcOperationContext::writeMessageRequested(const QByteArray &data)

The signal is emitted when the client tries to send a new message to the channel.

This signal can only be emitted by client or bidi streams. Implementations of QAbstractGrpcChannel should connect the sending logic to this signal. The data should be wrapped with the channel-related headers and sent to the wire.

The signal is implicitly connected to the QGrpcOperation counterpart.

[signal] void QGrpcOperationContext::writesDoneRequested()

T.B.A

© 2024 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.