Skip to content

Commit

Permalink
Deprecate older MultiplexedConnection constructors.
Browse files Browse the repository at this point in the history
They're replaced with a constructor that uses a shared config type after redis-rs#1167
  • Loading branch information
nihohit committed Jun 11, 2024
1 parent 7f51000 commit 4e8e94c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
9 changes: 5 additions & 4 deletions redis/src/aio/connection_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use super::RedisFuture;
use crate::cmd::Cmd;
use crate::push_manager::PushManager;
use crate::types::{RedisError, RedisResult, Value};
use crate::AsyncConnectionConfig;
use crate::{
aio::{ConnectionLike, MultiplexedConnection, Runtime},
Client,
Expand Down Expand Up @@ -298,11 +299,11 @@ impl ConnectionManager {
connection_timeout: std::time::Duration,
) -> RedisResult<MultiplexedConnection> {
let retry_strategy = exponential_backoff.map(jitter).take(number_of_retries);
let config = AsyncConnectionConfig::new()
.set_connection_timeout(connection_timeout)
.set_response_timeout(response_timeout);
Retry::spawn(retry_strategy, || {
client.get_multiplexed_async_connection_with_timeouts(
response_timeout,
connection_timeout,
)
client.get_multiplexed_async_connection_with_config(&config)
})
.await
}
Expand Down
9 changes: 5 additions & 4 deletions redis/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ impl AsyncConnectionConfig {
}

/// Sets the connection timeout
pub fn with_connection_timeout(mut self, connection_timeout: std::time::Duration) -> Self {
pub fn set_connection_timeout(mut self, connection_timeout: std::time::Duration) -> Self {
self.connection_timeout = Some(connection_timeout);
self
}

/// Sets the response timeout
pub fn with_response_timeout(mut self, response_timeout: std::time::Duration) -> Self {
pub fn set_response_timeout(mut self, response_timeout: std::time::Duration) -> Self {
self.response_timeout = Some(response_timeout);
self
}
Expand Down Expand Up @@ -181,15 +181,16 @@ impl Client {
docsrs,
doc(cfg(any(feature = "tokio-comp", feature = "async-std-comp")))
)]
#[deprecated(note = "Use `get_multiplexed_async_connection_with_config` instead")]
pub async fn get_multiplexed_async_connection_with_timeouts(
&self,
response_timeout: std::time::Duration,
connection_timeout: std::time::Duration,
) -> RedisResult<crate::aio::MultiplexedConnection> {
self.get_multiplexed_async_connection_with_config(
&AsyncConnectionConfig::new()
.with_connection_timeout(connection_timeout)
.with_response_timeout(response_timeout),
.set_connection_timeout(connection_timeout)
.set_response_timeout(response_timeout),
)
.await
}
Expand Down
8 changes: 4 additions & 4 deletions redis/src/cluster_async/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1399,11 +1399,11 @@ impl Connect for MultiplexedConnection {
async move {
let connection_info = info.into_connection_info()?;
let client = crate::Client::open(connection_info)?;
let config = crate::AsyncConnectionConfig::new()
.set_connection_timeout(connection_timeout)
.set_response_timeout(response_timeout);
client
.get_multiplexed_async_connection_with_timeouts(
response_timeout,
connection_timeout,
)
.get_multiplexed_async_connection_with_config(&config)
.await
}
.boxed()
Expand Down
8 changes: 4 additions & 4 deletions redis/tests/test_sentinel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ pub mod async_tests {
.unwrap();

let connection_options =
AsyncConnectionConfig::new().with_connection_timeout(std::time::Duration::from_secs(1));
AsyncConnectionConfig::new().set_connection_timeout(std::time::Duration::from_secs(1));

block_on_all(async move {
let mut master_con = master_client
Expand Down Expand Up @@ -562,7 +562,7 @@ pub mod async_tests {
.unwrap();

let connection_options =
AsyncConnectionConfig::new().with_response_timeout(std::time::Duration::from_secs(1));
AsyncConnectionConfig::new().set_response_timeout(std::time::Duration::from_secs(1));

block_on_all(async move {
let mut master_con = master_client
Expand Down Expand Up @@ -616,8 +616,8 @@ pub mod async_tests {
.unwrap();

let connection_options = AsyncConnectionConfig::new()
.with_connection_timeout(std::time::Duration::from_secs(1))
.with_response_timeout(std::time::Duration::from_secs(1));
.set_connection_timeout(std::time::Duration::from_secs(1))
.set_response_timeout(std::time::Duration::from_secs(1));

block_on_all(async move {
let mut master_con = master_client
Expand Down

0 comments on commit 4e8e94c

Please sign in to comment.