Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
barshaul committed Oct 9, 2024
1 parent 32f6466 commit 3fd8428
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 32 deletions.
26 changes: 11 additions & 15 deletions redis/src/cluster_async/connections_container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,21 +256,17 @@ where
amount: usize,
conn_type: ConnectionType,
) -> Option<impl Iterator<Item = ConnectionAndAddress<Connection>> + '_> {
if self.connection_map.is_empty() {
None
} else {
Some(
self.connection_map
.iter()
.choose_multiple(&mut rand::thread_rng(), amount)
.into_iter()
.map(move |item| {
let (address, node) = (item.key(), item.value());
let conn = node.get_connection(&conn_type);
(address.clone(), conn)
}),
)
}
(!self.connection_map.is_empty()).then(|| {
self.connection_map
.iter()
.choose_multiple(&mut rand::thread_rng(), amount)
.into_iter()
.map(move |item| {
let (address, node) = (item.key(), item.value());
let conn = node.get_connection(&conn_type);
(address.clone(), conn)
})
})
}

pub(crate) fn replace_or_add_connection_for_address(
Expand Down
19 changes: 3 additions & 16 deletions redis/src/cluster_async/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,6 @@ enum Next<C> {
// if not set, then a reconnect should happen without sending a request afterwards
request: Option<PendingRequest<C>>,
target: String,
should_retry: bool,
},
RefreshSlots {
// if not set, then a slot refresh should happen without sending a request afterwards
Expand Down Expand Up @@ -882,14 +881,9 @@ impl<C> Future for Request<C> {
|| matches!(retry_method, crate::types::RetryMethod::ReconnectAndRetry)
{
if let OperationTarget::Node { address } = target {
let should_retry = matches!(
retry_method,
crate::types::RetryMethod::ReconnectAndRetry
);
Next::Reconnect {
request: None,
target: address,
should_retry,
}
.into()
} else {
Expand Down Expand Up @@ -975,9 +969,8 @@ impl<C> Future for Request<C> {
crate::types::RetryMethod::ReconnectAndRetry
);
Next::Reconnect {
request: Some(request),
request: should_retry.then_some(request),
target: address,
should_retry,
}
.into()
}
Expand Down Expand Up @@ -2298,17 +2291,11 @@ where
}));
}
}
Next::Reconnect {
request,
target,
should_retry,
} => {
Next::Reconnect { request, target } => {
poll_flush_action =
poll_flush_action.change_state(PollFlushAction::Reconnect(vec![target]));
if let Some(request) = request {
if should_retry {
self.inner.pending_requests.lock().unwrap().push(request);
}
self.inner.pending_requests.lock().unwrap().push(request);
}
}
Next::ReconnectToInitialNodes { request } => {
Expand Down
2 changes: 1 addition & 1 deletion redis/tests/test_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ mod basic_async {
Err(err) => break err,
}
};
assert_eq!(err.kind(), ErrorKind::IoError); // Shouldn't this be IoError?
assert_eq!(err.kind(), ErrorKind::IoErrorRetrySafe);
}

#[tokio::test]
Expand Down

0 comments on commit 3fd8428

Please sign in to comment.