@@ -438,7 +438,7 @@ where
438438 & self ,
439439 slot : u16 ,
440440 slot_addr : SlotAddr ,
441- ) -> Option < String > {
441+ ) -> Option < Arc < String > > {
442442 self . conn_lock
443443 . read ( )
444444 . await
@@ -486,7 +486,7 @@ where
486486 }
487487
488488 // return slots of node
489- pub ( crate ) async fn get_slots_of_address ( & self , node_address : & str ) -> Vec < u16 > {
489+ pub ( crate ) async fn get_slots_of_address ( & self , node_address : Arc < String > ) -> Vec < u16 > {
490490 self . conn_lock
491491 . read ( )
492492 . await
@@ -1090,7 +1090,6 @@ where
10901090 Self :: refresh_slots_and_subscriptions_with_retries (
10911091 connection. inner . clone ( ) ,
10921092 & RefreshPolicy :: NotThrottable ,
1093- None ,
10941093 )
10951094 . await ?;
10961095
@@ -1250,7 +1249,6 @@ where
12501249 if let Err ( err) = Self :: refresh_slots_and_subscriptions_with_retries (
12511250 inner. clone ( ) ,
12521251 & RefreshPolicy :: Throttable ,
1253- None ,
12541252 )
12551253 . await
12561254 {
@@ -1492,7 +1490,6 @@ where
14921490 async fn refresh_slots_and_subscriptions_with_retries (
14931491 inner : Arc < InnerCore < C > > ,
14941492 policy : & RefreshPolicy ,
1495- moved_redirect : Option < RedirectNode > ,
14961493 ) -> RedisResult < ( ) > {
14971494 let SlotRefreshState {
14981495 in_progress,
@@ -1544,10 +1541,6 @@ where
15441541 Self :: refresh_slots ( inner. clone ( ) , curr_retry)
15451542 } )
15461543 . await ;
1547- } else if moved_redirect. is_some ( ) {
1548- // Update relevant slots in the slots map based on the moved_redirect address,
1549- // rather than refreshing all slots by querying the cluster nodes for their topology view.
1550- Self :: update_slots_for_redirect_change ( inner. clone ( ) , moved_redirect) . await ?;
15511544 }
15521545 in_progress. store ( false , Ordering :: Relaxed ) ;
15531546
@@ -1556,15 +1549,6 @@ where
15561549 res
15571550 }
15581551
1559- /// Update relevant slots in the slots map based on the moved_redirect address
1560- pub ( crate ) async fn update_slots_for_redirect_change (
1561- _inner : Arc < InnerCore < C > > ,
1562- _moved_redirect : Option < RedirectNode > ,
1563- ) -> RedisResult < ( ) > {
1564- // TODO: Add implementation
1565- Ok ( ( ) )
1566- }
1567-
15681552 /// Determines if the cluster topology has changed and refreshes slots and subscriptions if needed.
15691553 /// Returns `RedisResult` with `true` if changes were detected and slots were refreshed,
15701554 /// or `false` if no changes were found. Raises an error if refreshing the topology fails.
@@ -1574,7 +1558,7 @@ where
15741558 ) -> RedisResult < bool > {
15751559 let topology_changed = Self :: check_for_topology_diff ( inner. clone ( ) ) . await ;
15761560 if topology_changed {
1577- Self :: refresh_slots_and_subscriptions_with_retries ( inner. clone ( ) , policy, None ) . await ?;
1561+ Self :: refresh_slots_and_subscriptions_with_retries ( inner. clone ( ) , policy) . await ?;
15781562 }
15791563 Ok ( topology_changed)
15801564 }
@@ -1797,21 +1781,20 @@ where
17971781 . 0 ?;
17981782 let connections = & * read_guard;
17991783 // Create a new connection vector of the found nodes
1800- let mut nodes = new_slots. values ( ) . flatten ( ) . collect :: < Vec < _ > > ( ) ;
1801- nodes. sort_unstable ( ) ;
1802- nodes. dedup ( ) ;
1784+ let nodes = new_slots. all_node_addresses ( ) ;
18031785 let nodes_len = nodes. len ( ) ;
18041786 let addresses_and_connections_iter = stream:: iter ( nodes)
18051787 . fold (
18061788 Vec :: with_capacity ( nodes_len) ,
18071789 |mut addrs_and_conns, addr| async move {
1790+ let addr = addr. to_string ( ) ;
18081791 if let Some ( node) = connections. node_for_address ( addr. as_str ( ) ) {
18091792 addrs_and_conns. push ( ( addr, Some ( node) ) ) ;
18101793 return addrs_and_conns;
18111794 }
18121795 // If it's a DNS endpoint, it could have been stored in the existing connections vector using the resolved IP address instead of the DNS endpoint's name.
18131796 // We shall check if a connection is already exists under the resolved IP name.
1814- let ( host, port) = match get_host_and_port_from_addr ( addr) {
1797+ let ( host, port) = match get_host_and_port_from_addr ( & addr) {
18151798 Some ( ( host, port) ) => ( host, port) ,
18161799 None => {
18171800 addrs_and_conns. push ( ( addr, None ) ) ;
@@ -1837,18 +1820,18 @@ where
18371820 |connections, ( addr, node) | async {
18381821 let mut cluster_params = inner. cluster_params . clone ( ) ;
18391822 let subs_guard = inner. subscriptions_by_address . read ( ) . await ;
1840- cluster_params. pubsub_subscriptions = subs_guard. get ( addr) . cloned ( ) ;
1823+ cluster_params. pubsub_subscriptions = subs_guard. get ( & addr) . cloned ( ) ;
18411824 drop ( subs_guard) ;
18421825 let node = get_or_create_conn (
1843- addr,
1826+ & addr,
18441827 node,
18451828 & cluster_params,
18461829 RefreshConnectionType :: AllConnections ,
18471830 inner. glide_connection_options . clone ( ) ,
18481831 )
18491832 . await ;
18501833 if let Ok ( node) = node {
1851- connections. 0 . insert ( addr. into ( ) , node) ;
1834+ connections. 0 . insert ( addr, node) ;
18521835 }
18531836 connections
18541837 } ,
@@ -2192,7 +2175,6 @@ where
21922175 * future = Box :: pin ( Self :: refresh_slots_and_subscriptions_with_retries (
21932176 self . inner . clone ( ) ,
21942177 & RefreshPolicy :: Throttable ,
2195- None ,
21962178 ) ) ;
21972179 Poll :: Ready ( Err ( err) )
21982180 }
@@ -2439,12 +2421,12 @@ where
24392421
24402422 match ready ! ( self . poll_complete( cx) ) {
24412423 PollFlushAction :: None => return Poll :: Ready ( Ok ( ( ) ) ) ,
2442- PollFlushAction :: RebuildSlots ( moved_redirect) => {
2424+ PollFlushAction :: RebuildSlots ( _moved_redirect) => {
2425+ // TODO: Add logic to update the slots map based on the MOVED error
24432426 self . state = ConnectionState :: Recover ( RecoverFuture :: RecoverSlots ( Box :: pin (
24442427 ClusterConnInner :: refresh_slots_and_subscriptions_with_retries (
24452428 self . inner . clone ( ) ,
24462429 & RefreshPolicy :: Throttable ,
2447- moved_redirect,
24482430 ) ,
24492431 ) ) ) ;
24502432 }
0 commit comments