Browse Source

Qtfy grcp channels

- Add dixygen description to abstract channel
- Align names to integrate with qt
Alexey Edelev 5 years ago
parent
commit
066c7b8440

+ 2 - 2
examples/addressbook/addressbookengine.cpp

@@ -25,7 +25,7 @@
 
 #include "addressbookengine.h"
 #include "addressbookclient.h"
-#include <http2channel.h>
+#include <qgrpchttp2channel.h>
 #include <insecurecredentials.h>
 #include <sslcredentials.h>
 
@@ -58,7 +58,7 @@ AddressBookEngine::AddressBookEngine() : QObject()
     conf.setProtocol(QSsl::TlsV1_2);
     conf.setAllowedNextProtocols({QSslConfiguration::ALPNProtocolHTTP2});
 
-    std::shared_ptr<qtprotobuf::AbstractChannel> channel(new qtprotobuf::Http2Channel(QUrl("https://localhost:65001"), qtprotobuf::SslCredentials(conf) |
+    std::shared_ptr<qtprotobuf::QAbstractGrpcChannel> channel(new qtprotobuf::QGrpcHttp2Channel(QUrl("https://localhost:65001"), qtprotobuf::SslCredentials(conf) |
                                                                                       AuthCredentials("authorizedUser", QCryptographicHash::hash("test", QCryptographicHash::Md5).toHex())));
     m_client->attachChannel(channel);
     m_client->subscribeContactsUpdates(ListFrame());

+ 2 - 2
examples/simplechat/simplechatengine.cpp

@@ -25,7 +25,7 @@
 
 #include "simplechatengine.h"
 
-#include <http2channel.h>
+#include <qgrpchttp2channel.h>
 #include <insecurecredentials.h>
 #include <sslcredentials.h>
 
@@ -75,7 +75,7 @@ void SimpleChatEngine::login(const QString &name, const QString &password)
     conf.setAllowedNextProtocols({QSslConfiguration::ALPNProtocolHTTP2});
 
     QUrl url("https://localhost:65002");
-    std::shared_ptr<qtprotobuf::AbstractChannel> channel(new qtprotobuf::Http2Channel(url, qtprotobuf::SslCredentials(conf) |
+    std::shared_ptr<qtprotobuf::QAbstractGrpcChannel> channel(new qtprotobuf::QGrpcHttp2Channel(url, qtprotobuf::SslCredentials(conf) |
                                                                                       AuthCredentials(name, QCryptographicHash::hash(password.toUtf8(), QCryptographicHash::Md5).toHex())));
 
     m_client->attachChannel(channel);

+ 4 - 4
src/grpc/CMakeLists.txt

@@ -13,16 +13,16 @@ set(CMAKE_AUTORCC ON)
 include(${CMAKE_SOURCE_DIR}/cmake/Coverage.cmake)
 
 file(GLOB SOURCES asyncreply.cpp
-    abstractchannel.cpp
-    http2channel.cpp
+    qabstractgrpcchannel.cpp
+    qgrpchttp2channel.cpp
     abstractclient.cpp
     abstractcredentials.cpp
     sslcredentials.cpp
     insecurecredentials.cpp)
 
 file(GLOB HEADERS asyncreply.h
-    abstractchannel.h
-    http2channel.h
+    qabstractgrpcchannel.h
+    qgrpchttp2channel.h
     abstractclient.h
     abstractcredentials.h
     sslcredentials.h

+ 7 - 7
src/grpc/abstractclient.cpp

@@ -32,7 +32,7 @@ class AbstractClientPrivate final {
 public:
     AbstractClientPrivate(const QString &service) : service(service) {}
 
-    std::shared_ptr<AbstractChannel> channel;
+    std::shared_ptr<QAbstractGrpcChannel> channel;
     const QString service;
 };
 }
@@ -49,14 +49,14 @@ AbstractClient::~AbstractClient()
     delete d;
 }
 
-void AbstractClient::attachChannel(const std::shared_ptr<AbstractChannel> &channel)
+void AbstractClient::attachChannel(const std::shared_ptr<QAbstractGrpcChannel> &channel)
 {
     d->channel = channel;
 }
 
-AbstractChannel::StatusCode AbstractClient::call(const QString &method, const QByteArray &arg, QByteArray &ret)
+QAbstractGrpcChannel::StatusCode AbstractClient::call(const QString &method, const QByteArray &arg, QByteArray &ret)
 {
-    AbstractChannel::StatusCode callStatus = AbstractChannel::Unknown;
+    QAbstractGrpcChannel::StatusCode callStatus = QAbstractGrpcChannel::Unknown;
     if (d->channel) {
         callStatus = d->channel->call(method, d->service, arg, ret);
     } else {
@@ -72,7 +72,7 @@ AsyncReply *AbstractClient::call(const QString &method, const QByteArray &arg)
     if (d->channel) {
         reply = new AsyncReply(d->channel, this);
 
-        connect(reply, &AsyncReply::error, this, [this, reply](AbstractChannel::StatusCode statusCode) {
+        connect(reply, &AsyncReply::error, this, [this, reply](QAbstractGrpcChannel::StatusCode statusCode) {
             emit error(statusCode, QLatin1String("Connection has been aborted."));
             reply->deleteLater();
         });
@@ -83,7 +83,7 @@ AsyncReply *AbstractClient::call(const QString &method, const QByteArray &arg)
 
         d->channel->call(method, d->service, arg, reply);
     } else {
-        emit error(AbstractChannel::Unknown, QLatin1String("No channel(s) attached."));
+        emit error(QAbstractGrpcChannel::Unknown, QLatin1String("No channel(s) attached."));
     }
 
     return reply;
@@ -94,6 +94,6 @@ void AbstractClient::subscribe_p(const QString &method, const QByteArray &arg, c
     if (d->channel) {
         d->channel->subscribe(method, d->service, arg, this, handler);
     } else {
-        emit error(AbstractChannel::Unknown, QLatin1String("No channel(s) attached."));
+        emit error(QAbstractGrpcChannel::Unknown, QLatin1String("No channel(s) attached."));
     }
 }

+ 6 - 6
src/grpc/abstractclient.h

@@ -34,13 +34,13 @@
 
 #include <qtprotobuflogging.h>
 
-#include "abstractchannel.h"
+#include "qabstractgrpcchannel.h"
 #include "asyncreply.h"
 
 #include "qtgrpcglobal.h"
 
 namespace qtprotobuf {
-class AbstractChannel;
+class QAbstractGrpcChannel;
 
 /*!
  * \ingroup QtGrpc
@@ -50,10 +50,10 @@ class Q_GRPC_EXPORT AbstractClient : public QObject
 {
     Q_OBJECT
 public:
-    void attachChannel(const std::shared_ptr<AbstractChannel> &channel);
+    void attachChannel(const std::shared_ptr<QAbstractGrpcChannel> &channel);
 
 signals:
-    void error(AbstractChannel::StatusCode code, const QString &errorText);
+    void error(QAbstractGrpcChannel::StatusCode code, const QString &errorText);
 
 protected:
     AbstractClient(const QString &service, QObject *parent = nullptr);
@@ -74,7 +74,7 @@ protected:
         }
 
         QByteArray retData;
-        if (AbstractChannel::StatusCode::Ok == call(method, arg.serialize(), retData)) {
+        if (QAbstractGrpcChannel::StatusCode::Ok == call(method, arg.serialize(), retData)) {
             try {
                 ret->deserialize(retData);
             } catch (std::invalid_argument &) {
@@ -124,7 +124,7 @@ protected:
     }
 
 private:
-    AbstractChannel::StatusCode call(const QString &method, const QByteArray &arg, QByteArray &ret);
+    QAbstractGrpcChannel::StatusCode call(const QString &method, const QByteArray &arg, QByteArray &ret);
     AsyncReply *call(const QString &method, const QByteArray &arg);
     void subscribe_p(const QString &method, const QByteArray &arg, const std::function<void(const QByteArray &)> &handler);
 

+ 2 - 2
src/grpc/abstractcredentials.h

@@ -139,7 +139,7 @@ AbstractCredentials::AbstractCredentials(const Channel &channel)
 template<typename Call, typename Channel,
          typename std::enable_if_t<std::is_base_of<qtprotobuf::CallCredentials, Call>::value
                                    && std::is_base_of<qtprotobuf::ChannelCredentials, Channel>::value, int> = 0>
-qtprotobuf::AbstractCredentials operator|(const Call &call, const Channel &channel)
+qtprotobuf::AbstractCredentials operator |(const Call &call, const Channel &channel)
 {
     return qtprotobuf::AbstractCredentials(call, channel);
 }
@@ -148,7 +148,7 @@ qtprotobuf::AbstractCredentials operator|(const Call &call, const Channel &chann
 template<typename Call, typename Channel,
          typename std::enable_if_t<std::is_base_of<qtprotobuf::CallCredentials, Call>::value
                                    && std::is_base_of<qtprotobuf::ChannelCredentials, Channel>::value, int> = 0>
-qtprotobuf::AbstractCredentials operator|(const Channel &channel, const Call &call)
+qtprotobuf::AbstractCredentials operator |(const Channel &channel, const Call &call)
 {
     return qtprotobuf::AbstractCredentials(call, channel);
 }

+ 4 - 4
src/grpc/asyncreply.h

@@ -30,7 +30,7 @@
 #include <QMutex>
 #include <memory>
 
-#include "abstractchannel.h"
+#include "qabstractgrpcchannel.h"
 
 #include "qtgrpcglobal.h"
 
@@ -59,10 +59,10 @@ public:
 
 signals:
     void finished();
-    void error(AbstractChannel::StatusCode);
+    void error(QAbstractGrpcChannel::StatusCode);
 
 protected:
-    AsyncReply(const std::shared_ptr<AbstractChannel> &channel, QObject *parent = nullptr) : QObject(parent)
+    AsyncReply(const std::shared_ptr<QAbstractGrpcChannel> &channel, QObject *parent = nullptr) : QObject(parent)
     , m_channel(channel){}
     ~AsyncReply();
 
@@ -74,7 +74,7 @@ private:
 
     friend class AbstractClient;
 
-    std::shared_ptr<AbstractChannel> m_channel;
+    std::shared_ptr<QAbstractGrpcChannel> m_channel;
     QByteArray m_data;
 
     QMutex m_asyncLock;

+ 1 - 1
src/grpc/abstractchannel.cpp → src/grpc/qabstractgrpcchannel.cpp

@@ -23,4 +23,4 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-#include "abstractchannel.h"
+#include "qabstractgrpcchannel.h"

+ 36 - 23
src/grpc/abstractchannel.h → src/grpc/qabstractgrpcchannel.h

@@ -37,14 +37,17 @@ class AsyncReply;
 class AbstractClient;
 /*!
  * \ingroup QtGrpc
- * \brief The AbstractChannel class
+ * \brief The QAbstractGrpcChannel class is interface that represents common gRPC channel functionality.
+ *        You may implement this interface to create own channels for gRPC transport.
  */
-class Q_GRPC_EXPORT AbstractChannel
+class Q_GRPC_EXPORT QAbstractGrpcChannel
 {
 public:
     /*!
      * \enum StatusCode
      * \brief Channel's status codes
+     *
+     * \see <a href="https://github.com/grpc/grpc/blob/master/doc/statuscodes.md">gRPC status codes</a>
      */
     enum StatusCode {
         Ok = 0,                 //!< No error
@@ -67,43 +70,53 @@ public:
     };
 
     /*!
-     * \brief call
-     * \param method
-     * \param service
-     * \param args
-     * \param ret
-     * \return
+     * \brief Calls \p method synchronously with given serialized messge \p args and write result of call to \p ret.
+     *        \note This method is synchronous, that means it doesn't returns until call complete or aborted by timeout if it's
+     *        implemented in inherited channel.
+     * \param[in] method remote method is called
+     * \param[in] service service identified in URL path format
+     * \param[in] args serialized argument message
+     * \param[out] ret output bytearray to collect returned message
+     * \return returns gRPC QAbstractGrpcChannel::Status code for operation
      */
     virtual StatusCode call(const QString &method, const QString &service, const QByteArray &args, QByteArray &ret) = 0;
 
     /*!
-     * \brief call
-     * \param method
-     * \param service
-     * \param args
-     * \param ret AsyncReply that will be returned to end-point user to read data once ready. AsyncReply owned by AbstractClient only.
-     * \return
+     * \brief Calls \p method asynchronously with given serialized messge \p args. Result of method call is written to AsyncReply.
+     *        \note This method is asynchronous, that means it returns control imediately after it is called.
+     * \param[in] method remote method is called
+     * \param[in] service service identified in URL path format
+     * \param[in] args serialized argument message
+     * \param[out] ret AsyncReply that will be returned to end-point user to read data once call complete.
+     *            AsyncReply lifecycle is managed by AbstractClient only.
+     *            \see AsyncReply for details
      */
     virtual void call(const QString &method, const QString &service, const QByteArray &args, qtprotobuf::AsyncReply *ret) = 0;
 
     /*!
-     * \brief subscribe
-     * \param method
-     * \param service
-     * \param args
-     * \param handler
+     * \brief Subscribes to server-side stream to receive updates for given \p method.
+     * \param[in] method remote method is called
+     * \param[in] service service identified in URL path format
+     * \param[in] args serialized argument message
+     * \param[in] handler callback that will be called when message recevied from the server-stream
      */
     virtual void subscribe(const QString &method, const QString &service, const QByteArray &args, AbstractClient *client, const std::function<void(const QByteArray &)> &handler) = 0;
 protected:
-    AbstractChannel() = default;
-    virtual ~AbstractChannel() = default;
+    QAbstractGrpcChannel() = default;
+    virtual ~QAbstractGrpcChannel() = default;
 
-    virtual void abort(AsyncReply *) {
+    /*!
+     * \brief aborts async call for given \p reply
+     *        \note by default abort is explicitly not supported by QAbstractGrpcChannel and throws assert when called
+     * \param[in] reply returned by asynchronous QAbstractGrpcChannel::call() method
+     */
+    virtual void abort(AsyncReply *reply) {
+        Q_UNUSED(reply)
         assert("Abort is not supported by used channel");
     }
 
     friend class AsyncReply;
 private:
-    Q_DISABLE_COPY(AbstractChannel)
+    Q_DISABLE_COPY(QAbstractGrpcChannel)
 };
 }

+ 45 - 45
src/grpc/http2channel.cpp → src/grpc/qgrpchttp2channel.cpp

@@ -23,7 +23,7 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-#include "http2channel.h"
+#include "qgrpchttp2channel.h"
 
 #include <QUrl>
 #include <QNetworkAccessManager>
@@ -49,40 +49,40 @@ namespace  {
  * This QNetworkReply::NetworkError -> AbstractChannel::StatusCode mapping should be kept in sync with original
  * <a href="https://github.com/grpc/grpc/blob/master/doc/statuscodes.md">gRPC status codes</a>
  */
-const static std::unordered_map<QNetworkReply::NetworkError, AbstractChannel::StatusCode> StatusCodeMap = {
-                                                                { QNetworkReply::ConnectionRefusedError, AbstractChannel::Unavailable },
-                                                                { QNetworkReply::RemoteHostClosedError, AbstractChannel::Unavailable },
-                                                                { QNetworkReply::HostNotFoundError, AbstractChannel::Unavailable },
-                                                                { QNetworkReply::TimeoutError, AbstractChannel::DeadlineExceeded },
-                                                                { QNetworkReply::OperationCanceledError, AbstractChannel::Unavailable },
-                                                                { QNetworkReply::SslHandshakeFailedError, AbstractChannel::PermissionDenied },
-                                                                { QNetworkReply::TemporaryNetworkFailureError, AbstractChannel::Unknown },
-                                                                { QNetworkReply::NetworkSessionFailedError, AbstractChannel::Unavailable },
-                                                                { QNetworkReply::BackgroundRequestNotAllowedError, AbstractChannel::Unknown },
-                                                                { QNetworkReply::TooManyRedirectsError, AbstractChannel::Unavailable },
-                                                                { QNetworkReply::InsecureRedirectError, AbstractChannel::PermissionDenied },
-                                                                { QNetworkReply::UnknownNetworkError, AbstractChannel::Unknown },
-                                                                { QNetworkReply::ProxyConnectionRefusedError, AbstractChannel::Unavailable },
-                                                                { QNetworkReply::ProxyConnectionClosedError, AbstractChannel::Unavailable },
-                                                                { QNetworkReply::ProxyNotFoundError, AbstractChannel::Unavailable },
-                                                                { QNetworkReply::ProxyTimeoutError, AbstractChannel::DeadlineExceeded },
-                                                                { QNetworkReply::ProxyAuthenticationRequiredError, AbstractChannel::Unauthenticated },
-                                                                { QNetworkReply::UnknownProxyError, AbstractChannel::Unknown },
-                                                                { QNetworkReply::ContentAccessDenied, AbstractChannel::PermissionDenied },
-                                                                { QNetworkReply::ContentOperationNotPermittedError, AbstractChannel::PermissionDenied },
-                                                                { QNetworkReply::ContentNotFoundError, AbstractChannel::NotFound },
-                                                                { QNetworkReply::AuthenticationRequiredError, AbstractChannel::PermissionDenied },
-                                                                { QNetworkReply::ContentReSendError, AbstractChannel::DataLoss },
-                                                                { QNetworkReply::ContentConflictError, AbstractChannel::InvalidArgument },
-                                                                { QNetworkReply::ContentGoneError, AbstractChannel::DataLoss },
-                                                                { QNetworkReply::UnknownContentError, AbstractChannel::Unknown },
-                                                                { QNetworkReply::ProtocolUnknownError, AbstractChannel::Unknown },
-                                                                { QNetworkReply::ProtocolInvalidOperationError, AbstractChannel::Unimplemented },
-                                                                { QNetworkReply::ProtocolFailure, AbstractChannel::Unknown },
-                                                                { QNetworkReply::InternalServerError, AbstractChannel::Internal },
-                                                                { QNetworkReply::OperationNotImplementedError, AbstractChannel::Unimplemented },
-                                                                { QNetworkReply::ServiceUnavailableError, AbstractChannel::Unavailable },
-                                                                { QNetworkReply::UnknownServerError, AbstractChannel::Unknown }};
+const static std::unordered_map<QNetworkReply::NetworkError, QAbstractGrpcChannel::StatusCode> StatusCodeMap = {
+                                                                { QNetworkReply::ConnectionRefusedError, QAbstractGrpcChannel::Unavailable },
+                                                                { QNetworkReply::RemoteHostClosedError, QAbstractGrpcChannel::Unavailable },
+                                                                { QNetworkReply::HostNotFoundError, QAbstractGrpcChannel::Unavailable },
+                                                                { QNetworkReply::TimeoutError, QAbstractGrpcChannel::DeadlineExceeded },
+                                                                { QNetworkReply::OperationCanceledError, QAbstractGrpcChannel::Unavailable },
+                                                                { QNetworkReply::SslHandshakeFailedError, QAbstractGrpcChannel::PermissionDenied },
+                                                                { QNetworkReply::TemporaryNetworkFailureError, QAbstractGrpcChannel::Unknown },
+                                                                { QNetworkReply::NetworkSessionFailedError, QAbstractGrpcChannel::Unavailable },
+                                                                { QNetworkReply::BackgroundRequestNotAllowedError, QAbstractGrpcChannel::Unknown },
+                                                                { QNetworkReply::TooManyRedirectsError, QAbstractGrpcChannel::Unavailable },
+                                                                { QNetworkReply::InsecureRedirectError, QAbstractGrpcChannel::PermissionDenied },
+                                                                { QNetworkReply::UnknownNetworkError, QAbstractGrpcChannel::Unknown },
+                                                                { QNetworkReply::ProxyConnectionRefusedError, QAbstractGrpcChannel::Unavailable },
+                                                                { QNetworkReply::ProxyConnectionClosedError, QAbstractGrpcChannel::Unavailable },
+                                                                { QNetworkReply::ProxyNotFoundError, QAbstractGrpcChannel::Unavailable },
+                                                                { QNetworkReply::ProxyTimeoutError, QAbstractGrpcChannel::DeadlineExceeded },
+                                                                { QNetworkReply::ProxyAuthenticationRequiredError, QAbstractGrpcChannel::Unauthenticated },
+                                                                { QNetworkReply::UnknownProxyError, QAbstractGrpcChannel::Unknown },
+                                                                { QNetworkReply::ContentAccessDenied, QAbstractGrpcChannel::PermissionDenied },
+                                                                { QNetworkReply::ContentOperationNotPermittedError, QAbstractGrpcChannel::PermissionDenied },
+                                                                { QNetworkReply::ContentNotFoundError, QAbstractGrpcChannel::NotFound },
+                                                                { QNetworkReply::AuthenticationRequiredError, QAbstractGrpcChannel::PermissionDenied },
+                                                                { QNetworkReply::ContentReSendError, QAbstractGrpcChannel::DataLoss },
+                                                                { QNetworkReply::ContentConflictError, QAbstractGrpcChannel::InvalidArgument },
+                                                                { QNetworkReply::ContentGoneError, QAbstractGrpcChannel::DataLoss },
+                                                                { QNetworkReply::UnknownContentError, QAbstractGrpcChannel::Unknown },
+                                                                { QNetworkReply::ProtocolUnknownError, QAbstractGrpcChannel::Unknown },
+                                                                { QNetworkReply::ProtocolInvalidOperationError, QAbstractGrpcChannel::Unimplemented },
+                                                                { QNetworkReply::ProtocolFailure, QAbstractGrpcChannel::Unknown },
+                                                                { QNetworkReply::InternalServerError, QAbstractGrpcChannel::Internal },
+                                                                { QNetworkReply::OperationNotImplementedError, QAbstractGrpcChannel::Unimplemented },
+                                                                { QNetworkReply::ServiceUnavailableError, QAbstractGrpcChannel::Unavailable },
+                                                                { QNetworkReply::UnknownServerError, QAbstractGrpcChannel::Unknown }};
 
 const char *GrpcAcceptEncodingHeader = "grpc-accept-encoding";
 const char *AcceptEncodingHeader = "accept-encoding";
@@ -151,7 +151,7 @@ struct Http2ChannelPrivate {
         }
     }
 
-    static QByteArray processReply(QNetworkReply *networkReply, AbstractChannel::StatusCode &statusCode) {
+    static QByteArray processReply(QNetworkReply *networkReply, QAbstractGrpcChannel::StatusCode &statusCode) {
         //Check if no network error occured
         if (networkReply->error() != QNetworkReply::NoError) {
             statusCode = StatusCodeMap.at(networkReply->error());
@@ -159,8 +159,8 @@ struct Http2ChannelPrivate {
         }
 
         //Check if server answer with error
-        statusCode = static_cast<AbstractChannel::StatusCode>(networkReply->rawHeader(GrpcStatusHeader).toInt());
-        if (statusCode != AbstractChannel::StatusCode::Ok) {
+        statusCode = static_cast<QAbstractGrpcChannel::StatusCode>(networkReply->rawHeader(GrpcStatusHeader).toInt());
+        if (statusCode != QAbstractGrpcChannel::StatusCode::Ok) {
             return {};
         }
 
@@ -185,17 +185,17 @@ struct Http2ChannelPrivate {
 
 }
 
-Http2Channel::Http2Channel(const QUrl &url, const AbstractCredentials &credentials) : AbstractChannel()
+QGrpcHttp2Channel::QGrpcHttp2Channel(const QUrl &url, const AbstractCredentials &credentials) : QAbstractGrpcChannel()
   , d(new Http2ChannelPrivate(url, credentials))
 {
 }
 
-Http2Channel::~Http2Channel()
+QGrpcHttp2Channel::~QGrpcHttp2Channel()
 {
     delete d;
 }
 
-AbstractChannel::StatusCode Http2Channel::call(const QString &method, const QString &service, const QByteArray &args, QByteArray &ret)
+QAbstractGrpcChannel::StatusCode QGrpcHttp2Channel::call(const QString &method, const QString &service, const QByteArray &args, QByteArray &ret)
 {
     QEventLoop loop;
 
@@ -214,7 +214,7 @@ AbstractChannel::StatusCode Http2Channel::call(const QString &method, const QStr
     return grpcStatus;
 }
 
-void Http2Channel::call(const QString &method, const QString &service, const QByteArray &args, qtprotobuf::AsyncReply *reply)
+void QGrpcHttp2Channel::call(const QString &method, const QString &service, const QByteArray &args, qtprotobuf::AsyncReply *reply)
 {
     QNetworkReply *networkReply = d->post(method, service, args);
 
@@ -232,13 +232,13 @@ void Http2Channel::call(const QString &method, const QString &service, const QBy
         }
     });
 
-    QObject::connect(reply, &AsyncReply::error, networkReply, [networkReply, connection](AbstractChannel::StatusCode code) {
+    QObject::connect(reply, &AsyncReply::error, networkReply, [networkReply, connection](QAbstractGrpcChannel::StatusCode code) {
         QObject::disconnect(connection);
         Http2ChannelPrivate::abortNetworkReply(networkReply);
     });
 }
 
-void Http2Channel::subscribe(const QString &method, const QString &service, const QByteArray &args, AbstractClient *client, const std::function<void (const QByteArray &)> &handler)
+void QGrpcHttp2Channel::subscribe(const QString &method, const QString &service, const QByteArray &args, AbstractClient *client, const std::function<void (const QByteArray &)> &handler)
 {
     QNetworkReply *networkReply = d->post(method, service, args, true);
 
@@ -289,7 +289,7 @@ void Http2Channel::subscribe(const QString &method, const QString &service, cons
     });
 }
 
-void Http2Channel::abort(AsyncReply *reply)
+void QGrpcHttp2Channel::abort(AsyncReply *reply)
 {
     assert(reply != nullptr);
     reply->setData({});

+ 6 - 6
src/grpc/http2channel.h → src/grpc/qgrpchttp2channel.h

@@ -25,7 +25,7 @@
 
 #pragma once
 
-#include "abstractchannel.h"
+#include "qabstractgrpcchannel.h"
 
 #include <QUrl>
 
@@ -35,13 +35,13 @@ class AbstractCredentials;
 
 /*!
  * \ingroup QtGrpc
- * \brief The Http2Channel class
+ * \brief The QGrpcHttp2Channel class
  */
-class Q_GRPC_EXPORT Http2Channel final : public AbstractChannel
+class Q_GRPC_EXPORT QGrpcHttp2Channel final : public QAbstractGrpcChannel
 {
 public:
-    Http2Channel(const QUrl &url, const AbstractCredentials &credentials);
-    ~Http2Channel();
+    QGrpcHttp2Channel(const QUrl &url, const AbstractCredentials &credentials);
+    ~QGrpcHttp2Channel();
 
     StatusCode call(const QString &method, const QString &service, const QByteArray &args, QByteArray &ret) override;
     void call(const QString &method, const QString &service, const QByteArray &args, qtprotobuf::AsyncReply *reply) override;
@@ -51,7 +51,7 @@ protected:
     void abort(AsyncReply *reply) override;
 
 private:
-    Q_DISABLE_COPY(Http2Channel)
+    Q_DISABLE_COPY(QGrpcHttp2Channel)
 
     // PIMPL
     struct Http2ChannelPrivate *d;

+ 16 - 16
tests/test_grpc/clienttest.cpp

@@ -24,7 +24,7 @@
  */
 
 #include "testserviceclient.h"
-#include "http2channel.h"
+#include "qgrpchttp2channel.h"
 #include "insecurecredentials.h"
 #include "blobmessage.h"
 #include <sslcredentials.h>
@@ -69,7 +69,7 @@ TEST_F(ClientTest, CheckMethodsGeneration)
 TEST_F(ClientTest, StringEchoTest)
 {
     TestServiceClient testClient;
-    testClient.attachChannel(std::make_shared<Http2Channel>(m_echoServerAddress, InsecureCredentials()));
+    testClient.attachChannel(std::make_shared<QGrpcHttp2Channel>(m_echoServerAddress, InsecureCredentials()));
     SimpleStringMessage request;
     QPointer<SimpleStringMessage> result(new SimpleStringMessage);
     request.setTestFieldString("Hello beach!");
@@ -81,7 +81,7 @@ TEST_F(ClientTest, StringEchoTest)
 TEST_F(ClientTest, StringEchoAsyncTest)
 {
     TestServiceClient testClient;
-    testClient.attachChannel(std::make_shared<Http2Channel>(m_echoServerAddress, InsecureCredentials()));
+    testClient.attachChannel(std::make_shared<QGrpcHttp2Channel>(m_echoServerAddress, InsecureCredentials()));
     SimpleStringMessage request;
     SimpleStringMessage result;
     request.setTestFieldString("Hello beach!");
@@ -100,7 +100,7 @@ TEST_F(ClientTest, StringEchoAsyncTest)
 TEST_F(ClientTest, StringEchoAsync2Test)
 {
     TestServiceClient testClient;
-    testClient.attachChannel(std::make_shared<Http2Channel>(m_echoServerAddress, InsecureCredentials()));
+    testClient.attachChannel(std::make_shared<QGrpcHttp2Channel>(m_echoServerAddress, InsecureCredentials()));
     SimpleStringMessage result;
     SimpleStringMessage request;
     request.setTestFieldString("Hello beach!");
@@ -117,7 +117,7 @@ TEST_F(ClientTest, StringEchoAsync2Test)
 TEST_F(ClientTest, StringEchoImmediateAsyncAbortTest)
 {
     TestServiceClient testClient;
-    testClient.attachChannel(std::make_shared<Http2Channel>(m_echoServerAddress, InsecureCredentials()));
+    testClient.attachChannel(std::make_shared<QGrpcHttp2Channel>(m_echoServerAddress, InsecureCredentials()));
     SimpleStringMessage result;
     SimpleStringMessage request;
     request.setTestFieldString("sleep");
@@ -130,13 +130,13 @@ TEST_F(ClientTest, StringEchoImmediateAsyncAbortTest)
         waiter.quit();
     });
 
-    AbstractChannel::StatusCode asyncStatus = AbstractChannel::StatusCode::Ok;
-    QObject::connect(reply, &AsyncReply::error, reply, [&asyncStatus](AbstractChannel::StatusCode code){
+    QAbstractGrpcChannel::StatusCode asyncStatus = QAbstractGrpcChannel::StatusCode::Ok;
+    QObject::connect(reply, &AsyncReply::error, reply, [&asyncStatus](QAbstractGrpcChannel::StatusCode code){
         asyncStatus = code;
     });
 
-    AbstractChannel::StatusCode clientStatus = AbstractChannel::StatusCode::Ok;
-    QObject::connect(&testClient, &TestServiceClient::error, reply, [&clientStatus](AbstractChannel::StatusCode code, QString errMsg){
+    QAbstractGrpcChannel::StatusCode clientStatus = QAbstractGrpcChannel::StatusCode::Ok;
+    QObject::connect(&testClient, &TestServiceClient::error, reply, [&clientStatus](QAbstractGrpcChannel::StatusCode code, QString errMsg){
         clientStatus = code;
         std::cerr << code << ":" << errMsg.toStdString();
     });
@@ -145,15 +145,15 @@ TEST_F(ClientTest, StringEchoImmediateAsyncAbortTest)
     reply->abort();
     waiter.exec();
 
-    ASSERT_EQ(clientStatus, AbstractChannel::StatusCode::Aborted);
-    ASSERT_EQ(asyncStatus, AbstractChannel::StatusCode::Aborted);
+    ASSERT_EQ(clientStatus, QAbstractGrpcChannel::StatusCode::Aborted);
+    ASSERT_EQ(asyncStatus, QAbstractGrpcChannel::StatusCode::Aborted);
     ASSERT_STREQ(result.testFieldString().toStdString().c_str(), "Result not changed by echo");
 }
 
 TEST_F(ClientTest, StringEchoDeferredAsyncAbortTest)
 {
     TestServiceClient testClient;
-    testClient.attachChannel(std::make_shared<Http2Channel>(m_echoServerAddress, InsecureCredentials()));
+    testClient.attachChannel(std::make_shared<QGrpcHttp2Channel>(m_echoServerAddress, InsecureCredentials()));
     SimpleStringMessage result;
     SimpleStringMessage request;
     request.setTestFieldString("sleep");
@@ -167,7 +167,7 @@ TEST_F(ClientTest, StringEchoDeferredAsyncAbortTest)
         result = reply->read<SimpleStringMessage>();
         waiter.quit();
     });
-    QObject::connect(reply, &AsyncReply::error, reply, [&errorCalled](AbstractChannel::StatusCode){
+    QObject::connect(reply, &AsyncReply::error, reply, [&errorCalled](QAbstractGrpcChannel::StatusCode){
         errorCalled = true;
     });
 
@@ -183,7 +183,7 @@ TEST_F(ClientTest, StringEchoDeferredAsyncAbortTest)
 TEST_F(ClientTest, StringEchoStreamTest)
 {
     TestServiceClient testClient;
-    testClient.attachChannel(std::make_shared<Http2Channel>(m_echoServerAddress, InsecureCredentials()));
+    testClient.attachChannel(std::make_shared<QGrpcHttp2Channel>(m_echoServerAddress, InsecureCredentials()));
     SimpleStringMessage result;
     SimpleStringMessage request;
     request.setTestFieldString("Stream");
@@ -213,7 +213,7 @@ TEST_F(ClientTest, StringEchoStreamTest)
 TEST_F(ClientTest, StringEchoStreamTestRetUpdates)
 {
     TestServiceClient testClient;
-    testClient.attachChannel(std::make_shared<Http2Channel>(m_echoServerAddress, InsecureCredentials()));
+    testClient.attachChannel(std::make_shared<QGrpcHttp2Channel>(m_echoServerAddress, InsecureCredentials()));
     SimpleStringMessage request;
     QPointer<SimpleStringMessage> result(new SimpleStringMessage);
 
@@ -239,7 +239,7 @@ TEST_F(ClientTest, StringEchoStreamTestRetUpdates)
 TEST_F(ClientTest, HugeBlobEchoStreamTest)
 {
     TestServiceClient testClient;
-    testClient.attachChannel(std::make_shared<Http2Channel>(m_echoServerAddress, InsecureCredentials()));
+    testClient.attachChannel(std::make_shared<QGrpcHttp2Channel>(m_echoServerAddress, InsecureCredentials()));
     BlobMessage result;
     BlobMessage request;
     QFile testFile("testfile");

+ 2 - 2
tests/test_grpc/sslclienttest.cpp

@@ -24,7 +24,7 @@
  */
 
 #include "testserviceclient.h"
-#include "http2channel.h"
+#include "qgrpchttp2channel.h"
 #include "blobmessage.h"
 #include <sslcredentials.h>
 
@@ -62,7 +62,7 @@ TEST_F(ClientTest, IncorrectSecureCredentialsTest)
     //  conf.setCaCertificates({QSslCertificate(cert)});
 
     TestServiceClient testClient;
-    testClient.attachChannel(std::make_shared<qtprotobuf::Http2Channel>(QUrl("https://localhost:60051", QUrl::StrictMode), qtprotobuf::SslCredentials(conf)));
+    testClient.attachChannel(std::make_shared<qtprotobuf::QGrpcHttp2Channel>(QUrl("https://localhost:60051", QUrl::StrictMode), qtprotobuf::SslCredentials(conf)));
 
     std::unique_ptr<SimpleStringMessage> result = std::make_unique<SimpleStringMessage>();
     EXPECT_FALSE(testClient.testMethod(SimpleStringMessage{"Hello beach!"}, result.get()));