Skip to content

Commit

Permalink
config: pass hostname_resolution_timeout to MetadataReader and PoolCo…
Browse files Browse the repository at this point in the history
…nfig

These structs need this context to pass it forward to functions
responsible for DNS lookup.
  • Loading branch information
muzarski committed Dec 11, 2024
1 parent 0cffbee commit ee813e4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions scylla/src/transport/cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ impl Cluster {

let mut metadata_reader = MetadataReader::new(
known_nodes,
pool_config.hostname_resolution_timeout,
control_connection_repair_sender,
pool_config.connection_config.clone(),
pool_config.keepalive_interval,
Expand Down
2 changes: 2 additions & 0 deletions scylla/src/transport/connection_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ pub(crate) struct PoolConfig {
pub(crate) pool_size: PoolSize,
pub(crate) can_use_shard_aware_port: bool,
pub(crate) keepalive_interval: Option<Duration>,
pub(crate) hostname_resolution_timeout: Option<Duration>,
}

impl Default for PoolConfig {
Expand All @@ -69,6 +70,7 @@ impl Default for PoolConfig {
pool_size: Default::default(),
can_use_shard_aware_port: true,
keepalive_interval: None,
hostname_resolution_timeout: None,
}
}
}
Expand Down
1 change: 1 addition & 0 deletions scylla/src/transport/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,7 @@ where
pool_size: config.connection_pool_size,
can_use_shard_aware_port: !config.disallow_shard_aware_port,
keepalive_interval: config.keepalive_interval,
hostname_resolution_timeout: config.hostname_resolution_timeout,
};

let cluster = Cluster::new(
Expand Down
8 changes: 8 additions & 0 deletions scylla/src/transport/topology.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ use super::node::{InternalKnownNode, NodeAddr, ResolvedContactPoint};
pub(crate) struct MetadataReader {
connection_config: ConnectionConfig,
keepalive_interval: Option<Duration>,
hostname_resolution_timeout: Option<Duration>,

control_connection_endpoint: UntranslatedEndpoint,
control_connection: NodeConnectionPool,
Expand Down Expand Up @@ -470,6 +471,7 @@ impl MetadataReader {
#[allow(clippy::too_many_arguments)]
pub(crate) async fn new(
initial_known_nodes: Vec<InternalKnownNode>,
hostname_resolution_timeout: Option<Duration>,
control_connection_repair_requester: broadcast::Sender<()>,
mut connection_config: ConnectionConfig,
keepalive_interval: Option<Duration>,
Expand Down Expand Up @@ -503,13 +505,15 @@ impl MetadataReader {
control_connection_endpoint.clone(),
connection_config.clone(),
keepalive_interval,
hostname_resolution_timeout,
control_connection_repair_requester.clone(),
);

Ok(MetadataReader {
control_connection_endpoint,
control_connection,
keepalive_interval,
hostname_resolution_timeout,
connection_config,
known_peers: initial_peers
.into_iter()
Expand Down Expand Up @@ -630,6 +634,7 @@ impl MetadataReader {
self.control_connection_endpoint.clone(),
self.connection_config.clone(),
self.keepalive_interval,
self.hostname_resolution_timeout,
self.control_connection_repair_requester.clone(),
);

Expand Down Expand Up @@ -730,6 +735,7 @@ impl MetadataReader {
self.control_connection_endpoint.clone(),
self.connection_config.clone(),
self.keepalive_interval,
self.hostname_resolution_timeout,
self.control_connection_repair_requester.clone(),
);
}
Expand All @@ -741,11 +747,13 @@ impl MetadataReader {
endpoint: UntranslatedEndpoint,
connection_config: ConnectionConfig,
keepalive_interval: Option<Duration>,
hostname_resolution_timeout: Option<Duration>,
refresh_requester: broadcast::Sender<()>,
) -> NodeConnectionPool {
let pool_config = PoolConfig {
connection_config,
keepalive_interval,
hostname_resolution_timeout,

// We want to have only one connection to receive events from
pool_size: PoolSize::PerHost(NonZeroUsize::new(1).unwrap()),
Expand Down

0 comments on commit ee813e4

Please sign in to comment.