zhaohaidao commented on code in PR #132:
URL: https://github.com/apache/fluss-rust/pull/132#discussion_r2678764320


##########
crates/fluss/src/client/metadata.rs:
##########
@@ -135,7 +135,101 @@ impl Metadata {
         guard.clone()
     }
 
-    pub fn leader_for(&self, _table_bucket: &TableBucket) -> 
Option<&ServerNode> {
-        todo!()
+    pub fn leader_for(&self, table_bucket: &TableBucket) -> Option<ServerNode> 
{
+        let cluster = self.cluster.read();
+        cluster.leader_for(table_bucket).cloned()
+    }
+}
+
+#[cfg(test)]
+impl Metadata {
+    pub(crate) fn new_for_test(cluster: Arc<Cluster>) -> Self {
+        Metadata {
+            cluster: RwLock::new(cluster),
+            connections: Arc::new(RpcClient::new()),
+            bootstrap: Arc::from(""),
+        }
+    }
+}
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+    use crate::cluster::{BucketLocation, Cluster, ServerNode, ServerType};
+    use crate::metadata::{DataField, DataTypes, Schema, TableDescriptor, 
TableInfo, TablePath};
+    use std::collections::HashMap;
+
+    fn build_table_info(table_path: TablePath, table_id: i64) -> TableInfo {

Review Comment:
   make sense. done



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

Reply via email to