Skip to content

Commit b059785

Browse files
authored
Core: Refactored the connection container lock to use a sync RwLock (#2643)
* Core: Refactored the connection container lock to use a synchronous RwLock instead of an asynchronous one, and reducing lock acquisition time. * Core: Fixed redis-rs pubsub tests for server version >= 7.2.4 Signed-off-by: barshaul <[email protected]>
1 parent 66273f4 commit b059785

File tree

6 files changed

+340
-270
lines changed

6 files changed

+340
-270
lines changed

glide-core/redis-rs/redis/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ once_cell = "1"
184184
anyhow = "1"
185185
sscanf = "0.4.1"
186186
serial_test = "2"
187+
versions = "6.3"
187188

188189
[[test]]
189190
name = "test_async"

glide-core/redis-rs/redis/src/cluster_async/connections_container.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ where
297297
&self,
298298
amount: usize,
299299
conn_type: ConnectionType,
300-
) -> Option<impl Iterator<Item = ConnectionAndAddress<Connection>> + '_> {
300+
) -> Option<Vec<ConnectionAndAddress<Connection>>> {
301301
(!self.connection_map.is_empty()).then_some({
302302
self.connection_map
303303
.iter()
@@ -308,6 +308,7 @@ where
308308
let conn = node.get_connection(&conn_type);
309309
(address.clone(), conn)
310310
})
311+
.collect::<Vec<_>>()
311312
})
312313
}
313314

@@ -693,6 +694,7 @@ mod tests {
693694
let random_connections: HashSet<_> = container
694695
.random_connections(3, ConnectionType::User)
695696
.expect("No connections found")
697+
.into_iter()
696698
.map(|pair| pair.1)
697699
.collect();
698700

@@ -723,6 +725,7 @@ mod tests {
723725
let random_connections: Vec<_> = container
724726
.random_connections(1, ConnectionType::User)
725727
.expect("No connections found")
728+
.into_iter()
726729
.collect();
727730

728731
assert_eq!(vec![(address, 4)], random_connections);
@@ -734,6 +737,7 @@ mod tests {
734737
let mut random_connections: Vec<_> = container
735738
.random_connections(1000, ConnectionType::User)
736739
.expect("No connections found")
740+
.into_iter()
737741
.map(|pair| pair.1)
738742
.collect();
739743
random_connections.sort();
@@ -747,6 +751,7 @@ mod tests {
747751
let mut random_connections: Vec<_> = container
748752
.random_connections(1000, ConnectionType::PreferManagement)
749753
.expect("No connections found")
754+
.into_iter()
750755
.map(|pair| pair.1)
751756
.collect();
752757
random_connections.sort();

0 commit comments

Comments
 (0)