Skip to content

Commit 07ad7dd

Browse files
committed
Breaking changes: renamed ClusterConnectionNotFound to AllConnectionsUnavailable, added new error ConnectionNotFoundForRoute
1 parent 2266116 commit 07ad7dd

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

redis/src/cluster_async/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ impl<C> Future for Request<C> {
808808
let request = this.request.as_mut().unwrap();
809809
// TODO - would be nice if we didn't need to repeat this code twice, with & without retries.
810810
if request.retry >= this.retry_params.number_of_retries {
811-
let next = if err.kind() == ErrorKind::ClusterConnectionNotFound {
811+
let next = if err.kind() == ErrorKind::AllConnectionsUnavailable {
812812
Next::ReconnectToInitialNodes { request: None }.into()
813813
} else if matches!(err.retry_method(), crate::types::RetryMethod::MovedRedirect)
814814
|| matches!(target, OperationTarget::NotFound)
@@ -836,7 +836,7 @@ impl<C> Future for Request<C> {
836836
}
837837
request.retry = request.retry.saturating_add(1);
838838

839-
if err.kind() == ErrorKind::ClusterConnectionNotFound {
839+
if err.kind() == ErrorKind::AllConnectionsUnavailable {
840840
return Next::ReconnectToInitialNodes {
841841
request: Some(this.request.take().unwrap()),
842842
}
@@ -1255,7 +1255,7 @@ where
12551255
} else {
12561256
Err(last_err.unwrap_or_else(|| {
12571257
(
1258-
ErrorKind::ClusterConnectionNotFound,
1258+
ErrorKind::AllConnectionsUnavailable,
12591259
"Couldn't find any connection",
12601260
)
12611261
.into()
@@ -1651,7 +1651,7 @@ where
16511651
return OperationResult::Err((
16521652
OperationTarget::FanOut,
16531653
(
1654-
ErrorKind::ClusterConnectionNotFound,
1654+
ErrorKind::AllConnectionsUnavailable,
16551655
"No connections found for multi-node operation",
16561656
)
16571657
.into(),
@@ -1695,7 +1695,7 @@ where
16951695
)
16961696
} else {
16971697
let _ = sender.send(Err((
1698-
ErrorKind::ClusterConnectionNotFound,
1698+
ErrorKind::ConnectionNotFoundForRoute,
16991699
"Connection not found",
17001700
)
17011701
.into()));
@@ -1866,7 +1866,7 @@ where
18661866
&& !RoutingInfo::is_key_routing_command(&routable_cmd.unwrap())
18671867
{
18681868
return Err((
1869-
ErrorKind::ClusterConnectionNotFound,
1869+
ErrorKind::ConnectionNotFoundForRoute,
18701870
"Requested connection not found for route",
18711871
format!("{route:?}"),
18721872
)
@@ -1887,7 +1887,7 @@ where
18871887
return Ok((address, conn.await));
18881888
} else {
18891889
return Err((
1890-
ErrorKind::ClusterConnectionNotFound,
1890+
ErrorKind::ConnectionNotFoundForRoute,
18911891
"Requested connection not found",
18921892
address,
18931893
)
@@ -1933,7 +1933,7 @@ where
19331933
.random_connections(1, ConnectionType::User)
19341934
.next()
19351935
.ok_or(RedisError::from((
1936-
ErrorKind::ClusterConnectionNotFound,
1936+
ErrorKind::AllConnectionsUnavailable,
19371937
"No random connection found",
19381938
)))?;
19391939
return Ok((random_address, random_conn_future.await));

redis/src/commands/cluster_scan.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,9 @@ where
451451
// the connection to the address cant be reached from different reasons, we will check we want to check if
452452
// the problem is problem that we can recover from like failover or scale down or some network issue
453453
// that we can retry the scan command to an address that own the next slot we are at.
454-
ErrorKind::IoError | ErrorKind::ClusterConnectionNotFound => {
454+
ErrorKind::IoError
455+
| ErrorKind::AllConnectionsUnavailable
456+
| ErrorKind::ConnectionNotFoundForRoute => {
455457
let retry =
456458
retry_scan(&scan_state, &core, match_pattern, count, object_type).await?;
457459
(from_redis_value(&retry.0?)?, retry.1)

redis/src/types.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,10 @@ pub enum ErrorKind {
133133
EmptySentinelList,
134134
/// Attempted to kill a script/function while they werent' executing
135135
NotBusy,
136-
/// Used when a cluster connection cannot find a connection to a valid node.
137-
ClusterConnectionNotFound,
136+
/// Used when no valid node connections remain in the cluster connection
137+
AllConnectionsUnavailable,
138+
/// Used when a connection is not found for the specified route.
139+
ConnectionNotFoundForRoute,
138140

139141
#[cfg(feature = "json")]
140142
/// Error Serializing a struct to JSON form
@@ -875,7 +877,8 @@ impl RedisError {
875877
ErrorKind::NoValidReplicasFoundBySentinel => "no valid replicas found by sentinel",
876878
ErrorKind::EmptySentinelList => "empty sentinel list",
877879
ErrorKind::NotBusy => "not busy",
878-
ErrorKind::ClusterConnectionNotFound => "connection to node in cluster not found",
880+
ErrorKind::AllConnectionsUnavailable => "no valid connections remain in the cluster",
881+
ErrorKind::ConnectionNotFoundForRoute => "No connection found for the requested route",
879882
#[cfg(feature = "json")]
880883
ErrorKind::Serialize => "serializing",
881884
ErrorKind::RESP3NotSupported => "resp3 is not supported by server",
@@ -1046,7 +1049,8 @@ impl RedisError {
10461049

10471050
ErrorKind::ParseError => RetryMethod::Reconnect,
10481051
ErrorKind::AuthenticationFailed => RetryMethod::Reconnect,
1049-
ErrorKind::ClusterConnectionNotFound => RetryMethod::Reconnect,
1052+
ErrorKind::AllConnectionsUnavailable => RetryMethod::Reconnect,
1053+
ErrorKind::ConnectionNotFoundForRoute => RetryMethod::Reconnect,
10501054

10511055
ErrorKind::IoError => match &self.repr {
10521056
ErrorRepr::IoError(err) => match err.kind() {

0 commit comments

Comments
 (0)