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


##########
lib/ClientImpl.cc:
##########
@@ -854,4 +873,42 @@ std::chrono::nanoseconds 
ClientImpl::getOperationTimeout(const ClientConfigurati
     return clientConfiguration.impl_->operationTimeout;
 }
 
+void ClientImpl::updateServiceInfo(ServiceInfo&& serviceInfo) {
+    std::unique_lock lock(mutex_);
+    if (state_ != Open) {
+        LOG_ERROR("Client is not open, cannot update connection info");
+        return;
+    }
+
+    if (serviceInfo.authentication.has_value() && *serviceInfo.authentication) 
{
+        clientConfiguration_.setAuth(*serviceInfo.authentication);
+    } else {
+        clientConfiguration_.setAuth(AuthFactory::Disabled());
+    }
+    if (serviceInfo.tlsTrustCertsFilePath.has_value()) {
+        
clientConfiguration_.setTlsTrustCertsFilePath(*serviceInfo.tlsTrustCertsFilePath);
+    } else {
+        clientConfiguration_.setTlsTrustCertsFilePath("");
+    }
+    
clientConfiguration_.setUseTls(ServiceNameResolver::useTls(ServiceURI(serviceInfo.serviceUrl)));
+    serviceInfo_ = {serviceInfo.serviceUrl, 
toOptionalAuthentication(clientConfiguration_.getAuthPtr()),
+                    clientConfiguration_.getTlsTrustCertsFilePath().empty()
+                        ? std::nullopt
+                        : 
std::make_optional(clientConfiguration_.getTlsTrustCertsFilePath())};
+
+    pool_.resetForClusterSwitching(clientConfiguration_.getAuthPtr(), 
clientConfiguration_);
+
+    lookupServicePtr_->close();
+    for (auto&& it : redirectedClusterLookupServicePtrs_) {
+        it.second->close();
+    }
+    redirectedClusterLookupServicePtrs_.clear();
+    lookupServicePtr_ = createLookup(serviceInfo.serviceUrl);
+}

Review Comment:
   Now these fields are all protected by the ClientConfigurationImpl::mutex.



-- 
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]

Reply via email to