BewareMyPower commented on code in PR #170:
URL: https://github.com/apache/pulsar-client-cpp/pull/170#discussion_r1080755872


##########
lib/ServiceNameResolver.h:
##########
@@ -29,29 +29,33 @@ namespace pulsar {
 class ServiceNameResolver {
    public:
     ServiceNameResolver(const std::string& uriString)
-        : serviceUri_(uriString), 
numAddresses_(serviceUri_.getServiceHosts().size()) {
+        : serviceUri_(std::make_shared<ServiceURI>(uriString)),
+          numAddresses_(serviceUri_->getServiceHosts().size()) {
         assert(numAddresses_ > 0);  // the validation has been done in 
ServiceURI
     }
 
     ServiceNameResolver(const ServiceNameResolver&) = delete;
     ServiceNameResolver& operator=(const ServiceNameResolver&) = delete;
 
     bool useTls() const noexcept {
-        return serviceUri_.getScheme() == PulsarScheme::PULSAR_SSL ||
-               serviceUri_.getScheme() == PulsarScheme::HTTPS;
+        return serviceUri_->getScheme() == PulsarScheme::PULSAR_SSL ||
+               serviceUri_->getScheme() == PulsarScheme::HTTPS;
     }
 
     bool useHttp() const noexcept {
-        return serviceUri_.getScheme() == PulsarScheme::HTTP ||
-               serviceUri_.getScheme() == PulsarScheme::HTTPS;
+        return serviceUri_->getScheme() == PulsarScheme::HTTP ||
+               serviceUri_->getScheme() == PulsarScheme::HTTPS;
     }
 
     const std::string& resolveHost() {
-        return serviceUri_.getServiceHosts()[(numAddresses_ == 1) ? 0 : 
(index_++ % numAddresses_)];
+        return serviceUri_->getServiceHosts()[(numAddresses_ == 1) ? 0 : 
(index_++ % numAddresses_)];
     }
 
+    void updateServiceUrl(const std::string& urlString) { 
serviceUri_.reset(new ServiceURI(urlString)); }

Review Comment:
   There is a problem that if the `urlString` contains multiple service URLs, 
we have to update `numAddresses_` as well. A possible solution is moving 
`numAddresses_` into `ServiceURI`.



-- 
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: commits-unsubscr...@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to