BewareMyPower commented on code in PR #157:
URL: https://github.com/apache/pulsar-client-cpp/pull/157#discussion_r1065720801
##########
lib/ClientConnection.cc:
##########
@@ -1308,6 +1308,52 @@ void
ClientConnection::handleIncomingCommand(BaseCommand& incomingCmd) {
break;
}
+ case BaseCommand::GET_SCHEMA_RESPONSE: {
+ const auto& response = incomingCmd.getschemaresponse();
+ LOG_DEBUG(cnxString_ << "Received GetSchemaResponse from
server. req_id: "
+ << response.request_id());
+ Lock lock(mutex_);
+ PendingGetSchemaMap::iterator it =
pendingGetSchemaRequests_.find(response.request_id());
+ if (it != pendingGetSchemaRequests_.end()) {
+ Promise<Result, boost::optional<SchemaInfo>>
getSchemaPromise = it->second;
+ pendingGetSchemaRequests_.erase(it);
+ lock.unlock();
+
+ if (response.has_error_code()) {
+ if (response.error_code() == proto::TopicNotFound)
{
+ getSchemaPromise.setValue(boost::none);
+ } else {
+ Result result =
getResult(response.error_code(), response.error_message());
+ LOG_WARN(cnxString_ << "Received error
GetSchemaResponse from server "
+ << result
+ <<
(response.has_error_message()
+ ? (" (" +
response.error_message() + ")")
+ : "")
+ << " -- req_id: " <<
response.request_id());
+ getSchemaPromise.setFailed(result);
+ }
+ return;
+ }
+
+ auto schema = response.schema();
+ auto properMap = schema.properties();
Review Comment:
```suggestion
const auto& schema = response.schema();
const auto& properMap = schema.properties();
```
Avoid unnecessary copy.
##########
lib/ClientConnection.cc:
##########
@@ -1308,6 +1308,52 @@ void
ClientConnection::handleIncomingCommand(BaseCommand& incomingCmd) {
break;
}
+ case BaseCommand::GET_SCHEMA_RESPONSE: {
+ const auto& response = incomingCmd.getschemaresponse();
+ LOG_DEBUG(cnxString_ << "Received GetSchemaResponse from
server. req_id: "
+ << response.request_id());
+ Lock lock(mutex_);
+ PendingGetSchemaMap::iterator it =
pendingGetSchemaRequests_.find(response.request_id());
Review Comment:
```suggestion
auto it =
pendingGetSchemaRequests_.find(response.request_id());
```
##########
lib/LookupService.h:
##########
@@ -21,6 +21,7 @@
#include <pulsar/Result.h>
+#include <boost/optional.hpp>
#include <memory>
Review Comment:
It's better to include `<pulsar/Schema.h>` here though it does not affect
the compilation because the `.cc` files that includes `LookupService.h` already
include `Schema.h`. But for this single file, it might make some static code
analysis checks fail.

--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]