Skip to content

Commit c8d1a3c

Browse files
committed
conn_pool: unpub ConnectionPool, Pool[Refiller|Config]
All these structs are only intended for internal usage, for connection pooling in Session. All weren't accessible from outside (connection_pool module wasn't `pub`, and they weren't publicly reexported anywhere), so no breaking change incurred.
1 parent 677210f commit c8d1a3c

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

scylla/src/transport/connection_pool.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ impl Default for PoolSize {
5454
}
5555

5656
#[derive(Clone)]
57-
pub struct PoolConfig {
58-
pub connection_config: ConnectionConfig,
59-
pub pool_size: PoolSize,
60-
pub can_use_shard_aware_port: bool,
61-
pub keepalive_interval: Option<Duration>,
57+
pub(crate) struct PoolConfig {
58+
pub(crate) connection_config: ConnectionConfig,
59+
pub(crate) pool_size: PoolSize,
60+
pub(crate) can_use_shard_aware_port: bool,
61+
pub(crate) keepalive_interval: Option<Duration>,
6262
}
6363

6464
impl Default for PoolConfig {
@@ -148,7 +148,7 @@ impl std::fmt::Debug for PoolConnections {
148148
}
149149

150150
#[derive(Clone)]
151-
pub struct NodeConnectionPool {
151+
pub(crate) struct NodeConnectionPool {
152152
conns: Arc<ArcSwap<MaybePoolConnections>>,
153153
use_keyspace_request_sender: mpsc::Sender<UseKeyspaceRequest>,
154154
_refiller_handle: Arc<RemoteHandle<()>>,
@@ -165,7 +165,7 @@ impl std::fmt::Debug for NodeConnectionPool {
165165
}
166166

167167
impl NodeConnectionPool {
168-
pub fn new(
168+
pub(crate) fn new(
169169
endpoint: UntranslatedEndpoint,
170170
#[allow(unused_mut)] mut pool_config: PoolConfig, // `mut` needed only with "cloud" feature
171171
current_keyspace: Option<VerifiedKeyspaceName>,
@@ -224,15 +224,15 @@ impl NodeConnectionPool {
224224
*self.endpoint.write().unwrap() = UntranslatedEndpoint::Peer(new_endpoint);
225225
}
226226

227-
pub fn sharder(&self) -> Option<Sharder> {
227+
pub(crate) fn sharder(&self) -> Option<Sharder> {
228228
self.with_connections(|pool_conns| match pool_conns {
229229
PoolConnections::NotSharded(_) => None,
230230
PoolConnections::Sharded { sharder, .. } => Some(sharder.clone()),
231231
})
232232
.unwrap_or(None)
233233
}
234234

235-
pub fn connection_for_token(&self, token: Token) -> Result<Arc<Connection>, QueryError> {
235+
pub(crate) fn connection_for_token(&self, token: Token) -> Result<Arc<Connection>, QueryError> {
236236
trace!(token = token.value, "Selecting connection for token");
237237
self.with_connections(|pool_conns| match pool_conns {
238238
PoolConnections::NotSharded(conns) => {
@@ -252,7 +252,7 @@ impl NodeConnectionPool {
252252
})
253253
}
254254

255-
pub fn random_connection(&self) -> Result<Arc<Connection>, QueryError> {
255+
pub(crate) fn random_connection(&self) -> Result<Arc<Connection>, QueryError> {
256256
trace!("Selecting random connection");
257257
self.with_connections(|pool_conns| match pool_conns {
258258
PoolConnections::NotSharded(conns) => {
@@ -304,7 +304,7 @@ impl NodeConnectionPool {
304304
unreachable!("could not find any connection in supposedly non-empty pool")
305305
}
306306

307-
pub async fn use_keyspace(
307+
pub(crate) async fn use_keyspace(
308308
&self,
309309
keyspace_name: VerifiedKeyspaceName,
310310
) -> Result<(), QueryError> {
@@ -325,7 +325,7 @@ impl NodeConnectionPool {
325325
// Waits until the pool becomes initialized.
326326
// The pool is considered initialized either if the first connection has been
327327
// established or after first filling ends, whichever comes first.
328-
pub async fn wait_until_initialized(&self) {
328+
pub(crate) async fn wait_until_initialized(&self) {
329329
// First, register for the notification
330330
// so that we don't miss it
331331
let notified = self.pool_updated_notify.notified();
@@ -336,7 +336,7 @@ impl NodeConnectionPool {
336336
}
337337
}
338338

339-
pub fn get_working_connections(&self) -> Result<Vec<Arc<Connection>>, QueryError> {
339+
pub(crate) fn get_working_connections(&self) -> Result<Vec<Arc<Connection>>, QueryError> {
340340
self.with_connections(|pool_conns| match pool_conns {
341341
PoolConnections::NotSharded(conns) => conns.clone(),
342342
PoolConnections::Sharded { connections, .. } => {
@@ -481,7 +481,7 @@ struct UseKeyspaceRequest {
481481
}
482482

483483
impl PoolRefiller {
484-
pub fn new(
484+
pub(crate) fn new(
485485
endpoint: Arc<RwLock<UntranslatedEndpoint>>,
486486
pool_config: PoolConfig,
487487
current_keyspace: Option<VerifiedKeyspaceName>,
@@ -520,12 +520,12 @@ impl PoolRefiller {
520520
self.endpoint.read().unwrap().address()
521521
}
522522

523-
pub fn get_shared_connections(&self) -> Arc<ArcSwap<MaybePoolConnections>> {
523+
pub(crate) fn get_shared_connections(&self) -> Arc<ArcSwap<MaybePoolConnections>> {
524524
self.shared_conns.clone()
525525
}
526526

527527
// The main loop of the pool refiller
528-
pub async fn run(
528+
pub(crate) async fn run(
529529
mut self,
530530
mut use_keyspace_request_receiver: mpsc::Receiver<UseKeyspaceRequest>,
531531
) {

0 commit comments

Comments
 (0)