diff options
Diffstat (limited to 'src/grpc')
-rw-r--r-- | src/grpc/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/grpc/doc/src/qtgrpc-client-service-methods.qdoc | 4 | ||||
-rw-r--r-- | src/grpc/qabstractgrpcchannel.cpp | 16 | ||||
-rw-r--r-- | src/grpc/qabstractgrpcchannel.h | 4 | ||||
-rw-r--r-- | src/grpc/qgrpcclientbase.cpp (renamed from src/grpc/qabstractgrpcclient.cpp) | 94 | ||||
-rw-r--r-- | src/grpc/qgrpcclientbase.h (renamed from src/grpc/qabstractgrpcclient.h) | 18 | ||||
-rw-r--r-- | src/grpc/qgrpchttp2channel.cpp | 2 | ||||
-rw-r--r-- | src/grpc/qgrpcoperation.cpp | 2 | ||||
-rw-r--r-- | src/grpc/qgrpcstream.h | 2 |
9 files changed, 72 insertions, 72 deletions
diff --git a/src/grpc/CMakeLists.txt b/src/grpc/CMakeLists.txt index ef8f57b..eb24f0a 100644 --- a/src/grpc/CMakeLists.txt +++ b/src/grpc/CMakeLists.txt @@ -10,7 +10,7 @@ qt_internal_add_module(Grpc qgrpcstatus.h qgrpcstatus.cpp qabstractgrpcchannel.h qabstractgrpcchannel_p.h qabstractgrpcchannel.cpp qgrpchttp2channel.h qgrpchttp2channel.cpp - qabstractgrpcclient.h qabstractgrpcclient.cpp + qgrpcclientbase.h qgrpcclientbase.cpp qgrpccalloptions.h qgrpccalloptions.cpp qgrpcchanneloptions.h qgrpcchanneloptions.cpp qgrpcclientinterceptor.h qgrpcclientinterceptor.cpp diff --git a/src/grpc/doc/src/qtgrpc-client-service-methods.qdoc b/src/grpc/doc/src/qtgrpc-client-service-methods.qdoc index 11138d1..0c26cb2 100644 --- a/src/grpc/doc/src/qtgrpc-client-service-methods.qdoc +++ b/src/grpc/doc/src/qtgrpc-client-service-methods.qdoc @@ -96,7 +96,7 @@ two alternative asynchronous methods: namespace ping::pong { namespace PingPongService { - class Client : public QAbstractGrpcClient { + class Client : public QGrpcClientBase { Q_OBJECT public: std::shared_ptr<QGrpcCallReply> PingPong(const ping::pong::Ping &arg, @@ -161,7 +161,7 @@ an argument to the callback function that is used in the call: This variant makes a connection to the \l{QGrpcCallReply::finished} signal implicitly, but you cannot cancel the call using the \l{QGrpcOperation::cancel} function, and to get information about error occurred you need to subscribe to -the common \l{QAbstractGrpcClient::errorOccurred} signal. +the common \l{QGrpcClientBase::errorOccurred} signal. \section1 Using the server streams in Qt GRPC diff --git a/src/grpc/qabstractgrpcchannel.cpp b/src/grpc/qabstractgrpcchannel.cpp index 6f096a5..347c217 100644 --- a/src/grpc/qabstractgrpcchannel.cpp +++ b/src/grpc/qabstractgrpcchannel.cpp @@ -43,7 +43,7 @@ QT_BEGIN_NAMESPACE method when making unary gRPC call. The \a channelOperation is the pointer to a channel side \l QGrpcChannelOperation primitive that is connected with \l QGrpcCallReply primitive, that is used in - \l QAbstractGrpcClient implementations. + \l QGrpcClientBase implementations. The function should implement the channel-side logic of unary call. The implementation must be asynchronous and must not block the thread where @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE This pure virtual function that the starts of the server-side stream. The \a channelOperation is the pointer to a channel side \l QGrpcChannelOperation primitive that is connected with \l QGrpcServerStream - primitive, that is used in \l QAbstractGrpcClient implementations. + primitive, that is used in \l QGrpcClientBase implementations. The function should implement the channel-side logic of server-side stream. The implementation must be asynchronous and must not block the thread where @@ -71,7 +71,7 @@ QT_BEGIN_NAMESPACE This pure virtual function that the starts of the client-side stream. The \a channelOperation is the pointer to a channel side \l QGrpcChannelOperation primitive that is connected with - \l QGrpcClientStream primitive, that is used in \l QAbstractGrpcClient. + \l QGrpcClientStream primitive, that is used in \l QGrpcClientBase. The function should implement the channel-side logic of client-side stream. The implementation must be asynchronous and must not block the thread where @@ -85,7 +85,7 @@ QT_BEGIN_NAMESPACE This pure virtual function that the starts of the bidirectional stream. The \a channelOperation is the pointer to a channel side \l QGrpcChannelOperation primitive that is connected with - \l QGrpcBidirStream primitive, that is used in \l QAbstractGrpcClient. + \l QGrpcBidirStream primitive, that is used in \l QGrpcClientBase. The function should implement the channel-side logic of bidirectional stream. The implementation must be asynchronous and must not block the @@ -132,7 +132,7 @@ const QGrpcChannelOptions &QAbstractGrpcChannel::channelOptions() const noexcept between them. The function should not be called directly, but only by - \l QAbstractGrpcClient implementations. + \l QGrpcClientBase implementations. */ std::shared_ptr<QGrpcCallReply> QAbstractGrpcChannel::call(QLatin1StringView method, QLatin1StringView service, @@ -172,7 +172,7 @@ std::shared_ptr<QGrpcCallReply> QAbstractGrpcChannel::call(QLatin1StringView met between them. The function should not be called directly, but only by - \l QAbstractGrpcClient implementations. + \l QGrpcClientBase implementations. */ std::shared_ptr<QGrpcServerStream> QAbstractGrpcChannel::startServerStream(QLatin1StringView method, QLatin1StringView service, @@ -211,7 +211,7 @@ QAbstractGrpcChannel::startServerStream(QLatin1StringView method, QLatin1StringV between them. The function should not be called directly, but only by - \l QAbstractGrpcClient. + \l QGrpcClientBase. */ std::shared_ptr<QGrpcClientStream> QAbstractGrpcChannel::startClientStream(QLatin1StringView method, QLatin1StringView service, @@ -241,7 +241,7 @@ QAbstractGrpcChannel::startClientStream(QLatin1StringView method, QLatin1StringV between them. The function should not be called directly, but only by - \l QAbstractGrpcClient. + \l QGrpcClientBase. */ std::shared_ptr<QGrpcBidirStream> QAbstractGrpcChannel::startBidirStream(QLatin1StringView method, QLatin1StringView service, diff --git a/src/grpc/qabstractgrpcchannel.h b/src/grpc/qabstractgrpcchannel.h index 690723e..6170385 100644 --- a/src/grpc/qabstractgrpcchannel.h +++ b/src/grpc/qabstractgrpcchannel.h @@ -16,7 +16,7 @@ QT_BEGIN_NAMESPACE -class QAbstractGrpcClient; +class QGrpcClientBase; class QAbstractProtobufSerializer; struct QAbstractGrpcChannelPrivate; class QGrpcServerStream; @@ -57,7 +57,7 @@ protected: [[nodiscard]] const QGrpcChannelOptions &channelOptions() const noexcept; - friend class QAbstractGrpcClient; + friend class QGrpcClientBase; explicit QAbstractGrpcChannel(const QGrpcChannelOptions &options); private: diff --git a/src/grpc/qabstractgrpcclient.cpp b/src/grpc/qgrpcclientbase.cpp index 3b88cbe..34cf470 100644 --- a/src/grpc/qabstractgrpcclient.cpp +++ b/src/grpc/qgrpcclientbase.cpp @@ -13,7 +13,7 @@ #include <private/qobject_p.h> -#include "qabstractgrpcclient.h" +#include "qgrpcclientbase.h" QT_BEGIN_NAMESPACE @@ -22,30 +22,30 @@ using namespace Qt::StringLiterals; namespace { static QString threadSafetyWarning(QLatin1StringView methodName) { - return QAbstractGrpcClient::tr("%1 is called from a different thread.\n" + return QGrpcClientBase::tr("%1 is called from a different thread.\n" "Qt GRPC doesn't guarantee thread safety on the channel level.\n" "You have to be confident that channel routines are working in " - "the same thread as QAbstractGrpcClient.") + "the same thread as QGrpcClientBase.") .arg(methodName); } } // namespace /*! - \class QAbstractGrpcClient + \class QGrpcClientBase \inmodule QtGrpc - \brief The QAbstractGrpcClient class is bridge between gRPC clients + \brief The QGrpcClientBase class is bridge between gRPC clients and channels. - QAbstractGrpcClient provides a set of functions for client classes + QGrpcClientBase provides a set of functions for client classes generated out of protobuf services. - QAbstractGrpcClient enforces thread safety for startStream() and call() methods + QGrpcClientBase enforces thread safety for startStream() and call() methods of generated clients. - The methods QAbstractGrpcClient::call() and QAbstractGrpcClient::startStream() + The methods QGrpcClientBase::call() and QGrpcClientBase::startStream() should only be called by the generated client classes. */ /*! - \fn template <typename StreamType> std::shared_ptr<StreamType> QAbstractGrpcClient::startStream(QLatin1StringView method, const QProtobufMessage &arg, const QGrpcCallOptions &options) + \fn template <typename StreamType> std::shared_ptr<StreamType> QGrpcClientBase::startStream(QLatin1StringView method, const QProtobufMessage &arg, const QGrpcCallOptions &options) Starts the stream \a method of the \e StreamType type with the message argument \a arg to the attached channel. @@ -58,14 +58,14 @@ static QString threadSafetyWarning(QLatin1StringView methodName) */ /*! - \fn void QAbstractGrpcClient::channelChanged() + \fn void QGrpcClientBase::channelChanged() \since 6.7 Indicates that a new channel is attached to the client. */ /*! - \fn void QAbstractGrpcClient::errorOccurred(const QGrpcStatus &status); + \fn void QGrpcClientBase::errorOccurred(const QGrpcStatus &status); Indicates that an error occurred during serialization. @@ -76,11 +76,11 @@ static QString threadSafetyWarning(QLatin1StringView methodName) */ -class QAbstractGrpcClientPrivate : public QObjectPrivate +class QGrpcClientBasePrivate : public QObjectPrivate { - Q_DECLARE_PUBLIC(QAbstractGrpcClient) + Q_DECLARE_PUBLIC(QGrpcClientBase) public: - QAbstractGrpcClientPrivate(QLatin1StringView service) : service(service) + QGrpcClientBasePrivate(QLatin1StringView service) : service(service) { } @@ -99,9 +99,9 @@ public: std::vector<std::shared_ptr<QGrpcOperation>> activeStreams; }; -QGrpcStatus QAbstractGrpcClientPrivate::checkThread(QLatin1StringView warningPreamble) +QGrpcStatus QGrpcClientBasePrivate::checkThread(QLatin1StringView warningPreamble) { - Q_Q(QAbstractGrpcClient); + Q_Q(QGrpcClientBase); QGrpcStatus status; if (q->thread() != QThread::currentThread()) { @@ -112,9 +112,9 @@ QGrpcStatus QAbstractGrpcClientPrivate::checkThread(QLatin1StringView warningPre return status; } -bool QAbstractGrpcClientPrivate::checkChannel() +bool QGrpcClientBasePrivate::checkChannel() { - Q_Q(QAbstractGrpcClient); + Q_Q(QGrpcClientBase); if (!channel) { emit q->errorOccurred(QGrpcStatus{ QGrpcStatus::Unknown, @@ -124,9 +124,9 @@ bool QAbstractGrpcClientPrivate::checkChannel() return true; } -void QAbstractGrpcClientPrivate::addStream(std::shared_ptr<QGrpcOperation> grpcStream) +void QGrpcClientBasePrivate::addStream(std::shared_ptr<QGrpcOperation> grpcStream) { - Q_Q(QAbstractGrpcClient); + Q_Q(QGrpcClientBase); auto errorConnection = std::make_shared<QMetaObject::Connection>(); auto finishedConnection = std::make_shared<QMetaObject::Connection>(); @@ -138,7 +138,7 @@ void QAbstractGrpcClientPrivate::addStream(std::shared_ptr<QGrpcOperation> grpcS qGrpcWarning() << grpcStream->method() << "call" << service << "stream error: " << status.message(); - Q_Q(QAbstractGrpcClient); + Q_Q(QGrpcClientBase); emit q->errorOccurred(status); removeStream(std::move(grpcStream)); }); @@ -156,7 +156,7 @@ void QAbstractGrpcClientPrivate::addStream(std::shared_ptr<QGrpcOperation> grpcS activeStreams.push_back(grpcStream); } -void QAbstractGrpcClientPrivate::removeStream(std::shared_ptr<QGrpcOperation> grpcStream) +void QGrpcClientBasePrivate::removeStream(std::shared_ptr<QGrpcOperation> grpcStream) { auto it = std::find(activeStreams.begin(), activeStreams.end(), grpcStream); if (it != activeStreams.end()) @@ -165,12 +165,12 @@ void QAbstractGrpcClientPrivate::removeStream(std::shared_ptr<QGrpcOperation> gr grpcStream.reset(); } -QAbstractGrpcClient::QAbstractGrpcClient(QLatin1StringView service, QObject *parent) - : QObject(*new QAbstractGrpcClientPrivate(service), parent) +QGrpcClientBase::QGrpcClientBase(QLatin1StringView service, QObject *parent) + : QObject(*new QGrpcClientBasePrivate(service), parent) { } -QAbstractGrpcClient::~QAbstractGrpcClient() = default; +QGrpcClientBase::~QGrpcClientBase() = default; /*! Attaches \a channel to client as transport layer for gRPC. @@ -180,17 +180,17 @@ QAbstractGrpcClient::~QAbstractGrpcClient() = default; \note \b Warning: Qt GRPC doesn't guarantee thread safety on the channel level. You have to invoke the channel-related functions on the same thread as - QAbstractGrpcClient. + QGrpcClientBase. */ -void QAbstractGrpcClient::attachChannel(const std::shared_ptr<QAbstractGrpcChannel> &channel) +void QGrpcClientBase::attachChannel(const std::shared_ptr<QAbstractGrpcChannel> &channel) { if (channel->dPtr->threadId != QThread::currentThreadId()) { - const QString status = threadSafetyWarning("QAbstractGrpcClient::attachChannel"_L1); + const QString status = threadSafetyWarning("QGrpcClientBase::attachChannel"_L1); qGrpcCritical() << status; emit errorOccurred(QGrpcStatus{ QGrpcStatus::Unknown, status }); return; } - Q_D(QAbstractGrpcClient); + Q_D(QGrpcClientBase); for (auto &stream : d->activeStreams) { assert(stream != nullptr); stream->cancel(); @@ -200,7 +200,7 @@ void QAbstractGrpcClient::attachChannel(const std::shared_ptr<QAbstractGrpcChann emit channelChanged(); } -std::shared_ptr<QGrpcCallReply> QAbstractGrpcClient::call(QLatin1StringView method, +std::shared_ptr<QGrpcCallReply> QGrpcClientBase::call(QLatin1StringView method, const QProtobufMessage &arg, const QGrpcCallOptions &options) { @@ -214,19 +214,19 @@ std::shared_ptr<QGrpcCallReply> QAbstractGrpcClient::call(QLatin1StringView meth \since 6.7 Returns the channel attached to this client. */ -std::shared_ptr<QAbstractGrpcChannel> QAbstractGrpcClient::channel() const noexcept +std::shared_ptr<QAbstractGrpcChannel> QGrpcClientBase::channel() const noexcept { - Q_D(const QAbstractGrpcClient); + Q_D(const QGrpcClientBase); return d->channel; } -std::shared_ptr<QGrpcCallReply> QAbstractGrpcClient::call(QLatin1StringView method, +std::shared_ptr<QGrpcCallReply> QGrpcClientBase::call(QLatin1StringView method, QByteArrayView arg, const QGrpcCallOptions &options) { std::shared_ptr<QGrpcCallReply> reply; - Q_D(QAbstractGrpcClient); - if (d->checkThread("QAbstractGrpcClient::call"_L1) != QGrpcStatus::Ok) + Q_D(QGrpcClientBase); + if (d->checkThread("QGrpcClientBase::call"_L1) != QGrpcStatus::Ok) return reply; if (!d->checkChannel()) @@ -252,12 +252,12 @@ QT_WARNING_POP } std::shared_ptr<QGrpcServerStream> -QAbstractGrpcClient::startServerStream(QLatin1StringView method, QByteArrayView arg, +QGrpcClientBase::startServerStream(QLatin1StringView method, QByteArrayView arg, const QGrpcCallOptions &options) { - Q_D(QAbstractGrpcClient); + Q_D(QGrpcClientBase); - if (d->checkThread("QAbstractGrpcClient::startStream<QGrpcServerStream>"_L1) != QGrpcStatus::Ok) + if (d->checkThread("QGrpcClientBase::startStream<QGrpcServerStream>"_L1) != QGrpcStatus::Ok) return {}; if (!d->checkChannel()) @@ -270,12 +270,12 @@ QAbstractGrpcClient::startServerStream(QLatin1StringView method, QByteArrayView } std::shared_ptr<QGrpcClientStream> -QAbstractGrpcClient::startClientStream(QLatin1StringView method, QByteArrayView arg, +QGrpcClientBase::startClientStream(QLatin1StringView method, QByteArrayView arg, const QGrpcCallOptions &options) { - Q_D(QAbstractGrpcClient); + Q_D(QGrpcClientBase); - if (d->checkThread("QAbstractGrpcClient::startStream<QGrpcClientStream>"_L1) != QGrpcStatus::Ok) + if (d->checkThread("QGrpcClientBase::startStream<QGrpcClientStream>"_L1) != QGrpcStatus::Ok) return {}; if (!d->checkChannel()) @@ -288,12 +288,12 @@ QAbstractGrpcClient::startClientStream(QLatin1StringView method, QByteArrayView } std::shared_ptr<QGrpcBidirStream> -QAbstractGrpcClient::startBidirStream(QLatin1StringView method, QByteArrayView arg, +QGrpcClientBase::startBidirStream(QLatin1StringView method, QByteArrayView arg, const QGrpcCallOptions &options) { - Q_D(QAbstractGrpcClient); + Q_D(QGrpcClientBase); - if (d->checkThread("QAbstractGrpcClient::startStream<QGrpcBidirStream>"_L1) != QGrpcStatus::Ok) + if (d->checkThread("QGrpcClientBase::startStream<QGrpcBidirStream>"_L1) != QGrpcStatus::Ok) return {}; if (!d->checkChannel()) @@ -305,9 +305,9 @@ QAbstractGrpcClient::startBidirStream(QLatin1StringView method, QByteArrayView a return grpcStream; } -std::optional<QByteArray> QAbstractGrpcClient::trySerialize(const QProtobufMessage &arg) +std::optional<QByteArray> QGrpcClientBase::trySerialize(const QProtobufMessage &arg) { - Q_D(QAbstractGrpcClient); + Q_D(QGrpcClientBase); using namespace Qt::StringLiterals; auto _serializer = d->serializer(); if (_serializer == nullptr) { @@ -320,4 +320,4 @@ std::optional<QByteArray> QAbstractGrpcClient::trySerialize(const QProtobufMessa QT_END_NAMESPACE -#include "moc_qabstractgrpcclient.cpp" +#include "moc_qgrpcclientbase.cpp" diff --git a/src/grpc/qabstractgrpcclient.h b/src/grpc/qgrpcclientbase.h index 226aa8e..90180a0 100644 --- a/src/grpc/qabstractgrpcclient.h +++ b/src/grpc/qgrpcclientbase.h @@ -2,8 +2,8 @@ // Copyright (C) 2019 Alexey Edelev <semlanik@gmail.com> // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only -#ifndef QABSTRACTGRPCLIENT_H -#define QABSTRACTGRPCLIENT_H +#ifndef QGRPCLIENTBASE_H +#define QGRPCLIENTBASE_H #include <QtCore/qobject.h> #include <QtCore/qsharedpointer.h> @@ -22,9 +22,9 @@ QT_BEGIN_NAMESPACE class QGrpcOperation; class QAbstractGrpcChannel; -class QAbstractGrpcClientPrivate; +class QGrpcClientBasePrivate; -class Q_GRPC_EXPORT QAbstractGrpcClient : public QObject +class Q_GRPC_EXPORT QGrpcClientBase : public QObject { Q_OBJECT Q_PROPERTY(std::shared_ptr<QAbstractGrpcChannel> channel READ channel @@ -32,14 +32,14 @@ class Q_GRPC_EXPORT QAbstractGrpcClient : public QObject public: void attachChannel(const std::shared_ptr<QAbstractGrpcChannel> &channel); [[nodiscard]] std::shared_ptr<QAbstractGrpcChannel> channel() const noexcept; - ~QAbstractGrpcClient() override; + ~QGrpcClientBase() override; Q_SIGNALS: void errorOccurred(const QGrpcStatus &status); void channelChanged(); protected: - explicit QAbstractGrpcClient(QLatin1StringView service, QObject *parent = nullptr); + explicit QGrpcClientBase(QLatin1StringView service, QObject *parent = nullptr); std::shared_ptr<QGrpcCallReply> call(QLatin1StringView method, const QProtobufMessage &arg, const QGrpcCallOptions &options); @@ -85,10 +85,10 @@ private: std::optional<QByteArray> trySerialize(const QProtobufMessage &arg); - Q_DISABLE_COPY_MOVE(QAbstractGrpcClient) - Q_DECLARE_PRIVATE(QAbstractGrpcClient) + Q_DISABLE_COPY_MOVE(QGrpcClientBase) + Q_DECLARE_PRIVATE(QGrpcClientBase) }; QT_END_NAMESPACE -#endif // QABSTRACTGRPCLIENT_H +#endif // QGRPCLIENTBASE_H diff --git a/src/grpc/qgrpchttp2channel.cpp b/src/grpc/qgrpchttp2channel.cpp index aa858ed..1cdeeb1 100644 --- a/src/grpc/qgrpchttp2channel.cpp +++ b/src/grpc/qgrpchttp2channel.cpp @@ -4,7 +4,7 @@ #include "qgrpchttp2channel.h" -#include "qabstractgrpcclient.h" +#include "qgrpcclientbase.h" #include "qgrpcchanneloperation.h" #include "qgrpcserializationformat.h" diff --git a/src/grpc/qgrpcoperation.cpp b/src/grpc/qgrpcoperation.cpp index 0da120d..233fddc 100644 --- a/src/grpc/qgrpcoperation.cpp +++ b/src/grpc/qgrpcoperation.cpp @@ -49,7 +49,7 @@ using namespace Qt::StringLiterals; This signal is emitted when an error with \a status occurs in the channel. - \sa QAbstractGrpcClient::errorOccurred + \sa QGrpcClientBase::errorOccurred */ class QGrpcOperationPrivate : public QObjectPrivate diff --git a/src/grpc/qgrpcstream.h b/src/grpc/qgrpcstream.h index 6d699b9..cdde347 100644 --- a/src/grpc/qgrpcstream.h +++ b/src/grpc/qgrpcstream.h @@ -16,7 +16,7 @@ QT_BEGIN_NAMESPACE -class QAbstractGrpcClient; +class QGrpcClientBase; class Q_GRPC_EXPORT QGrpcServerStream final : public QGrpcOperation { |