Commit Graph

24 Commits

Author SHA1 Message Date
Dennis Oberst 778371b8ea Deprecate QHash<QBA,QBA> metadata in favor of QMultiHash
Even though gRPC provides some leeway, as "Access to metadata is
language dependent", we have yet to see an implementation which doesn't
support multiple values per key.

Common implementations like grpc-c++, grpc-go or grpc-java provide this
and we should do it aswell.

Ref: https://grpc.io/docs/what-is-grpc/core-concepts/#metadata
Ref: https://github.com/grpc/grpc-go/blob/master/Documentation/grpc-metadata.md#constructing-metadata

Use a base class to implement common functionality for the options
classes. Also use a new common class in the tests.

The QMultiHash overload is selected when the 'QtGrpc::MultiValue'
argument is used in 'metadata' calls. We update the documentation
accordingly.

Deprecation is scheduled for Qt 6.13

Users with a custom Qt build - those who care - should be rewarded with
minimal traces of this "accident" and should not suffer from potential
performance/storage overhead. Therefore we deprecate QtGrpc::MultiValue
for those builds, effectively providing Qt 7 behavior.

[ChangeLog][Deprecation Notice]
Deprecate the metadata()/setMetadata() methods on QGrpcCallOptions and
QGrpcChannelOptions that use QHash in favor of the new overloads that
use QMultiHash. This is more in line with the gRPC specification.

Fixes: QTBUG-136471
Change-Id: I58d14d2c304c06de269c99ba5383beee86d12f77
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-05-16 14:42:11 +02:00
Dennis Oberst 3b10708ed5 Use non _EXPORT version of QESDP specialization
Until we haven't found a clear conclusion with this lets remove.
It's safe to add it afterwards but it's not safe to remove.

Task-number: QTBUG-123625
Pick-to: 6.8
Change-Id: I8ee9a3c5edd3054e11328d0e408030c6cc19c3a4
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2024-09-05 12:49:59 +02:00
Dennis Oberst 2e8bff11d6 QtGrpc: polish public headers, sort member by getter/setter pairs
As a final step for 6.8 let's polish the headers. That includes
formatting them and also regrouping some class members to be in
getter/setter pairs instead of having all getter or setter combined.
This makes the header, and the features it provides, much easier to
follow. Also this is the schema that we already use in e.g. grpcquick.

Pick-to: 6.8
Change-Id: I95f9f1e3c75890ae5ea2002dfe3c6a35abf7baf3
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-08-27 19:51:52 +02:00
Dennis Oberst 19711e1d33 QGrpc{Channel, Call}Options: rename deadline to deadlineTimeout
We're setting the timeout value. The actual deadline is then calculated
right before the RPC starts. Rename the getters and setters to reflect
that.

Documentation update will be in a follow-up.

Task-number: QTBUG-125406
Pick-to: 6.8
Change-Id: If75c7ca9e1963b6e0b1816897a9f2fbe77b42d08
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-08-21 10:30:02 +02:00
Dennis Oberst f30945b7f5 QGrpcMetadata: use QHash instead of std::unordered_multimap <QBA, QBA>
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>
2024-07-29 09:21:18 +02:00
Dennis Oberst cc39238bbb Revert QGrpcDuration and use std::chrono::milliseconds directly again
This aligns with Qt's chrono first.

This commit reverts: 7a7e5a1c0c4f8070cf153f2b2979bd2f8d5f7ea8.

Task-number: QTBUG-123625
Pick-to: 6.8
Change-Id: If69b317e7cb52a90dfb2b5fd5859282acc51155c
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-07-29 09:21:13 +02:00
Dennis Oberst d70fd4b305 QGrpcCallOptions: transform into implicitly shared value class
As this class is copyable and really looks like a implicitly shared
value class transform it into such.

Also provide the missing testcase to this class.

Task-number: QTBUG-123625
Pick-to: 6.8
Change-Id: Ibdd24155a04b0ba8a622998cbc482428965e2288
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-07-29 09:20:56 +02:00
Dennis Oberst 61f7123e90 QGrpcCallOptions: add swap() and lift move SMFs to be inline
Add a custom deleter to the std::unique_ptr so that we can
lift the SMF to be inline.

As a drive-by add the missing documentation.

Task-number: QTBUG-123625
Pick-to: 6.8
Change-Id: I11509ae925a6964f4d7e9ddd30a30c604edcb909
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-06-14 14:51:44 +02:00
Dennis Oberst 584a971d35 QGrpc{Channel, Call}Options: prefer 'set~()' over 'with~()'
It was concluded that we will use the 'set~()' syntax in our options but
still return a reference to allow chaining.

Task-number: QTBUG-123625
Change-Id: I00838465b485d096b4b7bd3d691d24385543d662
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-05-28 10:54:19 +02:00
Dennis Oberst bf5bec1f02 QGrpcCallOptions: add debug streaming support
Change-Id: Id8a4616f69e9499b8bc77997016030f4e9a9fb94
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-05-08 15:51:48 +02:00
Dennis Oberst 434d7e1da4 QGrpcCallOptions: split metadata into ref-qualified members
It is dangerous to hand out references to temporaries. This change
optimizes and hardens the metadata() getter.

Change-Id: I7ba410879653754b2599b7e5d3b715fe382cfc5a
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-05-08 15:51:48 +02:00
Dennis Oberst baaf342e26 QGrpcCallOptions: rework header usage and make the PIMPL a class
Pick-to: 6.7
Change-Id: Ifc361e2b068ead91f683d38a2add9087365cd670
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-05-08 15:51:48 +02:00
Dennis Oberst d6134c6e11 Add QGrpcDuration: a typedef for std::chrono::milliseconds
std::chrono::milliseconds is already widely used in our API. Qt-ify
it for foresighted API and implementation design.

Task-number: QTBUG-120696
Change-Id: I03650045ee3c93f59b88864932dfe72442dc0925
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-05-06 15:26:28 +02:00
Dennis Oberst 0bd8fbb81a qgrpcmetadata.h: rename to qgrpcdefs.h
rename to 'qgrpcdefs' in order to add other type definitions.

Task-number: QTBUG-120696
Change-Id: I179553a36ae861b0685a7932c6ea7b5f89d97fa6
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-04-16 10:42:59 +02:00
Alexey Edelev 8471792099 Export only out-of-line members of the non-polymorphic QGrpcCallOptions
Task-number: QTBUG-123625
Change-Id: Id2531cdc2084d72e40f8ea15ee5da013a40e79c2
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-04-04 14:55:37 +02:00
Dennis Oberst 40f769c2d0 QGrpcCallOptions: add move version of withMetadata(~)
Change-Id: I5cec364c9bed8a4ea9915f88ea791bb9e2d9968f
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-03-26 11:31:17 +01:00
Dennis Oberst a69a583219 QGrpcCallOptions: declare implicit move and move assign ctors
This will follow the rule of five.

Task-number: QTBUG-123625
Pick-to: 6.7
Change-Id: I2f009f7a75b55c10a61c25f2d937c406327ff9da
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-03-26 11:30:58 +01:00
Dennis Oberst c8ca806f43 QGrpcCallOptions: modernize api with [[nodiscard]]
This improves tooling for return values that shouldn't be ignored.

As a drive-by mark those functions as noexcept.

Task-number: QTBUG-123625
Pick-to: 6.7
Change-Id: I838e9ff62cc6e3b75e39fd2cd972cca53abdee9e
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-03-26 11:30:52 +01:00
Dennis Oberst c232253fbc qtgrpc: unify includes to the schema <Module/file.h>
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>
2024-03-22 16:56:18 +01:00
Alexey Edelev 31f267affa Use const reference as the QGrpcCallOptions::metadata return type
Small optimization bit, to avoid potential extra copy of QGrpcMetadata
aka std::unordered_multimap, which doesn't support implicit sharing.

Change-Id: I9173cde9ca743be04f00b01a608ee1cf7055ba3c
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
2024-01-24 12:49:24 +01:00
Dennis Oberst ef8d1d5820 QGrpcCallOptions: remove maxRetryAttempts from public API
This feature hasn't been implemented yet and will not make it
into 6.6. Keep the API and docs sane by removing it from there.

Pick-to: 6.6 6.6.0
Change-Id: I2cb443e07a39150eafaec5714e5db69dd6ed51ce
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-09-15 11:52:19 +02:00
Konrad Kujawa f57775c830 Remove QGrpcUserPasswordCredentials
Remove QGrpcUserPasswordCredentials, as they are unused after introducing
QGrpcMetadata.

[ChangeLog] Removed QGrpcUserPasswordCredentials. Now user and password
credentials can be added by using QGrpcMetadata.

Task-number: QTBUG-111037
Change-Id: I8e998bae9882f238c4498f41e9f0d0a2894b49a7
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-06-01 09:53:21 +02:00
Konrad Kujawa 4235684288 Introduce QGrpcMetadata
Introduce alias to std::multimap names QGrpcMetadata, to represent
additional HTTP headers, that can be added to channel and call options.
Then channel implementations can use QGrpcMetadata and append all
metadata do each call (TODO).

Task-number: QTBUG-111037
Change-Id: Ie16e658407a57a5f44bc1a0ff54dcb3ca8b06fe1
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-05-23 13:34:34 +02:00
Konrad Kujawa 3b8b24c7e5 Introduce QGrpcCallOptions and QGrpcChannelOptions
Use the new classes to store call and channel options used to
create gRPC channels and perform gRPC calls.
Add QGrpcCallOptions parameter to call() and startStream() methods.
Change constructor parameter of QGrpcHttp2Channel and QGrpcChannel
to QGrpcChannelOptions that stores previous parameters used to
construct channel. Add additional deadline option to be able to
configure call timeout.

[ChangeLog] Add QGrpcCallOptions to store and process additional
call options.
[ChangeLog] Add QGrpcChannelOptions to store and process channel
options and default call options.

Task-number: QTBUG-111037
Change-Id: Icd92e95c036fb5b4c268907ab912fcf59ef9a69a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-05-23 13:34:34 +02:00