QGrpcOperationContext shall be constructed with the valid serializer.
Let's avoid unnecessary error handling and assert if
QGrpcOperationContext doesn't contain a valid pointer to a serializer.
[ChangeLog][Grpc] QAbstractGrpcChannel implementations now are obliged
to supply QGrpcContext with the valid serializer. Any attempt to
deserialize the returned message with null serializer now will lead to
assert or SEGV.
Pick-to: 6.8
Change-Id: I1f9142244bf5b5ba7a3d04965649d0a0fbb143b9
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Unify constraints that we use in public API and move them to a
common header file. Add the missing constraints for protobuf types,
that includes all types that sufficient for protobuf processing. Add
map types constains, which checks if the Key and Value meet the
protobuf requirements.
Use newly introduced constaints across the code.
Pick-to: 6.8
Task-number: QTBUG-123626
Change-Id: I7d3944f0a1374e7616304a22ec7ff148967ef525
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
The function was introduced back then, when we had finished() separated
into error and ok state. When we switched to the QGrpcStatus finished()
the usefullness of this 'helper' got less and less, where now it's just
a simple wrapper around connect. Remove it now and add the note about
SingleShotConnection in finished()
This makes QGrpcCallReply useless (we could just use QGrpcOperation) but
we'll keep it for potentially further API that could be added for unary
calls only.
Task-number: QTBUG-125406
Pick-to: 6.8
Change-Id: I80bafe369f79361dc69580a1c11e13ee3104a304
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This getter is for internal usage in the QGrpcOperation subclasses and
is never non-null. It was provided as a raw pointer to avoid the sharing
with shared_ptr.
Rename it to context() and also provide a const version of it.
Task-number: QTBUG-123625
Pick-to: 6.8
Change-Id: I7099ae56974abc0af2d19d81993af3755eb40b1c
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
There is likely already an instantiation available for it. Prefer the
usage of QHash to stay within the (Qt) lib boundary.
Remove qgrpcdefs.h as it's now obsolete. Update all occurrences of
QGrpcMetadata.
Task-number: QTBUG-123625
Pick-to: 6.8
Change-Id: Ida7bcd851c2d4b247c1b7a8dccddc3d518e0b5ae
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This provides a life-line if we have to add an event handler at some
point.
This patch addresses all of such problems for QGrpc
... and adds a linebreak for consistency ;)
Task-number: QTBUG-123625
Pick-to: 6.8
Change-Id: Ic36a9b3ab2ef9b9adea38b4d4d78e2b3439e6504
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This will make it easier to re-use it. This enum has a high chance of
being reused in the future.
Task-number: QTBUG-123625
Pick-to: 6.8
Change-Id: I587a2ae41e85b03539bc6213f53851ac37a415df
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
don't let user run into page long error messages.
Task-number: QTBUG-123625
Pick-to: 6.8
Change-Id: Id0d3c41d452c65da633b96ed8c364076f03ef4ec
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
and delete the rvalue version. Don't hand out refs on temporaries!
Task-number: QTBUG-123625
Pick-to: 6.8
Change-Id: Ide13de50d23c542141ad537ce93dff553688999a
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
That includes:
- Group headers by module separated by a newline.
- Sort headers alphabetically (exception: qtgrpcglobal.h is first).
We're already practicing this. With this patch we do it more precisely
though.
Pick-to: 6.8
Change-Id: I7a5aab2f1224dc61c32f6ee4040a6bb601267edd
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Don't take the argument by value but rather rvalue. We can guarantee
that for the private pimpl.
As a drive-by mark the single arg ctor explicit.
Pick-to: 6.8
Change-Id: I5430923b757652dc15ab5ea00dbf542280dc6a30
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
The name 'channel operation' can be confusing for people who look at
this class. This was already observed with experienced Qt developers who
struggled to get the idea and usage of this.
This class doesn't perform any operations on its own. It simply holds the
context (e.g. service names, options, signals).
Try to resolve this by renaming into QGrpcOperationContext. I think this
is more accurate then what we had before.
Task-number: QTBUG-123625
Pick-to: 6.8
Change-Id: I6dad0247ffc4c20d1f0b31f1651a608d28043cb0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
... otherwise the following patches can not merge. The body will be
provided as a follow up.
Pick-to: 6.8
Change-Id: Ie0a5ae0333670c06bdefabda616318d7f5833bc8
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
The signal is the redundant attempt to make Qt-style primitives. It
increases the usage complexity without any visible advantages. The
finished signal should instead accept the QGrpcStatus code and allow
users to make the descisions about the success of the operation in a
single call stack.
[ChangeLog][GRPC] The QGrpcOperation::errorOccurred and
QGrpcChannelOperation::errorOccurred signals are removed.
[ChangeLog][GRPC] The QGrpcOperation::finished and
QGrpcChannelOperation::finished signals now have QGrpcStatus argument
that indicates the status received from the server-side for the
operation.
Task-number: QTBUG-123625
Change-Id: I87669e0921c41cef0ff9d408bed1b057ba5198f2
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
We rename the dataReady(), sendData(), cancelled() and writesDone()
signals to messageReceived(), writeMessageRequested(), cancelRequested()
and writesDoneRequested() respectively.
Signals in channel operations have different meanings as they either
report the result of specific operations (outgoing) or get a request
from the client (incoming).
Change-Id: Icbc9e99b49cbf8b9977d37a77d5abc56517f661e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Do not expose the QAbstractProtobufSerializer API for the
QGrpcOperation and derived classes. QProtobufMessage now allows
serializing using the base class pointer. So we may simplify the
gRPC operations api and implementation. The serializer now is hidden
as the implementation detail.
Change-Id: Ib6865119a1b24e9f43cf60a30e2acc8ad0afdabf
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
QAbstractGrpcClient is not abstract and doesn't offer any interfaces
for reimplementation. Assuming it's the base class for all gRPC
clients, containing the generic gRPC client functionality. Rename the
class accordingly.
Taks-number: QTBUG-123625
Change-Id: I38e18a3b67e5f0f9c754e65337b2780780eea467
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Originally motivated by Axivion(SV3), which nagged about the const
errorOccurred signal; this patch removes signal emission for failed
deserialization in the read() functions. Immediately handling this can
lead to better user code as an fallback mechanism can avoid further
execution of unneeded logic.
This patch makes the errorOcurred signal non-const and changes the
signature of the read methods to either return an optional or bool to
signal failure immediately.
Users can then retrieve the error through 'deserializationError()' or
'deserializationErrorString()'. This can be seen in the generated QML
integration code, which uses those to still emit the 'errorOcurred'
signal on deserialization failure.
Change-Id: Ie6761753145536a42d5dd5bf1eac18afa555581a
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Expose 'deserializationError' and 'deserializationErrorString', as this
will be needed by the following commit, that changes the error handling
for the read() functions.
An API user could probably need the information of the failed
deserialization.
Change-Id: I0a61b6e4d8d9528c1a9fb45284bcbef6887fb527
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Wrap status messages generated by QtGrpc with QObject::tr calls.
This allows having the translated status messages if localization
is done.
Change-Id: I7eb7d6f7ac803f60414b74e55f80915a5826904b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
fixes Axivion(SV2244): Warns when QObject derived classes do
not have at least one constructor receiving a QObject.
Change-Id: I57823bc501b80c9d9ddd9e97d204b400f55783d2
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
The Qt signals shouldn't be const. The hole chain of const modifiers
was the result of some intermediate implenentation. In general the
QGrpcChannelOperation *QGrpcOperation::channelOperation return value
doesn't require to be const and the depdendent const modifier of
QGrpcChannelOperation::sendData signal can be removed too.
Change-Id: I64719307b1b33f136b6073af90759628048142bb
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Use the explicit constructors instead of overloading with default
arguments when constructing QGrpcStatus with and without the status
message.
Task-number: QTBUG-123625
Change-Id: I647474e5f3394f18746b8f57f6c0eafc3a9a97fa
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
This improves tooling for return values that shouldn't be ignored.
As a drive-by mark some of those functions as noexcept.
Task-number: QTBUG-123625
Pick-to: 6.7
Change-Id: I92a7aed22208b1e5f073089306da2e04fb143f9b
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Found in API-Review.
As a drive-by also change the includes for private headers and
implementation files.
Task-number: QTBUG-123625
Pick-to: 6.7
Change-Id: Ice4218c0425888a53d3e78c9f53aecd7b459cc69
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Now when we store the pointer to the property ordering in each
QProtobufMessage instance, we may remove generating of redundant
(de)serialize functions from messages.
This adds the generic QProtobufMessage::serialize and
QProtobufMessage::deserialize methods. Also we don't need the
template serialize/deserilze methods in QAbstractProtobufSerializer
since ordering information can be retrieved from the protobuf message
base class.
[ChangeLog][Protobuf][QProtobufMessage] Added the serialize and
deserialize methods.
[ChangeLog][Protobuf][QAbstractProtobufSerializer] The serialize
and deserialize methods are now non-template.
[ChangeLog][Protobuf] The Q_DECLARE_PROTOBUF_SERIALIZERS macro
is removed from the API and is not generated anymore.
Task-number: QTBUG-120931
Change-Id: I8ba8e6bb83728e58f781f42520629e1a9be4f026
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Add the following methods:
- QGrpcOperation::read(QProtobufMessage *message) const
- QGrpcClientStream::sendMessage(const QProtobufMessage *message)
- QGrpcBidirStream::sendMessage(const QProtobufMessage *message)
Methods allow serializing/deserializing protobuf message using the
interface base class. These methods use the serializeRawMessage
and deserializeRawMessage methods of QAbstractProtobufSerializer, so
in current implentation they work relatively slower than their template
counterparts.
[ChangeLog][GRPC] Added the following interfaces to gRPC operation
classes:
- QGrpcOperation::read(QProtobufMessage *message) const
- QGrpcClientStream::sendMessage(const QProtobufMessage *message)
- QGrpcBidirStream::sendMessage(const QProtobufMessage *message)
Task-number: QTBUG-120972
Change-Id: I6fb1ec20efd680cb45ccf13833cd5b712d2dd0aa
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Add documentation and link QAbstractGrpcClient::errorOccurred and
QGrpcOperation::errorOccurred wis see also tags.
Pick-to: 6.5 6.6 6.7
Change-Id: I6b07f0d6f9113e1b60a0417f3d9bece0911bdccc
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
The API was based on the nested QEventLoop which might cause
potential issues. Since we didn't find a good way to implement this
in channels, it's better to remove the API. It can be restored in
the future releases.
[ChangeLog][GRPC][UnaryCall] The synchronous gRPC calls are not
generated anymore. All related API is removed.
Fixes: QTBUG-118097
Change-Id: Id6d1a610a24ff079ed9a4112ca69ceb61fe03d52
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Introduce interceptors mechanism for every type of call.
Introduce QGrpcInterceptorContinuation, which is
a std::function wrapper for a call.
Introduce QGrpcClientInterceptor - a interface, client API
to implement interception logic by QtGRPC user.
Introduce QGrpcInterceptorManager - registry and a runner
of interception chain.
[ChangeLog][GRPC] Add gRPC client interceptors mechanism,
with QGrpcInterceptorContinuation, QGrpcClientInterceptor,
and QGrpcClientInterceptorManager classes.
[ChangeLog][GRPC] Added setter methods to QGrpcChannelOperation.
[ChangeLog][GRPC] Added addInterceptorManager() method to
the QAbstractGrpcChannel class.
[ChangeLog][GRPC] Added QGrpcOperation::isFinished() method.
[ChangeLog][GRPC] Added QGrpcOperation::waitForFinished() method.
Task-number: QTBUG-111038
Change-Id: I8d49b8f3e8aec52441bf4aada5fdef6875926de2
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Add the getter of the 'method' name to the QGrpcOperation.
The userfacing getter can be useful for debugging and other
related operations.
Task-numner: QTBUG-105494
Change-Id: Iac210e3e34d16c4aa1b3123ecb98eeab0be5a7af
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
This is valid from the design point of view API separation, that
unlock further streaming API improvements.
[ChangeLog][GRPC] QGrpcOperation::abort function is replaced by
QGrpcOperation::cancel function. The logic of new function is generic
for all gRPC operations. All grpc operations(calls and streams) now
emit errorOccurred signal when cancelling.
Task-number: QTBUG-105494
Change-Id: If306dd1ae43daebf5049b5fee55ad90c7fa848c3
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Since QGrpcOperation::read is the common entry-point for the message
deserialization it makes sense to add the deserialization error
processing to the QGrpcOperation primitive.
Change-Id: Ia8ee5e44ab63dfac5c27e505c0194d4548bac157
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Add the interface that allows reading metadata information received
from the server from the grpc streams and call replies.
TODO: This commit only add interface that should be used in channel
implementation.
Task-number: QTBUG-113663
Change-Id: I9e3d1810d1ee6a3b4e04fbd3555e093789b623ce
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Make QGrpcOperation use QAbstractProtobufSerializer to perform
serialization.
Fixes: QTBUG-111406
Change-Id: I48e7ca97e043de3827d7c655ae508e221d3d4ca8
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Fix qdoc warnings with missing module header, for example QtGrpcDoc,
by removing moduleheader variable from the .qdocconf files.
Initially that was resolving issues when building documentation on macOS.
Fix the root cause of the problem by changing capitalization of the project
from QtGRPC, to QtGrpc (inspired by the QtNfc module).
Pick-to: 6.5
Change-Id: I3b9cc408235b191bbf1350a18bdd91ae45327e41
Reviewed-by: Luca Di Sera <luca.disera@qt.io>
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
In the recent implementation the std::shared_ptr takes the real
ownership over the Qt GRPC channel primitives such as QGrpcOperation,
QGrpcStream, and QGrpcReply. Meanwhile these primitives had the QObject
parent-children relationships with the classes derived of the
QAbstractGrpcClient. This led to the floating double free issue when
Qt GC removed the primitives before the std::shared_ptr did.
Break the parent-child linking between the Qt GRPC channel primitives
and QAbstractGrpcClient. Cleanup the code parts that suppressed the
issue - the use of deleteLater instead of calling destructor directly.
Pick-to: 6.5
Change-Id: I9c6562335020e45ddb8e440311ec119fc90777f8
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Add the missing class to the message declaration.
Amends 0d56724387
Pick-to: 6.5
Change-Id: Ida7e60904bbe7d337a46f764321bb9580e93f04d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Add QtGrpc index and classes documentation pages.
Fix missing links to QtGrpc documentation.
The modules are now consistently named 'Qt GRPC', 'Qt Protobuf'.
Pick-to: 6.5
Change-Id: Iabd91336c871e43c97c49712a52f3aa82f7e75a5
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Add missing explicit, override, default, const keywords.
Omit pointless inline.
Remove empty () in lambdas.
Include mocs for QtGrpc module.
Use trailing , in enums.
Use underlying type for enums.
Task-number: QTBUG-108833
Pick-to: 6.5
Change-Id: I34e73a7f2715f374303634f9ed0236601c094a84
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reflow QtGrpc documentation and messages.
Fix style and grammar issues in the QtGrpc.
Address minor code review suggestions from 'Introduce QtGrpc' patch.
Task-number: QTBUG-108833
Pick-to: 6.5
Change-Id: I74b9725e82e23d0ad6ae9be19b6c5542e63fc487
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
QGrpcOperation name is more matching the implementation,
because is no longer thread safe and does not implement any of
async methods.
Task-number: QTBUG-108833
Pick-to: 6.5
Change-Id: I926dc651b2c3daa58429bcb358a827bd398cee46
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>