-
Notifications
You must be signed in to change notification settings - Fork 113
rest: build resource paths from final config #482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,9 +63,8 @@ std::unordered_set<Endpoint> GetDefaultEndpoints() { | |
| } | ||
|
|
||
| /// \brief Fetch server config and merge it with client config | ||
| Result<CatalogConfig> FetchServerConfig(const ResourcePaths& paths, | ||
| Result<CatalogConfig> FetchServerConfig(const std::string& config_path, | ||
| const RestCatalogProperties& current_config) { | ||
| ICEBERG_ASSIGN_OR_RAISE(auto config_path, paths.Config()); | ||
| HttpClient client(current_config.ExtractHeaders()); | ||
| ICEBERG_ASSIGN_OR_RAISE(const auto response, | ||
| client.Get(config_path, /*params=*/{}, /*headers=*/{}, | ||
|
|
@@ -111,10 +110,9 @@ Result<std::shared_ptr<RestCatalog>> RestCatalog::Make( | |
| if (!file_io) { | ||
| return InvalidArgument("FileIO is required to create RestCatalog"); | ||
| } | ||
| ICEBERG_ASSIGN_OR_RAISE( | ||
| auto paths, ResourcePaths::Make(std::string(TrimTrailingSlash(uri)), | ||
| config.Get(RestCatalogProperties::kPrefix))); | ||
| ICEBERG_ASSIGN_OR_RAISE(auto server_config, FetchServerConfig(*paths, config)); | ||
| ICEBERG_ASSIGN_OR_RAISE(auto config_uri, | ||
| ResourcePaths::Config(std::string(TrimTrailingSlash(uri)))); | ||
| ICEBERG_ASSIGN_OR_RAISE(auto server_config, FetchServerConfig(config_uri, config)); | ||
|
|
||
| std::unique_ptr<RestCatalogProperties> final_config = RestCatalogProperties::FromMap( | ||
| MergeConfigs(server_config.defaults, config.configs(), server_config.overrides)); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for fixing this! Let's not complicate the PR. I think this change can be added without the test.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes, i create a new pull request for it.https://github.com/apache/iceberg-cpp/pull/483/files |
||
|
|
@@ -132,7 +130,9 @@ Result<std::shared_ptr<RestCatalog>> RestCatalog::Make( | |
|
|
||
| // Update resource paths based on the final config | ||
| ICEBERG_ASSIGN_OR_RAISE(auto final_uri, final_config->Uri()); | ||
| ICEBERG_RETURN_UNEXPECTED(paths->SetBaseUri(std::string(TrimTrailingSlash(final_uri)))); | ||
| ICEBERG_ASSIGN_OR_RAISE( | ||
|
wgtmac marked this conversation as resolved.
|
||
| auto 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), | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It sounds good to remove
SetBaseUri. However, it leads to confusion to make this a static function. I'd suggest to revert this function as you have created a new ResourcePaths based on the server config.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's reasonable, i've reverted.