Skip to content

Commit 5ff6ee2

Browse files
committed
session: remove estimate_replicas_for_query
Remove estimate_replicas_for_query from Session. A user of this function can switch to using get_token_endpoints() from ClusterData directly. It did not make sense for estimate_replicas_for_query() to be in Session, as this is too much low-level function for Session and doesn't fit the abstraction of Session. As a followup, it might make sense to look into whether get_token_endpoints() from ClusterData should get removed as well: ReplicaLocator can be used directly. This change is a part of our effort to stabilize the API and reduce the number of pub functions. Refs #660
1 parent 9a08488 commit 5ff6ee2

File tree

2 files changed

+5
-23
lines changed

2 files changed

+5
-23
lines changed

examples/compare-tokens.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
use anyhow::Result;
22
use scylla::frame::value::ValueList;
3+
use scylla::routing::Token;
34
use scylla::transport::partitioner::{Murmur3Partitioner, Partitioner};
45
use scylla::transport::NodeAddr;
5-
use scylla::{load_balancing, Session, SessionBuilder};
6+
use scylla::{Session, SessionBuilder};
67
use std::env;
78

89
#[tokio::main]
@@ -32,16 +33,11 @@ async fn main() -> Result<()> {
3233
let serialized_pk = (pk,).serialized()?.into_owned();
3334
let t = Murmur3Partitioner::hash(&prepared.compute_partition_key(&serialized_pk)?).value;
3435

35-
let statement_info = load_balancing::RoutingInfo {
36-
token: Some(scylla::routing::Token { value: t }),
37-
keyspace: Some("ks"),
38-
is_confirmed_lwt: false,
39-
..Default::default()
40-
};
4136
println!(
42-
"Estimated replicas for query: {:?}",
37+
"Token endpoints for query: {:?}",
4338
session
44-
.estimate_replicas_for_query(&statement_info)
39+
.get_cluster_data()
40+
.get_token_endpoints("ks", Token { value: t })
4541
.iter()
4642
.map(|n| n.address)
4743
.collect::<Vec<NodeAddr>>()

scylla/src/transport/session.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,20 +1451,6 @@ impl Session {
14511451
Ok(Some(tracing_info))
14521452
}
14531453

1454-
// Returns which replicas are likely to take part in handling the query.
1455-
// If a list of replicas cannot be easily narrowed down, all available replicas
1456-
// will be returned.
1457-
pub fn estimate_replicas_for_query(&self, statement: &RoutingInfo) -> Vec<Arc<Node>> {
1458-
let cluster_data = self.cluster.get_data();
1459-
match statement.token {
1460-
Some(token) => {
1461-
let cluster_data = self.cluster.get_data();
1462-
cluster_data.get_token_endpoints(statement.keyspace.unwrap_or(""), token)
1463-
}
1464-
None => cluster_data.get_nodes_info().to_owned(),
1465-
}
1466-
}
1467-
14681454
// This method allows to easily run a query using load balancing, retry policy etc.
14691455
// Requires some information about the query and two closures
14701456
// First closure is used to choose a connection

0 commit comments

Comments
 (0)