Skip to content

Commit c46cbd2

Browse files
committed
state: introduce new getters for keyspace info
Thanks to that, we will be able to remove the getter that returns a HashMap<String, Keyspace>. Because of that, we will be able to change the underlying structure of how we store keyspace info in the future. One idea is to potentially wrap `Keyspace` struct in an `Arc`, so we may possibly share the keyspace info in multiple places.
1 parent 2935f48 commit c46cbd2

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

scylla/src/cluster/state.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,16 @@ impl ClusterState {
192192
&self.keyspaces
193193
}
194194

195+
/// Access keyspace details collected by the driver.
196+
pub fn get_keyspace(&self, keyspace: impl AsRef<str>) -> Option<&Keyspace> {
197+
self.keyspaces.get(keyspace.as_ref())
198+
}
199+
200+
/// Returns an iterator over keyspaces.
201+
pub fn keyspaces_iter(&self) -> impl Iterator<Item = (&str, &Keyspace)> {
202+
self.keyspaces.iter().map(|(k, v)| (k.as_str(), v))
203+
}
204+
195205
/// Access details about nodes known to the driver
196206
pub fn get_nodes_info(&self) -> &[Arc<Node>] {
197207
self.locator.unique_nodes_in_global_ring()

0 commit comments

Comments
 (0)