@@ -34,6 +34,7 @@ use crate::{
34
34
response:: Response ,
35
35
Method ,
36
36
} ,
37
+ nodes:: { NodesInfo , NodesInfoParts } ,
37
38
} ;
38
39
use base64:: write:: EncoderWriter as Base64Encoder ;
39
40
use bytes:: BytesMut ;
@@ -380,10 +381,13 @@ impl Transport {
380
381
Q : Serialize + ?Sized ,
381
382
{
382
383
if self . conn_pool . reseedable ( ) {
383
- // Reseed nodes
384
- println ! ( "Reseeding!" ) ;
384
+ self . conn_pool . reseeding ( ) ;
385
+ // NodesInfo::new(&self, NodesInfoParts::None)
386
+ // .send()
387
+ // .await
388
+ // .expect("Could not retrieve nodes for refresh");
385
389
}
386
- let connection = self . conn_pool . next ( ) ;
390
+ let connection = self . conn_pool . next ( )
387
391
let url = connection. url . join ( path. trim_start_matches ( '/' ) ) ?;
388
392
let reqwest_method = self . method ( method) ;
389
393
let mut request_builder = self . client . request ( reqwest_method, url) ;
@@ -471,6 +475,9 @@ pub trait ConnectionPool: Debug + dyn_clone::DynClone + Sync + Send {
471
475
false
472
476
}
473
477
478
+ // NOOP
479
+ fn reseeding ( & self ) { }
480
+
474
481
// NOOP by default
475
482
fn reseed ( & self , _connection : Vec < Connection > ) { }
476
483
}
@@ -637,6 +644,7 @@ pub struct MultiNodeConnectionPool<TStrategy = RoundRobin> {
637
644
638
645
#[ derive( Debug , Clone ) ]
639
646
pub struct MultiNodeConnectionPoolInner {
647
+ reseeding : bool ,
640
648
last_update : Option < Instant > ,
641
649
connections : Vec < Connection > ,
642
650
}
@@ -660,14 +668,20 @@ where
660
668
. last_update
661
669
. as_ref ( )
662
670
. map ( |last_update| last_update. elapsed ( ) > wait) ;
663
- last_update_is_stale. unwrap_or ( true )
671
+ last_update_is_stale. unwrap_or ( true ) && !inner. reseeding
672
+ }
673
+
674
+ fn reseeding ( & self ) {
675
+ let mut inner = self . inner . write ( ) . expect ( "Lock Poisoned" ) ;
676
+ inner. reseeding = true
664
677
}
665
678
666
679
fn reseed ( & self , mut connection : Vec < Connection > ) {
667
680
let mut inner = self . inner . write ( ) . expect ( "lock poisoned" ) ;
668
681
inner. last_update = Some ( Instant :: now ( ) ) ;
669
682
inner. connections . clear ( ) ;
670
683
inner. connections . append ( & mut connection) ;
684
+ inner. reseeding = false ;
671
685
}
672
686
}
673
687
@@ -678,6 +692,7 @@ impl MultiNodeConnectionPool<RoundRobin> {
678
692
679
693
let inner: Arc < RwLock < MultiNodeConnectionPoolInner > > =
680
694
Arc :: new ( RwLock :: new ( MultiNodeConnectionPoolInner {
695
+ reseeding : false ,
681
696
last_update : None ,
682
697
connections,
683
698
} ) ) ;
0 commit comments