diff --git a/crates/curp/proto/common b/crates/curp/proto/common index cc746b8fd..0ac729f32 160000 --- a/crates/curp/proto/common +++ b/crates/curp/proto/common @@ -1 +1 @@ -Subproject commit cc746b8fd240aae3e0a9ead62250b08ec2e6d66f +Subproject commit 0ac729f32fa0b5bee8e6b6d6e65bedcb9a7d05ae diff --git a/crates/curp/src/members.rs b/crates/curp/src/members.rs index b3f9a0a1f..f25c16a35 100644 --- a/crates/curp/src/members.rs +++ b/crates/curp/src/members.rs @@ -29,13 +29,14 @@ impl Member { pub fn new( id: ServerId, name: impl Into, - addrs: impl Into>, + peer_urls: impl Into>, is_learner: bool, ) -> Self { Self { id, name: name.into(), - addrs: addrs.into(), + peer_urls: peer_urls.into(), + client_urls: vec![], // TODO is_learner, } } @@ -57,8 +58,8 @@ impl Member { /// Get member addresses #[must_use] #[inline] - pub fn addrs(&self) -> &[String] { - self.addrs.as_slice() + pub fn peer_urls(&self) -> &[String] { + self.peer_urls.as_slice() } /// Is learner or not @@ -140,7 +141,7 @@ impl ClusterInfo { .members .into_iter() .map(|mut member| { - if member.addrs() == self_addr { + if member.peer_urls() == self_addr { member_id = member.id; member.name = self_name.to_owned(); } @@ -202,7 +203,7 @@ impl ClusterInfo { .members .get_mut(id) .unwrap_or_else(|| unreachable!("member {} not found", id)); - std::mem::swap(&mut addrs, &mut member.addrs); + std::mem::swap(&mut addrs, &mut member.peer_urls); addrs } @@ -210,7 +211,7 @@ impl ClusterInfo { #[must_use] #[inline] pub fn addrs(&self, id: ServerId) -> Option> { - self.members.get(&id).map(|t| t.addrs.clone()) + self.members.get(&id).map(|t| t.peer_urls.clone()) } /// Get the current member @@ -227,7 +228,7 @@ impl ClusterInfo { #[must_use] #[inline] pub fn self_addrs(&self) -> Vec { - self.self_member().addrs.clone() + self.self_member().peer_urls.clone() } /// Get the current server id @@ -329,7 +330,7 @@ impl ClusterInfo { self.members .iter() .filter(|t| t.id != self.member_id) - .map(|t| (t.id, t.addrs.clone())) + .map(|t| (t.id, t.peer_urls.clone())) .collect() } @@ -339,7 +340,7 @@ impl ClusterInfo { pub fn all_members_addrs(&self) -> HashMap> { self.members .iter() - .map(|t| (t.id, t.addrs.clone())) + .map(|t| (t.id, t.peer_urls.clone())) .collect() } diff --git a/crates/curp/src/rpc/mod.rs b/crates/curp/src/rpc/mod.rs index d3cacab7e..7c5e5b000 100644 --- a/crates/curp/src/rpc/mod.rs +++ b/crates/curp/src/rpc/mod.rs @@ -122,7 +122,7 @@ impl FetchClusterResponse { pub(crate) fn into_members_addrs(self) -> HashMap> { self.members .into_iter() - .map(|member| (member.id, member.addrs)) + .map(|member| (member.id, member.peer_urls)) // TODO .collect() } } diff --git a/crates/curp/src/server/raw_curp/mod.rs b/crates/curp/src/server/raw_curp/mod.rs index 193a3acc2..d141dad66 100644 --- a/crates/curp/src/server/raw_curp/mod.rs +++ b/crates/curp/src/server/raw_curp/mod.rs @@ -1812,7 +1812,7 @@ impl RawCurp { ( true, ( - removed_member.addrs, + removed_member.peer_urls, removed_member.name, removed_member.is_learner, ), diff --git a/crates/curp/tests/it/common/curp_group.rs b/crates/curp/tests/it/common/curp_group.rs index e3b14c434..4c57d2fb1 100644 --- a/crates/curp/tests/it/common/curp_group.rs +++ b/crates/curp/tests/it/common/curp_group.rs @@ -444,7 +444,7 @@ impl CurpGroup { let members = cluster_res_base .members .into_iter() - .map(|m| Member::new(m.id, m.name, m.addrs, m.is_learner)) + .map(|m| Member::new(m.id, m.name, m.peer_urls, m.is_learner)) .collect(); let cluster_res = curp::rpc::FetchClusterResponse { leader_id: cluster_res_base.leader_id, diff --git a/crates/curp/tests/it/server.rs b/crates/curp/tests/it/server.rs index 779d82991..8211df7f9 100644 --- a/crates/curp/tests/it/server.rs +++ b/crates/curp/tests/it/server.rs @@ -393,7 +393,7 @@ async fn propose_update_node_should_success() { let members = client.propose_conf_change(changes).await.unwrap(); assert_eq!(members.len(), 5); let member = members.iter().find(|m| m.id == node_id); - assert!(member.is_some_and(|m| m.addrs == ["new_addr"])); + assert!(member.is_some_and(|m| m.peer_urls == ["new_addr"])); } #[tokio::test(flavor = "multi_thread")] @@ -439,7 +439,7 @@ async fn propose_conf_change_to_follower() { let members = client.propose_conf_change(changes).await.unwrap(); assert_eq!(members.len(), 5); let member = members.iter().find(|m| m.id == node_id); - assert!(member.is_some_and(|m| m.addrs == ["new_addr"])); + assert!(member.is_some_and(|m| m.peer_urls == ["new_addr"])); } async fn check_new_node(is_learner: bool) { diff --git a/crates/xline/src/server/cluster_server.rs b/crates/xline/src/server/cluster_server.rs index fb445326b..efe9bf92f 100644 --- a/crates/xline/src/server/cluster_server.rs +++ b/crates/xline/src/server/cluster_server.rs @@ -40,11 +40,11 @@ impl ClusterServer { .await? .into_iter() .map(|member| Member { - id: member.id(), - name: member.name().to_owned(), - peer_ur_ls: member.addrs().to_vec(), - client_ur_ls: member.addrs().to_vec(), - is_learner: member.is_learner(), + id: member.id, + name: member.name.clone(), + peer_ur_ls: member.peer_urls.clone(), + client_ur_ls: member.client_urls.clone(), + is_learner: member.is_learner, }) .collect()) } @@ -132,8 +132,8 @@ impl Cluster for ClusterServer { .map(|member| Member { id: member.id, name: member.name, - peer_ur_ls: member.addrs.clone(), - client_ur_ls: member.addrs, + peer_ur_ls: member.peer_urls, + client_ur_ls: member.client_urls, is_learner: member.is_learner, }) .collect(),