smaheshwar-pltr commented on code in PR #1090:
URL: https://github.com/apache/iceberg-cpp/pull/1090#discussion_r4474881159


##########
src/iceberg/catalog/rest/http_client.cc:
##########
@@ -190,6 +199,50 @@ Status HandleFailureResponse(const cpr::Response& response,
 
 }  // namespace
 
+Result<HttpResponse> HttpResponse::Impl::Make(cpr::Response response,
+                                              const ErrorHandler& 
error_handler) {
+  ICEBERG_RETURN_UNEXPECTED(HandleFailureResponse(response, error_handler));
+  HttpResponse http_response;
+  http_response.impl_ = std::make_unique<Impl>(std::move(response));
+  return http_response;
+}
+
+// libcurl does not support using a connection cache from several threads at 
once
+// (CURLSHOPT_SHARE(3)).
+class HttpClient::ConnectionPools {
+ public:
+  template <typename Send>
+  Result<HttpResponse> Run(const Send& send, const ErrorHandler& 
error_handler) {
+    std::unique_ptr<cpr::ConnectionPool> pool = Acquire();
+    // Make() consumes the CPR response, freeing its curl handle before pool 
reuse.
+    Result<HttpResponse> response = HttpResponse::Impl::Make(send(*pool), 
error_handler);
+    Release(std::move(pool));
+    return response;
+  }
+
+ private:
+  std::unique_ptr<cpr::ConnectionPool> Acquire() {

Review Comment:
   This setup made sense to me, wonder if folks have thoughts on this approach?



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to