Skip to content

Conversation

@HeartLinked
Copy link
Contributor

No description provided.

/// 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.
Copy link
Contributor

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

Copy link
Member

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;
Copy link
Contributor

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";
Copy link
Member

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>
Copy link
Member

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Member

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_;
Copy link
Member

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;
Copy link
Member

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);
Copy link
Member

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);
Copy link
Member

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.

Copy link
Member

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)});
Copy link
Member

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) {
Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants