Skip to content

Commit a82e217

Browse files
wyfopsarna
authored andcommitted
connection_pool/node: expose node sharder
Make connection_pool sharder accessible in node
1 parent 7243c6d commit a82e217

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

scylla/src/transport/connection_pool.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,14 @@ impl NodeConnectionPool {
200200
}
201201
}
202202

203+
pub fn sharder(&self) -> Option<Sharder> {
204+
self.with_connections(|pool_conns| match pool_conns {
205+
PoolConnections::NotSharded(_) => None,
206+
PoolConnections::Sharded { sharder, .. } => Some(sharder.clone()),
207+
})
208+
.unwrap_or(None)
209+
}
210+
203211
pub fn connection_for_token(&self, token: Token) -> Result<Arc<Connection>, QueryError> {
204212
trace!(token = token.value, "Selecting connection for token");
205213
self.with_connections(|pool_conns| match pool_conns {

scylla/src/transport/node.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/// Node represents a cluster node along with it's data and connections
2-
use crate::routing::Token;
2+
use crate::routing::{Sharder, Token};
33
use crate::transport::connection::Connection;
44
use crate::transport::connection::VerifiedKeyspaceName;
55
use crate::transport::connection_pool::{NodeConnectionPool, PoolConfig};
@@ -53,6 +53,10 @@ impl Node {
5353
}
5454
}
5555

56+
pub fn sharder(&self) -> Option<Sharder> {
57+
self.pool.sharder()
58+
}
59+
5660
/// Get connection which should be used to connect using given token
5761
/// If this connection is broken get any random connection to this Node
5862
pub(crate) async fn connection_for_token(

0 commit comments

Comments
 (0)