rocketmq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ifplu...@apache.org
Subject [rocketmq-client-cpp] 23/29: refactor: ConsumerRunningInfo::encode
Date Tue, 29 Dec 2020 03:36:40 GMT
This is an automated email from the ASF dual-hosted git repository.

ifplusor pushed a commit to branch re_dev
in repository https://gitbox.apache.org/repos/asf/rocketmq-client-cpp.git

commit 03f31cf37deb0d345fdc6f51e1d4392cd73ea20f
Author: James Yin <ywhjames@hotmail.com>
AuthorDate: Wed Sep 23 17:47:55 2020 +0800

    refactor: ConsumerRunningInfo::encode
---
 src/ClientRemotingProcessor.cpp           |  2 +-
 src/protocol/body/ConsumerRunningInfo.cpp | 15 +++++++--------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/ClientRemotingProcessor.cpp b/src/ClientRemotingProcessor.cpp
index cbc8363..cf97306 100644
--- a/src/ClientRemotingProcessor.cpp
+++ b/src/ClientRemotingProcessor.cpp
@@ -116,7 +116,7 @@ RemotingCommand* ClientRemotingProcessor::resetOffset(RemotingCommand*
request)
 
 RemotingCommand* ClientRemotingProcessor::getConsumerRunningInfo(const std::string& addr,
RemotingCommand* request) {
   auto* requestHeader = request->decodeCommandCustomHeader<GetConsumerRunningInfoRequestHeader>();
-  LOG_INFO("getConsumerRunningInfo, group:{}", requestHeader->getConsumerGroup());
+  LOG_INFO_NEW("getConsumerRunningInfo, group:{}", requestHeader->getConsumerGroup());
 
   std::unique_ptr<RemotingCommand> response(
       new RemotingCommand(MQResponseCode::SYSTEM_ERROR, "not set any response code"));
diff --git a/src/protocol/body/ConsumerRunningInfo.cpp b/src/protocol/body/ConsumerRunningInfo.cpp
index f1ae14f..a14febd 100644
--- a/src/protocol/body/ConsumerRunningInfo.cpp
+++ b/src/protocol/body/ConsumerRunningInfo.cpp
@@ -37,18 +37,17 @@ void ConsumerRunningInfo::setStatusTable(const std::map<std::string,
ConsumeStat
 } */
 
 std::string ConsumerRunningInfo::encode() {
-  Json::Value outData;
+  Json::Value out_data;
 
-  outData[PROP_NAMESERVER_ADDR] = properties_[PROP_NAMESERVER_ADDR];
-  outData[PROP_CONSUME_TYPE] = properties_[PROP_CONSUME_TYPE];
-  outData[PROP_CLIENT_VERSION] = properties_[PROP_CLIENT_VERSION];
-  outData[PROP_CONSUMER_START_TIMESTAMP] = properties_[PROP_CONSUMER_START_TIMESTAMP];
-  outData[PROP_CONSUME_ORDERLY] = properties_[PROP_CONSUME_ORDERLY];
-  outData[PROP_THREADPOOL_CORE_SIZE] = properties_[PROP_THREADPOOL_CORE_SIZE];
+  for (const auto& it : properties_) {
+    const auto& name = it.first;
+    const auto& value = it.second;
+    out_data[name] = value;
+  }
 
   Json::Value root;
   root["jstack"] = jstack_;
-  root["properties"] = outData;
+  root["properties"] = out_data;
 
   for (const auto& subscription : subscription_set_) {
     root["subscriptionSet"].append(subscription.toJson());


Mime
View raw message