kevinjqliu commented on code in PR #2692:
URL: https://github.com/apache/iceberg-rust/pull/2692#discussion_r3530365187


##########
crates/catalog/rest/src/catalog.rs:
##########
@@ -412,14 +417,42 @@ impl RestCatalog {
             .get_or_try_init(|| async {
                 let client = HttpClient::new(&self.user_config)?;
                 let catalog_config = RestCatalog::load_config(&client, 
&self.user_config).await?;
+                // The `endpoints` field is optional. A non-empty advertised 
list
+                // is used as-is; an absent field or an empty list falls back 
to
+                // the standard base set every server is expected to support.

Review Comment:
   nit: these comments feels a bit confusing. endpoints is return as is from 
the rest response, otherwise when its empty use the `DEFAULT_ENDPOINTS`



##########
crates/catalog/rest/src/catalog.rs:
##########
@@ -347,6 +348,10 @@ struct RestContext {
     ///
     /// It's could be different from the user config.
     config: RestCatalogConfig,
+    /// The negotiated set of endpoints used for capability negotiation: the
+    /// server's advertised list, or the default base set when its
+    /// `GET /v1/config` response omits `endpoints` or sends an empty list.

Review Comment:
   nit: from the `RestContext` these are just capabilities the rest endpoint 
advertises (the rest is implementation detail)



##########
crates/catalog/rest/src/catalog.rs:
##########
@@ -412,14 +417,42 @@ impl RestCatalog {
             .get_or_try_init(|| async {
                 let client = HttpClient::new(&self.user_config)?;
                 let catalog_config = RestCatalog::load_config(&client, 
&self.user_config).await?;
+                // The `endpoints` field is optional. A non-empty advertised 
list
+                // is used as-is; an absent field or an empty list falls back 
to
+                // the standard base set every server is expected to support.
+                let endpoints = match &catalog_config.endpoints {
+                    Some(advertised) if !advertised.is_empty() => {
+                        advertised.iter().cloned().collect()
+                    }
+                    _ => crate::endpoint::DEFAULT_ENDPOINTS.clone(),
+                };
                 let config = 
self.user_config.clone().merge_with_config(catalog_config);
                 let client = client.update_with(&config)?;
 
-                Ok(RestContext { config, client })
+                Ok(RestContext {
+                    config,
+                    client,
+                    endpoints,
+                })
             })
             .await
     }
 
+    /// Returns whether the connected server supports `endpoint`.
+    ///
+    /// Servers advertise the routes they support in the `endpoints` field of
+    /// the `GET /v1/config` response. A non-empty advertised list is used 
as-is.
+    /// An absent field or an empty list falls back to a standard base set of
+    /// namespace and table operations, so a server that predates the field 
still
+    /// resolves its core operations as supported; any optional endpoint 
outside
+    /// that base set is reported unsupported unless it is explicitly 
advertised.
+    ///
+    /// The server config is fetched once and cached, so the first call may
+    /// incur a round-trip to `GET /v1/config`.

Review Comment:
   nit: can we be more concise with these explanations? 
   i dont think we need to explain the whole protocol here



##########
crates/catalog/rest/src/catalog.rs:
##########
@@ -347,6 +348,10 @@ struct RestContext {
     ///
     /// It's could be different from the user config.
     config: RestCatalogConfig,
+    /// The negotiated set of endpoints used for capability negotiation: the
+    /// server's advertised list, or the default base set when its
+    /// `GET /v1/config` response omits `endpoints` or sends an empty list.
+    endpoints: HashSet<Endpoint>,

Review Comment:
   and it seems like a lot of endpoint related functions are in there 
   
   
https://github.com/apache/iceberg-rust/blob/22e80a63dbb4e58e034672b4ff665a6eae82fa02/crates/catalog/rest/src/catalog.rs#L168-L341



##########
crates/catalog/rest/src/catalog.rs:
##########
@@ -347,6 +348,10 @@ struct RestContext {
     ///
     /// It's could be different from the user config.
     config: RestCatalogConfig,
+    /// The negotiated set of endpoints used for capability negotiation: the
+    /// server's advertised list, or the default base set when its
+    /// `GET /v1/config` response omits `endpoints` or sends an empty list.
+    endpoints: HashSet<Endpoint>,

Review Comment:
   is it better to store `endpoints` inside of `RestCatalogConfig`? The comment 
leads me to believe it might be a good place
   ```
       /// Runtime config is fetched from rest server and stored here.
       ///
       /// It's could be different from the user config.
   ```



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