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 @@ -300,6 +300,10 @@ pub struct SessionConfig {
300
300
/// It is true by default but can be disabled if successive schema-altering statements should be performed.
301
301
pub refresh_metadata_on_auto_schema_agreement : bool ,
302
302
303
+ /// DNS hostname resolution timeout.
304
+ /// If `None`, the driver will wait for hostname resolution indefinitely.
305
+ pub hostname_resolution_timeout : Option < Duration > ,
306
+
303
307
/// The address translator is used to translate addresses received from ScyllaDB nodes
304
308
/// (either with cluster metadata or with an event) to addresses that can be used to
305
309
/// actually connect to those nodes. This may be needed e.g. when there is NAT
@@ -380,6 +384,7 @@ impl SessionConfig {
380
384
ssl_context : None ,
381
385
authenticator : None ,
382
386
connect_timeout : Duration :: from_secs ( 5 ) ,
387
+ hostname_resolution_timeout : Some ( Duration :: from_secs ( 5 ) ) ,
383
388
connection_pool_size : Default :: default ( ) ,
384
389
disallow_shard_aware_port : false ,
385
390
keyspaces_to_fetch : Vec :: new ( ) ,
Original file line number Diff line number Diff line change @@ -806,6 +806,27 @@ impl<K: SessionBuilderKind> GenericSessionBuilder<K> {
806
806
self
807
807
}
808
808
809
+ /// Changes DNS hostname resolution timeout.
810
+ /// The default is 5 seconds.
811
+ ///
812
+ /// # Example
813
+ /// ```
814
+ /// # use scylla::{Session, SessionBuilder};
815
+ /// # use std::time::Duration;
816
+ /// # async fn example() -> Result<(), Box<dyn std::error::Error>> {
817
+ /// let session: Session = SessionBuilder::new()
818
+ /// .known_node("127.0.0.1:9042")
819
+ /// .hostname_resolution_timeout(Duration::from_secs(10))
820
+ /// .build() // Turns SessionBuilder into Session
821
+ /// .await?;
822
+ /// # Ok(())
823
+ /// # }
824
+ /// ```
825
+ pub fn hostname_resolution_timeout ( mut self , duration : Duration ) -> Self {
826
+ self . config . hostname_resolution_timeout = Some ( duration) ;
827
+ self
828
+ }
829
+
809
830
/// Sets the host filter. The host filter decides whether any connections
810
831
/// should be opened to the node or not. The driver will also avoid
811
832
/// those nodes when re-establishing the control connection.
You can’t perform that action at this time.
0 commit comments