Skip to content

Commit afb32ea

Browse files
committed
editoast: remove valkey cluster client
Signed-off-by: Florian Amsallem <[email protected]>
1 parent 85e2e06 commit afb32ea

File tree

3 files changed

+0
-24
lines changed

3 files changed

+0
-24
lines changed

editoast/src/client/valkey_config.rs

-5
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ pub struct ValkeyConfig {
1111
#[derivative(Default(value = "false"))]
1212
#[clap(long, env, default_value_t = false)]
1313
pub no_cache: bool,
14-
#[derivative(Default(value = "false"))]
15-
#[clap(long, env, default_value_t = false)]
16-
pub is_cluster_client: bool,
1714
#[derivative(Default(value = r#"Url::parse("redis://localhost:6379").unwrap()"#))]
1815
#[arg(long, env, default_value_t = Url::parse("redis://localhost:6379").unwrap())]
1916
/// Valkey url like `redis://[:PASSWORD@]HOST[:PORT][/DATABASE]`
@@ -24,13 +21,11 @@ impl From<ValkeyConfig> for valkey_utils::ValkeyConfig {
2421
fn from(
2522
ValkeyConfig {
2623
no_cache,
27-
is_cluster_client,
2824
valkey_url,
2925
}: ValkeyConfig,
3026
) -> Self {
3127
valkey_utils::ValkeyConfig {
3228
no_cache,
33-
is_cluster_client,
3429
valkey_url,
3530
}
3631
}

editoast/src/valkey_utils.rs

-18
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ use futures::future;
44
use futures::FutureExt;
55
use redis::aio::ConnectionLike;
66
use redis::aio::ConnectionManager;
7-
use redis::cluster::ClusterClient;
8-
use redis::cluster_async::ClusterConnection;
97
use redis::cmd;
108
use redis::AsyncCommands;
119
use redis::Client;
@@ -22,7 +20,6 @@ use url::Url;
2220
use crate::error::Result;
2321

2422
pub enum ValkeyConnection {
25-
Cluster(ClusterConnection),
2623
Tokio(ConnectionManager),
2724
NoCache,
2825
}
@@ -59,7 +56,6 @@ fn no_cache_cmd_handler(cmd: &redis::Cmd) -> std::result::Result<redis::Value, R
5956
impl ConnectionLike for ValkeyConnection {
6057
fn req_packed_command<'a>(&'a mut self, cmd: &'a redis::Cmd) -> RedisFuture<'a, redis::Value> {
6158
match self {
62-
ValkeyConnection::Cluster(connection) => connection.req_packed_command(cmd),
6359
ValkeyConnection::Tokio(connection) => connection.req_packed_command(cmd),
6460
ValkeyConnection::NoCache => future::ready(no_cache_cmd_handler(cmd)).boxed(),
6561
}
@@ -72,9 +68,6 @@ impl ConnectionLike for ValkeyConnection {
7268
count: usize,
7369
) -> RedisFuture<'a, Vec<redis::Value>> {
7470
match self {
75-
ValkeyConnection::Cluster(connection) => {
76-
connection.req_packed_commands(cmd, offset, count)
77-
}
7871
ValkeyConnection::Tokio(connection) => {
7972
connection.req_packed_commands(cmd, offset, count)
8073
}
@@ -92,7 +85,6 @@ impl ConnectionLike for ValkeyConnection {
9285

9386
fn get_db(&self) -> i64 {
9487
match self {
95-
ValkeyConnection::Cluster(connection) => connection.get_db(),
9688
ValkeyConnection::Tokio(connection) => connection.get_db(),
9789
ValkeyConnection::NoCache => 0,
9890
}
@@ -267,7 +259,6 @@ impl ValkeyConnection {
267259

268260
#[derive(Clone)]
269261
pub enum ValkeyClient {
270-
Cluster(ClusterClient),
271262
Tokio(Client),
272263
/// This doesn't cache anything. It has no backend.
273264
NoCache,
@@ -277,7 +268,6 @@ pub enum ValkeyClient {
277268
pub struct ValkeyConfig {
278269
/// Disables caching. This should not be used in production.
279270
pub no_cache: bool,
280-
pub is_cluster_client: bool,
281271
pub valkey_url: Url,
282272
}
283273

@@ -286,21 +276,13 @@ impl ValkeyClient {
286276
if valkey_config.no_cache {
287277
return Ok(ValkeyClient::NoCache);
288278
}
289-
if valkey_config.is_cluster_client {
290-
return Ok(ValkeyClient::Cluster(
291-
redis::cluster::ClusterClient::new(vec![valkey_config.valkey_url]).unwrap(),
292-
));
293-
}
294279
Ok(ValkeyClient::Tokio(
295280
redis::Client::open(valkey_config.valkey_url).unwrap(),
296281
))
297282
}
298283

299284
pub async fn get_connection(&self) -> RedisResult<ValkeyConnection> {
300285
match self {
301-
ValkeyClient::Cluster(client) => Ok(ValkeyConnection::Cluster(
302-
client.get_async_connection().await?,
303-
)),
304286
ValkeyClient::Tokio(client) => Ok(ValkeyConnection::Tokio(
305287
client.get_connection_manager().await?,
306288
)),

editoast/src/views/test_app.rs

-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ impl TestAppBuilder {
161161
},
162162
valkey_config: ValkeyConfig {
163163
no_cache: false,
164-
is_cluster_client: false,
165164
valkey_url: Url::parse("redis://localhost:6379").unwrap(),
166165
},
167166
};

0 commit comments

Comments
 (0)