lishuxu commented on code in PR #544:
URL: https://github.com/apache/iceberg-cpp/pull/544#discussion_r2757135866
##########
src/iceberg/catalog/rest/rest_catalog.cc:
##########
@@ -139,27 +159,43 @@ Result<std::shared_ptr<RestCatalog>> RestCatalog::Make(
paths, ResourcePaths::Make(std::string(TrimTrailingSlash(final_uri)),
final_config->Get(RestCatalogProperties::kPrefix)));
- return std::shared_ptr<RestCatalog>(
- new RestCatalog(std::move(final_config), std::move(file_io),
std::move(paths),
- std::move(endpoints)));
+ auto client = std::make_unique<HttpClient>(final_config->ExtractHeaders());
+ ICEBERG_ASSIGN_OR_RAISE(auto catalog_session,
+ auth_manager->CatalogSession(*client,
final_config->configs()));
+ return std::shared_ptr<RestCatalog>(new RestCatalog(
+ std::move(final_config), std::move(file_io), std::move(client),
std::move(paths),
+ std::move(endpoints), std::move(auth_manager),
std::move(catalog_session)));
}
RestCatalog::RestCatalog(std::unique_ptr<RestCatalogProperties> config,
std::shared_ptr<FileIO> file_io,
+ std::unique_ptr<HttpClient> client,
std::unique_ptr<ResourcePaths> paths,
- std::unordered_set<Endpoint> endpoints)
+ std::unordered_set<Endpoint> endpoints,
+ std::unique_ptr<auth::AuthManager> auth_manager,
+ std::shared_ptr<auth::AuthSession> catalog_session)
: config_(std::move(config)),
file_io_(std::move(file_io)),
- client_(std::make_unique<HttpClient>(config_->ExtractHeaders())),
+ client_(std::move(client)),
paths_(std::move(paths)),
name_(config_->Get(RestCatalogProperties::kName)),
- supported_endpoints_(std::move(endpoints)) {}
+ supported_endpoints_(std::move(endpoints)),
+ auth_manager_(std::move(auth_manager)),
+ catalog_session_(std::move(catalog_session)) {}
std::string_view RestCatalog::name() const { return name_; }
+Result<std::unordered_map<std::string, std::string>>
RestCatalog::AuthHeaders() const {
Review Comment:
The current design keeps HttpClient focused on HTTP transport concerns,
while RestCatalog handles authentication as a business-layer responsibility. So
I think current design may be better.
--
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]