File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -252,6 +252,10 @@ pub struct SessionConfig {
252
252
/// It is true by default but can be disabled if successive schema-altering statements should be performed.
253
253
pub refresh_metadata_on_auto_schema_agreement : bool ,
254
254
255
+ /// DNS hostname resolution timeout.
256
+ /// If `None`, the driver will wait for hostname resolution indefinitely.
257
+ pub hostname_resolution_timeout : Option < Duration > ,
258
+
255
259
/// The address translator is used to translate addresses received from ScyllaDB nodes
256
260
/// (either with cluster metadata or with an event) to addresses that can be used to
257
261
/// actually connect to those nodes. This may be needed e.g. when there is NAT
@@ -332,6 +336,7 @@ impl SessionConfig {
332
336
ssl_context : None ,
333
337
authenticator : None ,
334
338
connect_timeout : Duration :: from_secs ( 5 ) ,
339
+ hostname_resolution_timeout : Some ( Duration :: from_secs ( 5 ) ) ,
335
340
connection_pool_size : Default :: default ( ) ,
336
341
disallow_shard_aware_port : false ,
337
342
keyspaces_to_fetch : Vec :: new ( ) ,
Original file line number Diff line number Diff line change @@ -762,6 +762,27 @@ impl<K: SessionBuilderKind> GenericSessionBuilder<K> {
762
762
self
763
763
}
764
764
765
+ /// Changes DNS hostname resolution timeout.
766
+ /// The default is 5 seconds.
767
+ ///
768
+ /// # Example
769
+ /// ```
770
+ /// # use scylla::{Session, SessionBuilder};
771
+ /// # use std::time::Duration;
772
+ /// # async fn example() -> Result<(), Box<dyn std::error::Error>> {
773
+ /// let session: Session = SessionBuilder::new()
774
+ /// .known_node("127.0.0.1:9042")
775
+ /// .hostname_resolution_timeout(Duration::from_secs(10))
776
+ /// .build() // Turns SessionBuilder into Session
777
+ /// .await?;
778
+ /// # Ok(())
779
+ /// # }
780
+ /// ```
781
+ pub fn hostname_resolution_timeout ( mut self , duration : Duration ) -> Self {
782
+ self . config . hostname_resolution_timeout = Some ( duration) ;
783
+ self
784
+ }
785
+
765
786
/// Sets the host filter. The host filter decides whether any connections
766
787
/// should be opened to the node or not. The driver will also avoid
767
788
/// those nodes when re-establishing the control connection.
You can’t perform that action at this time.
0 commit comments