Skip to content

Commit 14ff415

Browse files
committed
ClusterData: remove get_datacenters_info()
This method seems to have very limited usability: - For iterating through datacenter names user can call `ReplicaLocator::datacenter_names, which is constant time. - Nothing else was available to the user because `Datacenter` struct is not exported (so is unnameable). This also means all the work done by this method was a waste. - For more advanced tasks there are `ReplicaLocator::unique_nodes_in_datacenter_ring` and `ClusterData::get_nodes_info`. I don't think it is worth it to have this method which allocates a lot on each call and calculates rack counts. It could make sense to have rack counts precalculated when creating `ClusterData` - I'll think about it during metadata refactor. I'm pretty sure that the original intention was to calculate this whole hash map in `ClusterData::new`, but for some reason the calculation there was thrown out and redone here. I don't think its worth it repair this API now considering it was basically unavailable to users.`
1 parent 7f7f2d0 commit 14ff415

File tree

1 file changed

+0
-19
lines changed

1 file changed

+0
-19
lines changed

scylla/src/transport/cluster.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -381,25 +381,6 @@ impl ClusterData {
381381
&self.keyspaces
382382
}
383383

384-
/// Access datacenter details collected by the driver
385-
/// Returned `HashMap` is indexed by names of datacenters
386-
pub fn get_datacenters_info(&self) -> HashMap<String, Datacenter> {
387-
self.locator
388-
.datacenter_names()
389-
.iter()
390-
.map(|dc_name| {
391-
let nodes = self
392-
.locator
393-
.unique_nodes_in_datacenter_ring(dc_name)
394-
.unwrap()
395-
.to_vec();
396-
let rack_count = nodes.iter().map(|node| node.rack.as_ref()).unique().count();
397-
398-
(dc_name.clone(), Datacenter { nodes, rack_count })
399-
})
400-
.collect()
401-
}
402-
403384
/// Access details about nodes known to the driver
404385
pub fn get_nodes_info(&self) -> &[Arc<Node>] {
405386
self.locator.unique_nodes_in_global_ring()

0 commit comments

Comments
 (0)