-
Notifications
You must be signed in to change notification settings - Fork 64
feat: first version of rest catalog #296
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
base: main
Are you sure you want to change the base?
Conversation
| /// initialized directly via aggregate initialization. It provides helper methods to | ||
| /// construct specific endpoint URLs and HTTP headers from the configuration properties. | ||
| struct ICEBERG_REST_EXPORT RestCatalogConfig { | ||
| /// \brief Returns the endpoint string for listing all catalog configuration settings. |
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.
Consider adding timeout and retry configurations to the REST catalog to handle transient network or service issues
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.
Yes that's a good point. I think Iceberg spec (at least the Java impl) has defined some properties to address this as my comment above.
| const cpr::Header& request_headers, | ||
| Func&& perform_request); | ||
|
|
||
| cpr::Header default_headers; |
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.
Follow the code style in this repo and use '_' as private member's suffix.
| return r; | ||
| } | ||
| constexpr std::string_view kMimeTypeApplicationJson = "application/json"; | ||
| constexpr std::string_view kClientVersion = "0.14.1"; |
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.
What is this?
| #include <memory> | ||
| #include <string> | ||
|
|
||
| #include <cpr/cpr.h> |
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.
We cannot include any cpr header to an installed header file.
| /// | ||
| /// \param config the configuration for the RestCatalog | ||
| /// \return a RestCatalog instance | ||
| static Result<RestCatalog> Make(RestCatalogConfig 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.
| static Result<RestCatalog> Make(RestCatalogConfig config); | |
| static Result<std::unique_ptr<RestCatalog>> Make(const RestCatalogConfig& config); |
| /// \return a RestCatalog instance | ||
| static Result<RestCatalog> Make(RestCatalogConfig config); | ||
|
|
||
| /// \brief Return the name for this catalog |
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 is a common practice that override functions do not need to write any comment unless the behavior has changed or attention should be paid.
| RestCatalog(std::shared_ptr<RestCatalogConfig> config, | ||
| std::unique_ptr<HttpClient> client); | ||
|
|
||
| std::shared_ptr<RestCatalogConfig> 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.
What is the reason that config is shared but client is unique? Shouldn't both be unique?
| /// any custom headers prefixed with "header." in the properties. | ||
| /// \return A Result containing cpr::Header object, or an error if names/values are | ||
| /// invalid. | ||
| Result<cpr::Header> GetExtraHeaders() const; |
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.
We cannot expose cpr symbols in the public api.
| Result<cpr::Header> RestCatalogConfig::GetExtraHeaders() const { | ||
| cpr::Header headers; | ||
|
|
||
| headers[std::string(kHeaderContentType)] = std::string(kMimeTypeApplicationJson); |
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.
If the major usage of these magics are as string types, we should better define them as strings.
| } | ||
|
|
||
| std::string RestCatalogConfig::GetNamespacesEndpoint() const { | ||
| return std::format("{}/{}/namespaces", TrimTrailingSlash(uri), kPathV1); |
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.
This is not correct. prefix should be considered though in most cases it is an empty string.
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.
For example, the Java code is as below:
public String namespaces() {
return SLASH.join("v1", prefix, "namespaces");
}
| while (true) { | ||
| cpr::Parameters params; | ||
| if (!ns.levels.empty()) { | ||
| params.Add({"parent", EncodeNamespaceForUrl(ns)}); |
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.
Define these magic strings as constants.
| /// is returned unchanged. | ||
| /// \param uri_sv The URI string view to trim. | ||
| /// \return The (possibly) trimmed URI string view. | ||
| inline std::string_view TrimTrailingSlash(std::string_view uri_sv) { |
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.
What about renaming the file to endpoint_util.h?
No description provided.