Remove the 'stream' prefix from all streaming methods

There are no particular reasons for these prefixes. Remove them.

[ChangeLog][GRPC] The 'stream' prefix is removed for all generated
streaming methods.

Task-number: QTBUG-123625
Change-Id: Ie1e63a6c559e259956aa3b4b72aa3ef380df4f44
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
Alexey Edelev 2024-05-10 14:43:10 +02:00
parent 8d83970d7b
commit d69bc69750
15 changed files with 50 additions and 51 deletions

View File

@ -58,7 +58,7 @@ void SimpleChatEngine::login(const QString &name, const QString &password)
m_client->attachChannel(channel);
// ![1]
auto stream = m_client->streamMessageList(qtgrpc::examples::chat::None());
auto stream = m_client->messageList(qtgrpc::examples::chat::None());
QObject::connect(stream.get(), &QGrpcServerStream::errorOccurred, this,
[this, stream](const QGrpcStatus &status) {
qCritical()

View File

@ -28,7 +28,7 @@ void NaviThread::run()
}
Empty request;
m_stream = m_client->streamGetNaviStream(request);
m_stream = m_client->getNaviStream(request);
connect(m_stream.get(), &QGrpcServerStream::messageReceived, this, [this] {
const auto result = m_stream->read<DistanceMsg>();
if (!result)

View File

@ -41,7 +41,7 @@ void VehicleThread::run()
});
Empty speedRequest;
m_streamSpeed = m_client->streamGetSpeedStream(speedRequest);
m_streamSpeed = m_client->getSpeedStream(speedRequest);
connect(m_streamSpeed.get(), &QGrpcServerStream::messageReceived, this, [this] {
if (const auto speedResponse = m_streamSpeed->read<SpeedMsg>())
emit speedChanged(speedResponse->speed());
@ -59,7 +59,7 @@ void VehicleThread::run()
[this] { emit speedChanged(0); });
Empty gearRequest;
m_streamGear = m_client->streamGetGearStream(gearRequest);
m_streamGear = m_client->getGearStream(gearRequest);
connect(m_streamGear.get(), &QGrpcServerStream::messageReceived, this, [this] {
if (const auto gearResponse = m_streamGear->read<GearMsg>())
emit rpmChanged(gearResponse->rpm());

View File

@ -173,7 +173,7 @@ For server streams, the \l {The qtgrpcgen Tool} {qtgrpcgen tool} generates
the method that returns the pointer to \l QGrpcServerStream:
\code
std::shared_ptr<QGrpcServerStream> streamPingSeveralPong(const ping::pong::Ping &arg,
std::shared_ptr<QGrpcServerStream> pingSeveralPong(const ping::pong::Ping &arg,
const QGrpcCallOptions &options = {});
\endcode
@ -215,14 +215,14 @@ For server streams, the \l {The qtgrpcgen Tool} {qtgrpcgen tool} generates
the method that returns the pointer to \l{QGrpcClientStream}:
\code
std::shared_ptr<QGrpcClientStream> streamSeveralPingPong(const ping::pong::Ping &arg,
std::shared_ptr<QGrpcClientStream> severalPingPong(const ping::pong::Ping &arg,
const QGrpcCallOptions &options = {});
\endcode
To send multiple requests to the server, use the
\l {QGrpcClientStream::sendMessage} method:
\code
auto stream = cl.streamSeveralPingPong(request);
auto stream = cl.severalPingPong(request);
QTimer timer;
QObject::connect(&timer, &QTimer::timeout, stream.get(),
@ -259,14 +259,14 @@ Bidirectional streams combine the functionality of server and client streams.
The generated method returns the pointer to \l QGrpcBidirStream, which provides
the API from both server and client streams:
\code
std::shared_ptr<QGrpcBidirStream> streamSeveralPingSeveralPong(const ping::pong::Ping &arg,
std::shared_ptr<QGrpcBidirStream> severalPingSeveralPong(const ping::pong::Ping &arg,
const QGrpcCallOptions &options = {});
\endcode
Use the bidirectional streams to organize the two-sided communication without
breaking the connection session:
\code
auto stream = cl.streamSeveralPingSeveralPong(request);
auto stream = cl.severalPingSeveralPong(request);
qint64 maxPingPongTime = 0;
QTimer timer;

View File

@ -107,13 +107,13 @@ const char *GrpcTemplates::ClientMethodDefinitionQmlTemplate()
const char *GrpcTemplates::ClientMethodStreamDeclarationTemplate()
{
return "std::shared_ptr<$stream_type$> stream$method_name_upper$(const $param_type$ "
return "std::shared_ptr<$stream_type$> $method_name$(const $param_type$ "
"&$param_name$, const QGrpcCallOptions &options = {});\n";
}
const char *GrpcTemplates::ClientMethodStreamDefinitionTemplate()
{
return "std::shared_ptr<$stream_type$> $classname$::stream$method_name_upper$("
return "std::shared_ptr<$stream_type$> $classname$::$method_name$("
"const $param_type$ &$param_name$, const QGrpcCallOptions &options)\n"
"{\n"
" return startStream<$stream_type$>(\"$method_name$\"_L1, "

View File

@ -368,7 +368,6 @@ MethodMap common::produceMethodMap(const MethodDescriptor *method, const std::st
{ "return_type", outputTypeName },
{ "classname_low_case", utils::deCapitalizeAsciiName(scope)},
{ "method_name", methodName },
{ "method_name_upper", methodNameUpper },
{ "param_type", inputTypeName },
{ "param_name", "arg" },
{ "stream_type", streamType },

View File

@ -34,7 +34,7 @@ void QtGrpcClientBidirStreamTest::valid()
SimpleStringMessage request;
request.setTestFieldString("Stream");
auto stream = client()->streamTestMethodBiStream(request);
auto stream = client()->testMethodBiStream(request);
QString fullResponse;
int i = 0;
@ -65,7 +65,7 @@ void QtGrpcClientBidirStreamTest::sequentialSendWithDone()
SimpleStringMessage request;
request.setTestFieldString("Stream");
auto stream = client()->streamTestMethodBiStreamWithDone(request);
auto stream = client()->testMethodBiStreamWithDone(request);
QString fullResponse;
int i = 0;

View File

@ -35,7 +35,7 @@ void QtGrpcClientClientStreamTest::valid()
SimpleStringMessage request;
request.setTestFieldString("Stream");
auto stream = client()->streamTestMethodClientStream(request);
auto stream = client()->testMethodClientStream(request);
int i = 0;
QTimer sendTimer;
@ -67,7 +67,7 @@ void QtGrpcClientClientStreamTest::sequentialSend()
SimpleStringMessage request;
request.setTestFieldString("Stream");
auto stream = client()->streamTestMethodClientStream(request);
auto stream = client()->testMethodClientStream(request);
// Ensure that messages are not lost during the sequential sending right after the stream is
// instanciated.
@ -96,7 +96,7 @@ void QtGrpcClientClientStreamTest::sequentialSendWithDone()
SimpleStringMessage request;
request.setTestFieldString("Stream");
auto stream = client()->streamTestMethodClientStreamWithDone(request);
auto stream = client()->testMethodClientStreamWithDone(request);
// Ensure that messages are not lost during the sequential sending right after the stream is
// instanciated.

View File

@ -56,7 +56,7 @@ void QtGrpcClientServerStreamTest::valid()
SimpleStringMessage request;
request.setTestFieldString("Stream");
auto stream = client()->streamTestMethodServerStream(request);
auto stream = client()->testMethodServerStream(request);
QSignalSpy messageReceivedSpy(stream.get(), &QGrpcServerStream::messageReceived);
QVERIFY(messageReceivedSpy.isValid());
@ -88,7 +88,7 @@ void QtGrpcClientServerStreamTest::cancel()
SimpleStringMessage request;
request.setTestFieldString("Stream");
auto stream = client()->streamTestMethodServerStream(request);
auto stream = client()->testMethodServerStream(request);
QSignalSpy streamFinishedSpy(stream.get(), &QGrpcServerStream::finished);
QVERIFY(streamFinishedSpy.isValid());
@ -119,7 +119,7 @@ void QtGrpcClientServerStreamTest::deferredCancel()
SimpleStringMessage request;
request.setTestFieldString("Stream");
auto stream = client()->streamTestMethodServerStream(request);
auto stream = client()->testMethodServerStream(request);
QSignalSpy streamFinishedSpy(stream.get(), &QGrpcServerStream::finished);
QVERIFY(streamFinishedSpy.isValid());
@ -157,7 +157,7 @@ void QtGrpcClientServerStreamTest::hugeBlob()
request.setTestBytes(testFile.readAll());
QByteArray dataHash = QCryptographicHash::hash(request.testBytes(), QCryptographicHash::Sha256);
auto stream = client()->streamTestMethodBlobServerStream(request);
auto stream = client()->testMethodBlobServerStream(request);
QSignalSpy streamFinishedSpy(stream.get(), &QGrpcServerStream::finished);
QVERIFY(streamFinishedSpy.isValid());
@ -238,9 +238,9 @@ void QtGrpcClientServerStreamTest::multipleStreams()
SimpleStringMessage request;
request.setTestFieldString("Stream");
auto stream = client()->streamTestMethodServerStream(request);
auto stream = client()->testMethodServerStream(request);
// Ensure we're not reusing streams
QCOMPARE_NE(stream, client()->streamTestMethodServerStream(request));
QCOMPARE_NE(stream, client()->testMethodServerStream(request));
QSignalSpy streamFinishedSpy(stream.get(), &QGrpcServerStream::finished);
QVERIFY(streamFinishedSpy.isValid());
@ -271,8 +271,8 @@ void QtGrpcClientServerStreamTest::multipleStreamsCancel()
SimpleStringMessage request;
request.setTestFieldString("Stream");
auto stream = client()->streamTestMethodServerStream(request);
auto streamNext = client()->streamTestMethodServerStream(request);
auto stream = client()->testMethodServerStream(request);
auto streamNext = client()->testMethodServerStream(request);
QCOMPARE_NE(stream, streamNext);
@ -294,10 +294,10 @@ void QtGrpcClientServerStreamTest::multipleStreamsCancel()
QCOMPARE(streamNextFinishedSpy.count(), 0);
QCOMPARE(streamNextErrorSpy.count(), 1);
stream = client()->streamTestMethodServerStream(request);
stream = client()->testMethodServerStream(request);
QCOMPARE_NE(stream, streamNext);
streamNext = client()->streamTestMethodServerStream(request);
streamNext = client()->testMethodServerStream(request);
QCOMPARE_NE(stream, streamNext);
@ -332,7 +332,7 @@ void QtGrpcClientServerStreamTest::inThread()
int i = 0;
const std::unique_ptr<QThread> thread(QThread::create([&] {
QEventLoop waiter;
auto stream = client()->streamTestMethodServerStream(request);
auto stream = client()->testMethodServerStream(request);
QObject::connect(stream.get(), &QGrpcServerStream::messageReceived, &waiter,
[&result, &i, &waiter, stream] {
const auto ret = stream->read<SimpleStringMessage>();
@ -364,7 +364,7 @@ void QtGrpcClientServerStreamTest::cancelWhileErrorTimeout()
SimpleStringMessage request;
request.setTestFieldString("Stream");
auto stream = client()->streamTestMethodServerStream(request);
auto stream = client()->testMethodServerStream(request);
QSignalSpy streamFinishedSpy(stream.get(), &QGrpcServerStream::finished);
QVERIFY(streamFinishedSpy.isValid());
@ -405,7 +405,7 @@ void QtGrpcClientServerStreamTest::deadline()
SimpleStringMessage request;
request.setTestFieldString("Stream");
auto stream = client()->streamTestMethodServerStream(request, opt);
auto stream = client()->testMethodServerStream(request, opt);
QSignalSpy streamErrorSpy(stream.get(), &QGrpcServerStream::errorOccurred);
QVERIFY(streamErrorSpy.isValid());
@ -463,7 +463,7 @@ void QtGrpcClientServerStreamTest::interceptor()
SimpleStringMessage result;
SimpleStringMessage request;
auto stream = client()->streamTestMethodServerStream(request);
auto stream = client()->testMethodServerStream(request);
QSignalSpy messageReceivedSpy(stream.get(), &QGrpcServerStream::messageReceived);
QVERIFY(messageReceivedSpy.isValid());
@ -500,7 +500,7 @@ void QtGrpcClientServerStreamTest::cancelledInterceptor()
SimpleStringMessage request;
request.setTestFieldString("Stream");
auto stream = client()->streamTestMethodServerStream(request);
auto stream = client()->testMethodServerStream(request);
QSignalSpy streamFinishedSpy(stream.get(), &QGrpcServerStream::finished);
QVERIFY(streamFinishedSpy.isValid());
@ -546,7 +546,7 @@ void QtGrpcClientServerStreamTest::interceptResponse()
SimpleStringMessage request;
request.setTestFieldString("Stream");
auto stream = client()->streamTestMethodServerStream(request);
auto stream = client()->testMethodServerStream(request);
QSignalSpy streamFinishedSpy(stream.get(), &QGrpcServerStream::finished);
QVERIFY(streamFinishedSpy.isValid());

View File

@ -25,17 +25,17 @@ void Client::testMethod(const qtgrpc::tests::SimpleStringMessage &arg, const QOb
}, Qt::SingleShotConnection);
}
std::shared_ptr<QGrpcServerStream> Client::streamTestMethodServerStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options)
std::shared_ptr<QGrpcServerStream> Client::testMethodServerStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options)
{
return startStream<QGrpcServerStream>("testMethodServerStream"_L1, arg, options);
}
std::shared_ptr<QGrpcClientStream> Client::streamTestMethodClientStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options)
std::shared_ptr<QGrpcClientStream> Client::testMethodClientStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options)
{
return startStream<QGrpcClientStream>("testMethodClientStream"_L1, arg, options);
}
std::shared_ptr<QGrpcBidirStream> Client::streamTestMethodBiStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options)
std::shared_ptr<QGrpcBidirStream> Client::testMethodBiStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options)
{
return startStream<QGrpcBidirStream>("testMethodBiStream"_L1, arg, options);
}

View File

@ -28,11 +28,11 @@ public:
std::shared_ptr<QGrpcCallReply> testMethod(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options = {});
Q_INVOKABLE void testMethod(const qtgrpc::tests::SimpleStringMessage &arg, const QObject *context, const std::function<void(std::shared_ptr<QGrpcCallReply>)> &callback, const QGrpcCallOptions &options = {});
std::shared_ptr<QGrpcServerStream> streamTestMethodServerStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options = {});
std::shared_ptr<QGrpcServerStream> testMethodServerStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options = {});
std::shared_ptr<QGrpcClientStream> streamTestMethodClientStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options = {});
std::shared_ptr<QGrpcClientStream> testMethodClientStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options = {});
std::shared_ptr<QGrpcBidirStream> streamTestMethodBiStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options = {});
std::shared_ptr<QGrpcBidirStream> testMethodBiStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options = {});
};

View File

@ -25,17 +25,17 @@ void Client::testMethod(const qtgrpc::tests::SimpleStringMessage &arg, const QOb
}, Qt::SingleShotConnection);
}
std::shared_ptr<QGrpcServerStream> Client::streamTestMethodServerStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options)
std::shared_ptr<QGrpcServerStream> Client::testMethodServerStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options)
{
return startStream<QGrpcServerStream>("testMethodServerStream"_L1, arg, options);
}
std::shared_ptr<QGrpcClientStream> Client::streamTestMethodClientStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options)
std::shared_ptr<QGrpcClientStream> Client::testMethodClientStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options)
{
return startStream<QGrpcClientStream>("testMethodClientStream"_L1, arg, options);
}
std::shared_ptr<QGrpcBidirStream> Client::streamTestMethodBiStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options)
std::shared_ptr<QGrpcBidirStream> Client::testMethodBiStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options)
{
return startStream<QGrpcBidirStream>("testMethodBiStream"_L1, arg, options);
}

View File

@ -28,11 +28,11 @@ public:
std::shared_ptr<QGrpcCallReply> testMethod(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options = {});
Q_INVOKABLE void testMethod(const qtgrpc::tests::SimpleStringMessage &arg, const QObject *context, const std::function<void(std::shared_ptr<QGrpcCallReply>)> &callback, const QGrpcCallOptions &options = {});
std::shared_ptr<QGrpcServerStream> streamTestMethodServerStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options = {});
std::shared_ptr<QGrpcServerStream> testMethodServerStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options = {});
std::shared_ptr<QGrpcClientStream> streamTestMethodClientStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options = {});
std::shared_ptr<QGrpcClientStream> testMethodClientStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options = {});
std::shared_ptr<QGrpcBidirStream> streamTestMethodBiStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options = {});
std::shared_ptr<QGrpcBidirStream> testMethodBiStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options = {});
};

View File

@ -25,17 +25,17 @@ void Client::testMethod(const qtgrpc::tests::SimpleStringMessage &arg, const QOb
}, Qt::SingleShotConnection);
}
std::shared_ptr<QGrpcServerStream> Client::streamTestMethodServerStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options)
std::shared_ptr<QGrpcServerStream> Client::testMethodServerStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options)
{
return startStream<QGrpcServerStream>("testMethodServerStream"_L1, arg, options);
}
std::shared_ptr<QGrpcClientStream> Client::streamTestMethodClientStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options)
std::shared_ptr<QGrpcClientStream> Client::testMethodClientStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options)
{
return startStream<QGrpcClientStream>("testMethodClientStream"_L1, arg, options);
}
std::shared_ptr<QGrpcBidirStream> Client::streamTestMethodBiStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options)
std::shared_ptr<QGrpcBidirStream> Client::testMethodBiStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options)
{
return startStream<QGrpcBidirStream>("testMethodBiStream"_L1, arg, options);
}

View File

@ -29,11 +29,11 @@ public:
std::shared_ptr<QGrpcCallReply> testMethod(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options = {});
Q_INVOKABLE void testMethod(const qtgrpc::tests::SimpleStringMessage &arg, const QObject *context, const std::function<void(std::shared_ptr<QGrpcCallReply>)> &callback, const QGrpcCallOptions &options = {});
std::shared_ptr<QGrpcServerStream> streamTestMethodServerStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options = {});
std::shared_ptr<QGrpcServerStream> testMethodServerStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options = {});
std::shared_ptr<QGrpcClientStream> streamTestMethodClientStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options = {});
std::shared_ptr<QGrpcClientStream> testMethodClientStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options = {});
std::shared_ptr<QGrpcBidirStream> streamTestMethodBiStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options = {});
std::shared_ptr<QGrpcBidirStream> testMethodBiStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options = {});
};